| POST | /quote/order | Provide a quoteId to create an order. This will bill the order to your account. |
|---|
import Foundation
import ServiceStack
public class PlaceOrderFromQuote : ApiServiceRequest, ILogRequest
{
/**
* Optionally provide your own reference identifier
*/
// @ApiMember(Description="Optionally provide your own reference identifier")
public var clientReference:String
/**
* The quote the order is for
*/
// @ApiMember(Description="The quote the order is for", IsRequired=true)
public var quoteId:String
/**
* Set this to true to prevent creating an order and billing for it
*/
// @ApiMember(Description="Set this to true to prevent creating an order and billing for it", IsRequired=true)
public var test:Bool
/**
* Is your account allows Urgent Orders, you can use this flag to indicate when an Order is urgent.
*/
// @ApiMember(Description="Is your account allows Urgent Orders, you can use this flag to indicate when an Order is urgent.")
public var isUrgent:Bool
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case clientReference
case quoteId
case test
case isUrgent
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
clientReference = try container.decodeIfPresent(String.self, forKey: .clientReference)
quoteId = try container.decodeIfPresent(String.self, forKey: .quoteId)
test = try container.decodeIfPresent(Bool.self, forKey: .test)
isUrgent = try container.decodeIfPresent(Bool.self, forKey: .isUrgent)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if clientReference != nil { try container.encode(clientReference, forKey: .clientReference) }
if quoteId != nil { try container.encode(quoteId, forKey: .quoteId) }
if test != nil { try container.encode(test, forKey: .test) }
if isUrgent != nil { try container.encode(isUrgent, forKey: .isUrgent) }
}
}
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 PlaceOrderFromQuoteResponse : ApiServiceResponse
{
/**
* The ID of the order.
*/
// @ApiMember(Description="The ID of the order.")
public var orderId:String
/**
* User friendly waybill number
*/
// @ApiMember(Description="User friendly waybill number")
public var wayBill:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case orderId
case wayBill
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
orderId = try container.decodeIfPresent(String.self, forKey: .orderId)
wayBill = try container.decodeIfPresent(String.self, forKey: .wayBill)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if orderId != nil { try container.encode(orderId, forKey: .orderId) }
if wayBill != nil { try container.encode(wayBill, forKey: .wayBill) }
}
}
public class ApiServiceResponse : IServiceResponse, Codable
{
/**
* Information about the response.
*/
// @ApiMember(Description="Information about the response.", IsRequired=true)
public var Description:String
/**
* Heading or summary of the response.
*/
// @ApiMember(Description="Heading or summary of the response.", IsRequired=true)
public var heading:String
/**
* Did the intended operation for this response complete successfully?
*/
// @ApiMember(DataType="boolean", Description="Did the intended operation for this response complete successfully?", IsRequired=true)
public var wasSuccessful:Bool
required public init(){}
}
Swift PlaceOrderFromQuote DTOs
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 /quote/order HTTP/1.1
Host: api.1fetch.co.za
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<PlaceOrderFromQuote xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/WebService.ClientServiceModel">
<ApiKey xmlns="http://schemas.datacontract.org/2004/07/WebService.ClientServiceModel.Base">String</ApiKey>
<ClientReference>String</ClientReference>
<IsUrgent>false</IsUrgent>
<QuoteId>00000000-0000-0000-0000-000000000000</QuoteId>
<Test>false</Test>
</PlaceOrderFromQuote>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <PlaceOrderFromQuoteResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/WebService.ClientServiceModel"> <Description xmlns="http://schemas.datacontract.org/2004/07/WebService.ClientServiceModel.Base">String</Description> <Heading xmlns="http://schemas.datacontract.org/2004/07/WebService.ClientServiceModel.Base">String</Heading> <WasSuccessful xmlns="http://schemas.datacontract.org/2004/07/WebService.ClientServiceModel.Base">false</WasSuccessful> <OrderId>00000000-0000-0000-0000-000000000000</OrderId> <WayBill>String</WayBill> </PlaceOrderFromQuoteResponse>