OjpSdk

class OjpSdk(baseUrl: String, endpoint: String, requesterReference: String, httpHeaders: HashMap<String, String> = hashMapOf(), defaultTimeZone: ZoneId = ZoneId.of("Europe/Zurich"))

Created by Michael Ruppen on 08.04.2024

Parameters

baseUrl

The url where the SDK shall point to do the OJP requests ex: https://api.opentransportdata.swiss/

endpoint

The specific endpoint on the baseUrl to request ex: ojp20 => https://api.opentransportdata.swiss/ojp20

requesterReference

The reference for requests to help tracking on the OJP backend

httpHeaders

Define custom http headers ex. key: "Authorization" value: "Bearer xyz"

defaultTimeZone

Set the timeZone you want the dateTimes to be parsed at, default is "Europe/Zurich"

Constructors

Link copied to clipboard
constructor(baseUrl: String, endpoint: String, requesterReference: String, httpHeaders: HashMap<String, String> = hashMapOf(), defaultTimeZone: ZoneId = ZoneId.of("Europe/Zurich"))

Functions

Link copied to clipboard
suspend fun requestLocationsFromCoordinates(languageCode: LanguageCode = LanguageCode.DE, longitude: Double, latitude: Double, restrictions: LocationInformationParams): Result<List<PlaceResultDto>>

Request a list of Place Results based on the given geographical point

Link copied to clipboard
suspend fun requestLocationsFromSearchTerm(languageCode: LanguageCode = LanguageCode.DE, term: String, restrictions: LocationInformationParams): Result<List<PlaceResultDto>>

Request a list of Place Results based on the given search term

Link copied to clipboard

You can read an XML file of a tripRequest and use this function to get the parsed version out of it. This method is only used so you can have a real cased parsed object and for example test your UI.

Link copied to clipboard
suspend fun requestNextTrips(numberOfResults: Int = 5): Result<TripDeliveryDto>

Load further trips according to your last trip item of the tripResult list. Need to do a requestTrips call first!

Link copied to clipboard
suspend fun requestPreviousTrips(numberOfResults: Int = 5): Result<TripDeliveryDto>

Load previous trips according to your first trip item of the tripResult list. Need to do a requestTrips call first!

Link copied to clipboard

Refines a previously requested trip by retrieving more detailed or updated trip information

Link copied to clipboard
suspend fun requestTrips(languageCode: LanguageCode = LanguageCode.DE, origin: PlaceReferenceDto, destination: PlaceReferenceDto, via: PlaceReferenceDto? = null, time: LocalDateTime, isSearchForDepartureTime: Boolean = true, params: TripParams?): Result<TripDeliveryDto>

Request a list of trips

Link copied to clipboard
suspend fun updateTripData(languageCode: LanguageCode = LanguageCode.DE, origin: PlaceReferenceDto, destination: PlaceReferenceDto, via: PlaceReferenceDto?, params: TripParams?, trip: TripDto): Result<TripDeliveryDto>