Skip to content
EventFahrplanPublic

About

A Kotlin library containing a parser and models for Frab-compatible conference schedule JSON (versions 1 & 2).

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Build Maven Central Apache License

Schedule library

A Kotlin library containing parsers and models for Frab-compatible conference schedule JSON versions 1 and 2, as used by apps such as:

Usage

The library is published as two separate artifacts: schedule-base and schedule-repositories. You can use either of them depending on your needs.

Usage of schedule-base

The schedule-base artifact provides Retrofit services for both schedule formats. The suspending ScheduleService#getScheduleV1 and ScheduleService#getScheduleV2 functions return Response<ScheduleV1> and Response<ScheduleV2>, respectively. Choose the function that matches the JSON format served by the conference.

suspend fun loadSchedule(okHttpClient: Call.Factory, logging: Logging) {
    val api: ScheduleApi = Api
    val service: ScheduleService = api.provideScheduleService(
        baseUrl = "https://some.event.com/schedules/",
        callFactory = okHttpClient,
        logging = logging,
    )

    val requestETag = "" // Pass an empty string or a previous ETag value for caching
    val requestLastModifiedAt = "" // Pass an empty string or a previous Last-Modified value for caching
    val response = service.getScheduleV1(
        eTag = requestETag,
        lastModifiedAt = requestLastModifiedAt,
        path = "schedule.json",
    )

    if (response.isSuccessful) {
        val scheduleV1 = response.body()
        val responseETag = response.headers()["ETag"]
        val responseLastModifiedAt = response.headers()["Last-Modified"]
    } else {
        val errorCode = response.code()
        val errorMessage = response.message()
    }
}

Usage of schedule-repositories

The schedule-repositories artifact provides a Flow-based API for both formats. Call ScheduleRepository#getScheduleV1State for v1 (Flow<GetScheduleV1State>) or ScheduleRepository#getScheduleV2State for v2 (Flow<GetScheduleV2State>). The simple repository implementation is SimpleScheduleRepository.

suspend fun loadSchedule(okHttpClient: Call.Factory, logging: Logging) {
    val repository: ScheduleRepository = SimpleScheduleRepository(
        callFactory = okHttpClient,
        logging = logging,
        api = Api,
    )

    val requestETag = "" // Pass an empty string or a previous ETag value for caching
    val requestLastModifiedAt = "" // Pass an empty string or a previous Last-Modified value for caching
    repository.getScheduleV1State(
        url = "https://some.event.com/schedules/schedule.json",
        requestETag = requestETag,
        lastModifiedAt = requestLastModifiedAt,
    ).collectLatest { state ->
        when (state) {
            is Success -> {
                val scheduleV1 = state.scheduleV1
                val responseETag = state.responseETag
                val responseLastModifiedAt = state.responseLastModifiedAt
            }
            is Error -> {
                val httpStatusCode = state.httpStatusCode
                val errorMessage = state.errorMessage
            }
            is Failure -> {
                val throwable = state.throwable
            }
        }
    }
}

The v2 model is available under info.metadude.kotlin.library.schedule.v2.models. It represents scheduled events, planned (not yet scheduled) events and meta events separately, supports localized strings and v2 date and time types, ignores unknown JSON object keys, and maps unrecognized enum values to UNKNOWN where the format defines an enum fallback. Missing required fields still cause parsing to fail.

To use v2 with schedule-base, call ScheduleService#getScheduleV2, which returns Response<ScheduleV2>. To use v2 with schedule-repositories, call ScheduleRepository#getScheduleV2State, which returns Flow<GetScheduleV2State>. Its Success state exposes scheduleV2, and its Error and Failure states report HTTP errors and thrown exceptions, respectively.

Gradle build

To deploy the library to your local Maven repository run the following task:

$ ./gradlew publishToMavenLocal

Then, to use the library in your project add the following to your top level build.gradle:

allprojects {
    repositories {
        mavenLocal()
    }
}

and one of the following dependencies to your application module build.gradle:

dependencies {
    implementation "info.metadude.kotlin.library.schedule:schedule-base:$version"
    implementation "info.metadude.kotlin.library.schedule:schedule-repositories:$version"
}

Tests

Run the following command to execute all tests:

$ ./gradlew clean test

Author

License

Copyright 2026 Tobias Preuss

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

A Kotlin library containing a parser and models for Frab-compatible conference schedule JSON (versions 1 & 2).

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages