Trip

Handles Trip related requests with IMS web services.

Fetch by ID

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.

Concrete example

To fetch a trip by ID one can use following snippet

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))
})

Fetch by user

Fetch a Trip collection with expanded detail.

Parameters:

  • user: The user for which trips are being fetched. If nil, fetches the trips for the currently authenticated User. Defaults to nil.

  • filters: A Set of Filters for the request. Defaults to an empty set..

  • expansions: A Set of Expansions for the collection.

The filters include cursor(limit, offset), date(start, end)

Concrete example

To fetch a trip by user one can use following snippet

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))
})

Fetch all

Parameters:

  • filters: A Set of Filters for the request. Defaults to an empty set..

  • expansions: A Set of Expansions for the collection.

Concrete example

To fetch all trips one can use following snippet

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))
})

Update trip

Parameters:

  • trip: The Trip to update.

  • transportMode: The TransportMode to apply to the Trip.

  • purpose: The Purpose to apply to the Trip.

Concrete example

To update the trip one can use following snippet

let service = TripService(identity: identity)
service.update(trip,
               transportMode: TransportMode,
               purpose: purpose { result in
    switch result {
    case .success(_):
        // update successful
    case .failure(_):
        // error
    }
})

Fetch trips by vehicle

- Parameters:

  • vehicleId: The id of the vehicle for which we want the list of Trip

  • vehicleTripsLimit: The maximum number of trips

  • shouldExpandScores: If true will provide the scores information inside the Trip object

Concrete example

To fetch trips by vehicle, one can use following snippet

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))
})

Last updated