Instantly share code, notes, and snippets.

Embed
What would you like to do?
/**
Reservamos
*/
public func handle(intent: BookRideIntent, completion: @escaping (BookRideIntentResponse) -> Void) -> Void {
var rideParameters = RideRequestParameter()
rideParameters.origin = intent.origin?.location
rideParameters.destination = intent.destination?.location
if let payment = intent.payment {
switch payment.type {
case .applePay:
rideParameters.paymentMethod = PaymentMethod.applePay
case .debit:
rideParameters.paymentMethod = PaymentMethod.visa
default:
rideParameters.paymentMethod = PaymentMethod.paypal
}
}
if let car = intent.car, let identifier = car.identifier, let carType = CarType(rawValue: identifier) {
rideParameters.carType = carType
}
///
rideParameters.rideName = "From Siri Intents"
UbifyClient.shared.request(rideParameters) { (ride: Ride?, error: String?) -> Void in
if let ride = ride {
let response = BookRideIntentResponse(code: .success, userActivity: nil)
response.arrivalTime = NSNumber(value: ride.arrivalTime!)
response.driverName = ride.driver?.name
response.driverImageURL = ride.driver?.imageURL
completion(response)
} else {
completion(BookRideIntentResponse(code: .failure, userActivity: nil))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment