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 requestLocationsFromRectangle(languageCode: LanguageCode = LanguageCode.DE, upperLeftLongitude: Double, upperLeftLatitude: Double, lowerRightLongitude: Double, lowerRightLatitude: Double, restrictions: LocationInformationParams): Result<List<PlaceResultDto>>

Request a list of Place Results located within the given geographical rectangle (bounding box). This is typically used to load points of interest (e.g. shared mobility vehicles) for the currently visible map region.

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
suspend fun requestStopEvent(languageCode: LanguageCode = LanguageCode.DE, location: LocationDto, params: StopEventParam? = null): Result<StopEventDeliveryDto>

Requests stop event information (departures/arrivals) for a specific stop

Link copied to clipboard
suspend fun requestTripInfo(languageCode: LanguageCode = LanguageCode.DE, journeyRef: String, operatingDayRef: String, params: TripInfoParam? = null): Result<TripInfoDeliveryDto>

Requests detailed real-time information about a specific journey

Link copied to clipboard
suspend fun requestTripRefinement(languageCode: LanguageCode = LanguageCode.DE, tripResult: TripResultDto, params: TripRefineParam): Result<TripRefineDeliveryDto>

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?, individualTransportOption: IndividualTransportOptionDto? = null): 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, individualTransportOption: IndividualTransportOptionDto?): Result<TripDeliveryDto>

Updates the trip data for a given trip by re-requesting it with the same parameters