| POST | /pickmeup/pickmeup | Request a booking for the Pick Me Up service. |
|---|
import Foundation
import ServiceStack
public class PickMeUpRequest : PickMeUpActivationRequest
{
required public init(){ super.init() }
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
}
}
public class PickMeUpActivationRequest : ApiServiceRequest
{
/**
* ID Number of the user making this request.
*/
// @ApiMember(Description="ID Number of the user making this request.", IsRequired=true)
public var idNumber:String
/**
* The number of people to be picked up.
*/
// @ApiMember(Description="The number of people to be picked up.", IsRequired=true)
public var passengerCount:Int
/**
* Date and Time of the pickup in ISO 8601 format.
*/
// @ApiMember(Description="Date and Time of the pickup in ISO 8601 format.", IsRequired=true)
public var bookingDate:String
/**
* Name of contact person at pickup.
*/
// @ApiMember(Description="Name of contact person at pickup.", IsRequired=true)
public var contactName:String
/**
* Contact number of contact person at pickup.
*/
// @ApiMember(Description="Contact number of contact person at pickup.", IsRequired=true)
public var contactNumber:String
/**
* The location details of where the clients are to be picked up.
*/
// @ApiMember(DataType="BookingLocation", Description="The location details of where the clients are to be picked up.", IsRequired=true)
public var pickupLocation:BookingLocation
/**
* The location details of where the clients are to be dropped off.
*/
// @ApiMember(DataType="BookingLocation", Description="The location details of where the clients are to be dropped off.", IsRequired=true)
public var dropoffLocation:BookingLocation
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case idNumber
case passengerCount
case bookingDate
case contactName
case contactNumber
case pickupLocation
case dropoffLocation
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
idNumber = try container.decodeIfPresent(String.self, forKey: .idNumber)
passengerCount = try container.decodeIfPresent(Int.self, forKey: .passengerCount)
bookingDate = try container.decodeIfPresent(String.self, forKey: .bookingDate)
contactName = try container.decodeIfPresent(String.self, forKey: .contactName)
contactNumber = try container.decodeIfPresent(String.self, forKey: .contactNumber)
pickupLocation = try container.decodeIfPresent(BookingLocation.self, forKey: .pickupLocation)
dropoffLocation = try container.decodeIfPresent(BookingLocation.self, forKey: .dropoffLocation)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if idNumber != nil { try container.encode(idNumber, forKey: .idNumber) }
if passengerCount != nil { try container.encode(passengerCount, forKey: .passengerCount) }
if bookingDate != nil { try container.encode(bookingDate, forKey: .bookingDate) }
if contactName != nil { try container.encode(contactName, forKey: .contactName) }
if contactNumber != nil { try container.encode(contactNumber, forKey: .contactNumber) }
if pickupLocation != nil { try container.encode(pickupLocation, forKey: .pickupLocation) }
if dropoffLocation != nil { try container.encode(dropoffLocation, forKey: .dropoffLocation) }
}
}
public class ApiServiceRequest : IServiceRequest, IHasApiKey, Codable
{
/**
* The API Key required for authentication
*/
// @ApiMember(DataType="string", Description="The API Key required for authentication", IsRequired=true)
public var apiKey:String
required public init(){}
}
public class BookingLocation : Codable
{
/**
* Latitude of the pickup/drop-off location.
*/
// @ApiMember(Description="Latitude of the pickup/drop-off location.", IsRequired=true)
public var latitude:Double
/**
* Longitude of the pickup/drop-off location.
*/
// @ApiMember(Description="Longitude of the pickup/drop-off location.", IsRequired=true)
public var longitude:Double
/**
* Address of the pickup/drop-off location.
*/
// @ApiMember(Description="Address of the pickup/drop-off location.", IsRequired=true)
public var address:String
required public init(){}
}
public class PickMeUpResponse : ApiServiceResponse
{
/**
* Is the requested product set up and enabled on Galaxy.
*/
// @ApiMember(Description="Is the requested product set up and enabled on Galaxy.")
public var productAvailable:Bool
/**
* Does the user have access to this product, based on their Galaxy profile.
*/
// @ApiMember(Description="Does the user have access to this product, based on their Galaxy profile.")
public var userHasAccess:Bool
/**
* This indicates that the pickup location is outside of the service area of the service provider.
*/
// @ApiMember(Description="This indicates that the pickup location is outside of the service area of the service provider.")
public var pickupOutOfBounds:Bool
/**
* This indicates that the dropoff location is outside of the service area of the service provider.
*/
// @ApiMember(Description="This indicates that the dropoff location is outside of the service area of the service provider.")
public var dropoffOutOfBounds:Bool
/**
* This indicates that the pickup time is not far enough in the future. The time needs to be at least 60 minutes in the future, or 90 minutes during peak times. See the documentation for more details.
*/
// @ApiMember(Description="This indicates that the pickup time is not far enough in the future. The time needs to be at least 60 minutes in the future, or 90 minutes during peak times. See the documentation for more details.")
public var pickupTooSoon:Bool
/**
* The booking reference number returned by the service provider. To be shown to the client.
*/
// @ApiMember(Description="The booking reference number returned by the service provider. To be shown to the client.")
public var referenceNumber:String
/**
* Error message from service provider.
*/
// @ApiMember(Description="Error message from service provider.")
public var errorMessage:String
/**
* Error code from service provider.
*/
// @ApiMember(Description="Error code from service provider.")
public var errorCode:Int
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case productAvailable
case userHasAccess
case pickupOutOfBounds
case dropoffOutOfBounds
case pickupTooSoon
case referenceNumber
case errorMessage
case errorCode
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
productAvailable = try container.decodeIfPresent(Bool.self, forKey: .productAvailable)
userHasAccess = try container.decodeIfPresent(Bool.self, forKey: .userHasAccess)
pickupOutOfBounds = try container.decodeIfPresent(Bool.self, forKey: .pickupOutOfBounds)
dropoffOutOfBounds = try container.decodeIfPresent(Bool.self, forKey: .dropoffOutOfBounds)
pickupTooSoon = try container.decodeIfPresent(Bool.self, forKey: .pickupTooSoon)
referenceNumber = try container.decodeIfPresent(String.self, forKey: .referenceNumber)
errorMessage = try container.decodeIfPresent(String.self, forKey: .errorMessage)
errorCode = try container.decodeIfPresent(Int.self, forKey: .errorCode)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if productAvailable != nil { try container.encode(productAvailable, forKey: .productAvailable) }
if userHasAccess != nil { try container.encode(userHasAccess, forKey: .userHasAccess) }
if pickupOutOfBounds != nil { try container.encode(pickupOutOfBounds, forKey: .pickupOutOfBounds) }
if dropoffOutOfBounds != nil { try container.encode(dropoffOutOfBounds, forKey: .dropoffOutOfBounds) }
if pickupTooSoon != nil { try container.encode(pickupTooSoon, forKey: .pickupTooSoon) }
if referenceNumber != nil { try container.encode(referenceNumber, forKey: .referenceNumber) }
if errorMessage != nil { try container.encode(errorMessage, forKey: .errorMessage) }
if errorCode != nil { try container.encode(errorCode, forKey: .errorCode) }
}
}
public class ApiServiceResponse : IServiceResponse, Codable
{
public var Description:String
public var heading:String
public var wasSuccessful:Bool
//modelState:Object ignored. Type could not be extended in Swift
required public init(){}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /pickmeup/pickmeup HTTP/1.1
Host: galaxymobile.api.client.prod.86degrees.com
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<PickMeUpRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/WebService.ClientServiceModel.PickMeUp">
<ApiKey xmlns="http://schemas.datacontract.org/2004/07/WebService.ClientServiceModel.Base">String</ApiKey>
<BookingDate>String</BookingDate>
<ContactName>String</ContactName>
<ContactNumber>String</ContactNumber>
<DropoffLocation>
<Address>String</Address>
<Latitude>0</Latitude>
<Longitude>0</Longitude>
</DropoffLocation>
<IdNumber>String</IdNumber>
<PassengerCount>0</PassengerCount>
<PickupLocation>
<Address>String</Address>
<Latitude>0</Latitude>
<Longitude>0</Longitude>
</PickupLocation>
</PickMeUpRequest>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <PickMeUpResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/WebService.ClientServiceModel.PickMeUp"> <Description xmlns="http://schemas.datacontract.org/2004/07/CommonService.Api.Models.Base">String</Description> <Heading xmlns="http://schemas.datacontract.org/2004/07/CommonService.Api.Models.Base">String</Heading> <ModelState xmlns="http://schemas.datacontract.org/2004/07/CommonService.Api.Models.Base" /> <WasSuccessful xmlns="http://schemas.datacontract.org/2004/07/CommonService.Api.Models.Base">false</WasSuccessful> <DropoffOutOfBounds>false</DropoffOutOfBounds> <ErrorCode>0</ErrorCode> <ErrorMessage>String</ErrorMessage> <PickupOutOfBounds>false</PickupOutOfBounds> <PickupTooSoon>false</PickupTooSoon> <ProductAvailable>false</ProductAvailable> <ReferenceNumber>String</ReferenceNumber> <UserHasAccess>false</UserHasAccess> </PickMeUpResponse>