Comment on page
Discount
Handles Discount related requests with IMS web services.
The SDK allows for the host application to retrieve discount related data, which in turn can be used by the host application to fetch data from the Discount system (see documentation for the Discount).
This service will take in an Identity and return the current discount and projected discount, alongside some useful discount information. Discount values may not always be available due to insufficient driving data.
*Identity: In order to fetch discount data, the application must have a valid user (represented by the Identity). That user must be active.
To fetch discount data, one can use the following snippet
Swift
Kotlin
let service = DiscountService(identity: identity)
service.fetchDiscount(then: { discount in
guard !discount.value.isEmpty else {
// failure
return
}
completionHandler(.success(discount.value))
})
val discountService = DiscountService(identity)
discountService.fetchDiscount() { result: Result<DiscountMetaData>? ->
if (result?.value == null || result.throwable != null) {
// failure
} else {
// Success
val discountMetaData: DiscountMetaData = result?.value
completionHandler(discountMetaData)
}
}
Represents the mapping between scores ranges and discounts. The mappings of scores are represented as Ranges of Doubles to be consistent with the scoring values.
Any valid user on the DriveSync system (identified via the
Identity
) should be able to know how discount is calculated (score ranges vs discounts), so that driver knows how his/her driving style affecting his/her discount.*Identity: In order to fetch discount mapping data, the application must have a valid user (represented by the Identity). That user must be active.
To fetch discount mapping data, one can use the following snippet
Swift
Kotlin
let service = DiscountMetadataService(identity: identity)
service.fetchDiscountMetadata(then: { discount in
guard !discount.value.isEmpty else {
// failure
return
}
completionHandler(.success(discount.value))
})
val discountMetadataService = DiscountMetadataService(identity)
discountMetadataService.fetchMapping() { result: Result<List<DiscountMapping>>? ->
val discountMappings = result?.value
val error = result?.throwable
if (discountMappings != null) {
// Success
completionHandler(discountMappings)
} else if (error != null) {
// Failure
errorHandler(error)
}
}
The SDK allows for the host application to retrieve discount related data by vehicle, which in turn can be used by the host application to fetch data from the Discount system (see documentation for the Discount).
This service will take in an Identity and return the current discount and projected discount, alongside some useful discount information. Discount values may not always be available due to insufficient driving data.
*Identity: In order to fetch discount data, the application must have a valid user (represented by the Identity). That user must be active.
Since each account can be linked to multiple vehicles, vehicle ID is passed.
To fetch discount data by vehicle, one can use the following snippet
Kotlin
val discountService = DiscountService(identity)
discountService.fetchDiscountByVehicle(vehicleId) { result: Result<DiscountMetaData>? ->
if (result?.value == null || result.throwable != null) {
// failure
} else {
// Success
val discountMetaData: DiscountMetaData = result?.value
completionHandler(discountMetaData)
}
}
Last modified 2mo ago