A Kotlin library containing a parser and models for the Engelsystem:
The library is published as two separate artifacts: engelsystem-base
and engelsystem-repositories
.
You can use either of them depending on your needs.
The engelsystem-base
artifact returns a Response<List<Shift>>
type from the suspending
EngelsystemService#getShifts()
function.
val api: EngelsystemApi = Api
val service: EngelsystemService = api.provideEngelsystemService(BASE_URL, okHttpClient)
service.getShifts(
eTag = "", // Pass an empty string or a previous ETag value for caching
lastModifiedAt = "", // Pass an empty string or a previous Last-Modified value for caching
path = URL_PART_PATH,
apiKey = API_KEY,
)
if (response.isSuccessful) {
val shifts = response.body()
val responseETag = response.headers()["ETag"]
val responseLastModifiedAt = response.headers()["Last-Modified"]
} else {
val errorCode = response.code()
val errorMessage = response.message()
}
The engelsystem-repositories
artifact returns a Flow<GetShiftsState>
type from the suspending
SimpleEngelsystemRepository#getShiftsState()
function.
val api: EngelsystemApi = Api
val repository = SimpleEngelsystemRepository(
callFactory = OkHttpClient.Builder().build(),
api = api,
)
repository.getShiftsState(
requestETag = "", // Pass an empty string or a previous ETag value for caching
requestLastModifiedAt = "", // Pass an empty string or a previous Last-Modified value for caching
baseUrl = BASE_URL,
path = URL_PART_PATH,
apiKey = API_KEY,
)
.collectLatest { state: GetShiftsState ->
when (state) {
is Success -> {
val shifts = state.shifts
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 API response contains time stamps and a corresponding time zone offset.
When the properties of the Shift
model are read then these two information are joined.
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.engelsystem:engelsystem-base:$version"
implementation "info.metadude.kotlin.library.engelsystem:engelsystem-repositories:$version"
}
Alternatively, you can use JitPack to fetch and build the sources directly from this repository.
Run the following command to execute all tests:
$ ./gradlew clean test
Copyright 2019-2025 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.