IMS SDK Product Document
  • Getting Started
    • iOS
      • Requirements
      • Importing the SDK
      • Permissions
      • Initializing the SDK
      • Using the SDK
        • Using Push Notifications
          • Push notification certificate and profile creation guide
    • Android
      • Requirements
      • Import the SDK
      • Permissions
      • Obfuscation
      • Initialize the SDK
      • Using the SDK
        • Trip Detection and Recording
          • Trip Manager Configuration
            • Using TripDetector.AWARENESS
            • Trip Manager Device Support
          • Trip Manager Control
          • Trip Manager Status
        • Bluetooth and Other Devices
    • React Native
      • Requirements
      • Import the SDK
      • Permissions
      • Initialize the SDK
        • Android
        • iOS
      • Using the SDK
        • Trip Manager
        • Device service
    • Flutter
      • Requirements
      • Import the SDK
      • Permissions
      • Initialize the SDK
      • Using the SDK
  • Security
  • App misuse
  • Time Driven Without Phone
  • DriveSync Portal
    • Requirement
    • User
    • Device
    • Driving Alert
    • Push Notification
    • Invitations
    • Subscription
    • Trip
    • Location
    • Driving Summary
    • Discount
    • Scoring
    • Vehicle
    • Leaderboard
    • Rewards
    • Submit consent to EULA
    • Legal documents and FAQ
    • Named Driver
    • Wedge
  • Known Issues
    • iOS
    • Android
      • 1.17.0
      • 1.18.0
      • 1.22.0
  • Releases
    • 1.13.0
      • iOS
      • Android
    • 1.14.0
      • Android
    • 1.15.0
      • iOS
      • Android
    • 1.15.1
    • 1.16.0
      • iOS
      • Android
    • 1.17.0
      • iOS
      • Android
    • 1.18
      • iOS
      • Android
    • 1.18.1
    • 1.19.0
      • iOS
      • Android
    • 1.20.0
      • Android
      • iOS
    • 1.21.0
      • Android
      • iOS
    • 1.22.0
      • Android
      • iOS
    • 1.23.0
      • Android
      • iOS
    • 1.24.0
      • Android
      • iOS
    • 1.24.1
      • iOS
  • Migration
    • iOS
      • 1.15.x -> 1.16.0
      • 1.16.0 -> 1.17.0
      • 1.17.0 -> 1.18.0
      • 1.18.0 -> 1.19.0
      • 1.19.0 -> 1.20.0
      • 1.20.0 -> 1.21.0
      • 1.21.0 -> 1.22.0
      • 1.22.0 -> 1.23.0
      • 1.23.0 -> 1.24.0
      • 1.24.0 -> 1.24.1
    • Android
      • 1.15.x -> 1.16
      • 1.16 -> 1.17
      • 1.17 -> 1.18
      • 1.18 -> 1.19
      • 1.19 -> 1.20
      • 1.20 -> 1.21
      • 1.21 -> 1.22
      • 1.22 -> 1.23
      • 1.23 -> 1.24
  • Support
Powered by GitBook
On this page
  • Fetch by ID
  • Fetch by user
  • Fetch all
  • Update trip
  • Fetch trips by vehicle
  • Filter
  1. DriveSync Portal

Trip

Handles Trip related requests with IMS web services.

Fetch by ID

Parameters:

  • id: The unique ID of the `Trip`

  • expansions: A `Set` of Expansions for the `Trip`. Defaults to an empty set.

The Expansion includes events, scores, geometry, and user.

To fetch a trip by ID, the following API can be used.

Concrete example

let tripService = TripService()
tripService.fetch(id: id,
                  expansions: expansions then: { result in
    guard !result.value.empty else {
        // error
        return
    }
    completionHandler(.success(result.value))
})
val service = TripService()
service.fetch(id,
              expansions) { result: Result<Content?>? ->
    if (result?.value == null || result.throwable != null) {
        // failure
    } else {
        // Success
        val content = result.value
        completionHandler(content)
    }
})

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.

To fetch a trip by user, the following API can be used.

Concrete example

let tripService = TripService()
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()
service.fetch(user,
                 filters,
                 expansions) { result: Result<Content?>? ->
    if (result?.value == null || result.throwable != null) {
        // failure
    } else {
        // Success
        val content = result.value
        completionHandler(content)
    }
})

Fetch all

Parameters:

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

  • expansions: A Set of Expansions for the collection.

To fetch all trips, the following API can be used.

Concrete example

let tripService = TripService()
tripService.fetchAll(filters: [Filter],
                     expansions: expansions then: { result in
    guard !result.value.empty else {
        // error
        return
    }
    completionHandler(.success(result.value))
})
val service = TripService()
service.fetchAll(filters,
                 expansions) { result: Result<Content?>? ->
    if (result?.value == null || result.throwable != null) {
        // failure
    } else {
        // Success
        val content = result.value
        completionHandler(content)
    }
})

Update trip

Parameters:

  • trip: The Trip to update.

  • transportMode: The TransportMode to apply to the Trip.

  • purpose: The Purpose to apply to the Trip.

To update the trip, the following API can be used.

Concrete example

let service = TripService()
service.update(trip,
               transportMode: TransportMode,
               purpose: purpose { result in
    switch result {
    case .success(_):
        // update successful
    case .failure(_):
        // error
    }
})
val service = TripService()
service.updateTrip(trip,
                   transportationMode,
                   purpose) { result: Result<Content?>? ->
    if (result?.value == null || result.throwable != null) {
        // failure
    } else {
        // Success
        val content = result.value
        completionHandler(content)
    }
})

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

To fetch trips by vehicle, the following API can be used.

Concrete example

let service = TripService()
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()
service.fetchTripsByVehicle(vehicleId,
                            vehicleTripsLimit,
                            shouldExpandScore) { result: Result<Content?>? ->
    if (result?.value == null || result.throwable != null) {
        // failure
    } else {
        // Success
        val content = result.value
        completionHandler(content)
    }
})

Filter

The Trip APIs support pagination through a cursor parameter, which allows efficient navigation through a user's trips. The cursor utilizes two key fields: limit and offset.

Cursor Parameters

  • limit: Specifies the maximum number of trips to retrieve per request. If not provided, the default value is 50.

  • offset: Defines the starting point (index) for fetching trips, relative to the most recent trip.

Usage Example

Assume a user has a total of 200 trips. The host application can retrieve trips in pages using the cursor parameters as follows:

  1. Fetch the Most Recent Trips To retrieve the 50 most recent trips:

    cursor(limit: 50, offset: 0)
  2. Fetch the Next Page of Trips To retrieve the next 50 trips:

    cursor(limit: 50, offset: 50)
  3. Continue Paging Through Trips Subsequent requests can increment the offset by the limit value to fetch further pages:

    cursor(limit: 50, offset: 100) // Retrieves trips 101–150
    cursor(limit: 50, offset: 150) // Retrieves trips 151–200

Key Points to Note

  • The limit value should be chosen based on the application's requirement for batch size, balancing data size and API call frequency.

  • Pagination parameters enable efficient navigation through the logbook without overwhelming the API or client application with large data responses.

PreviousSubscriptionNextLocation

Last updated 5 months ago

The filters include cursor(limit, offset), date(start, end), check for paging through trips from the logbook.

here