Invitations
Handles Invitation related requests with IMS web services.
Last updated
Handles Invitation related requests with IMS web services.
Last updated
The SDK allows for the host application to enable the primary driver to send invitations to any secondary driver based on VEHICLE or FAMILY ACCOUNT.
To send the invitation, the following API can be used.In this example we send an invitation based on ACCOUNT.
let invitationService = InvitationService()
invitationService.sendAccountInvitation(fromUserID: fromUserID,
toUserFirstName: toUserFirstName,
toUserLastName: toUserLastName,
toUserEmail: toUserEmail,
toUserPhoneNumber: toUserPhoneNumber,
fromAccountIds: fromAccountIDs, then: { result in
switch result {
case .success(_):
// invitation successful
case .failure
// error
}
})
To send the invitation based on VEHICLE you need to provide vehicleIds field instead of fromAccountIds and call sendVehicleInvitation.
let invitationService = InvitationService()
invitationService.sendVehicleInvitation(fromUserID: fromUserID,
toUserFirstName: toUserFirstName,
toUserLastName: toUserLastName,
toUserEmail: toUserEmail,
toUserPhoneNumber: toUserPhoneNumber,
vehicleIDs: vehicleIDs, then: { result in
switch result {
case .success(_):
// invitation successful
case .failure
// error
}
})
The guest driver can be removed from the Family Account.
To remove secondary guest driver based on account, the following API can be used.
let service = InvitationService()
service.removeGuestDriverFromAccount(toUserId: userID,
accountId: accountID, then: { result in
switch result {
case .success(_):
// successfully removed
case .failure
// error
}
})
To remove secondary guest driver based on vehicle, the following API can be used.
let service = InvitationService()
service.removeGuestDriverFromVehicle(toUserId: userID,
vehicleId: vehicle, then: { result in
switch result {
case .success(_):
// successfully removed
case .failure
// error
}
})
The host application can retrieve pending invitations. The list contains all invitations that the user has sent or received, so apps should check the primaryDriver and secondaryDriver ID's to see if the current user sent (primary) or received (secondary) each one.
To retrieve the pending account invitations, the following API can be used.
let service = InvitationService()
service.fetchAccountInvites(then: { result in
guard !result.value?.isEmpty else {
// failure
return
}
completionHandler(.success(result.value))
})
To retrieve pending vehicle invites, the following API can be used.
let service = InvitationService()
service.fetchVehicleInvites(then: { result in
guard !result.value?.isEmpty else {
// failure
return
}
completionHandler(.success(result.value))
})
The host application can accept or decline pending invitations.
To accept an invitation, the following API can be used.
let service = InvitationService()
service.respondToInvitation(toUserId: toUserId,
invitationId: invitationId,
response: .accept, then: { result in
switch result
case .success(_):
// response successful
case .failure(_):
// error
})
To decline an invitation, the following API can be used.
let service = InvitationService()
service.respondToInvitation(toUserId: toUserId,
invitationId: invitationId,
response: .decline, then: { result in
switch result
case .success(_):
// response successful
case .failure(_):
// error
})
The host application can cancel pending invitations.
UserId: Only the user who sent the invitation can cancel it.
To cancel to an invitation, the following API can be used.
let service = InvitationService()
service.cancelVehicleInvitation(fromUserId: fromUserId,
invitationId: invitationId,
then: { result in
switch result
case .success(_):
// cancel successful
case .failure(_):
// error
})