Trip
Handles Trip related requests with IMS web services.
Parameters:
id
: The unique ID of the `Trip`expansions
: A `Set` of `Expansion`s for the `Trip`. Defaults to an empty set.
The Expansion includes
events
, scores
, geometry
, and user
.To fetch a trip by ID one can use following snippet
Swift
Kotlin
let tripService = TripService(identity: identity)
tripService.fetch(id: id,
expansions: expansions then: { result in
guard !result.value.empty else {
// error
return
}
completionHandler(.success(result.value))
})
val service = TripService(identity: identity)
service.fetch(id,
expansions) { result: Result<Content?>? ->
if (result?.value == null || result.throwable != null) {
// failure
} else {
// Success
val content = result.value
completionHandler(content)
}
})
Fetch a
Trip
collection with expanded detail.Parameters:
user
: The user for which trips are being fetched. Ifnil
, fetches the trips for the currently authenticatedUser
. Defaults tonil
.filters
: A Set ofFilters
for the request. Defaults to an empty set..expansions
: ASet
ofExpansion
s for the collection.
The filters include
cursor(limit, offset)
, date(start, end)
To fetch a trip by user one can use following snippet
Swift
Kotlin
let tripService = TripService(identity: identity)
tripService.fetch(user: user,
filters: [Filter],
expansions: expansions,
then: { result in
guard !result.value.empty else {
// error
return
}
completionHandler(.success(result.value))
})
val service = TripService(identity)
service.fetch(user,
filters,
expansions) { result: Result<Content?>? ->
if (result?.value == null || result.throwable != null) {
// failure
} else {
// Success
val content = result.value
completionHandler(content)
}
})
Parameters:
filters
: A Set ofFilters
for the request. Defaults to an empty set..expansions
: ASet
ofExpansion
s for the collection.
To fetch all trips one can use following snippet
Swift
Kotlin
let tripService = TripService(identity: identity)
tripService.fetchAll(filters: [Filter],
expansions: expansions then: { result in
guard !result.value.empty else {
// error
return
}
completionHandler(.success(result.value))
})
val service = TripService(identity)
service.fetchAll(filters,
expansions) { result: Result<Content?>? ->
if (result?.value == null || result.throwable != null) {
// failure
} else {
// Success
val content = result.value
completionHandler(content)
}
})
trip
: TheTrip
to update.transportMode
: TheTransportMode
to apply to theTrip
.purpose
: ThePurpose
to apply to theTrip
.
TransportMode options are:
- UNKNOWN
- DRIVER
- PASSENGER
- TRAIN
- BUS
- AIRPLANE
- TAXI
- MOTORCYCLE
- BOAT
- WALK
- BICYCLE
- PUBLIC_TRANSIT
- OTHER
The available TransportMode options are:
- UNKNOWN
- DRIVER
- PASSENGER
- TRAIN
- BUS
- AIRPLANE
- TAXI
- MOTORCYCLE
- BOAT
- WALK
- BICYCLE
- PUBLIC_TRANSIT
- OTHER
The Purposes of the trips can be:
- UNKNOWN
- PERSONAL
- BUSINESS
To update the trip one can use following snippet
Swift
Kotlin
let service = TripService(identity: identity)
service.update(trip,
transportMode: TransportMode,
purpose: purpose { result in
switch result {
case .success(_):
// update successful
case .failure(_):
// error
}
})
val service = TripService(identity)
service.updateTrip(trip,
transportationMode,
purpose) { result: Result<Content?>? ->
if (result?.value == null || result.throwable != null) {
// failure
} else {
// Success
val content = result.value
completionHandler(content)
}
})
- Parameters:
vehicleId
: Theid
of the vehicle for which we want the list ofTrip
vehicleTripsLimit
: The maximum number of tripsshouldExpandScores
: Iftrue
will provide the scores information inside theTrip
object
To fetch trips by vehicle, one can use following snippet
Swift
Kotlin
let service = TripService(identity: identity)
service.fetchTripsByVehicle(vehicleId: vehicleId,
vehicleTripsLimit: vehicleTripsLimit,
shouldExpandScores: shouldExpandScores, then: { result in
guard !result.value.isEmpty else {
// error
return
}
completionHandler(.success(result.value))
})
val service = TripService(identity: identity)
service.fetchTripsByVehicle(vehicleId,
vehicleTripsLimit,
shouldExpandScore) { result: Result<Content?>? ->
if (result?.value == null || result.throwable != null) {
// failure
} else {
// Success
val content = result.value
completionHandler(content)
}
})
Last modified 4mo ago