| POST | /dealers/order | Places a new order with the specified items. |
|---|
import Foundation
import ServiceStack
public class PostNewOrder : AuthenticatedRequest
{
/**
* Items to order.
*/
// @ApiMember(Description="Items to order.", IsRequired=true, ParameterType="body")
public var items:NewOrderItemList
/**
* Dropshipment indication.
*/
// @ApiMember(Description="Dropshipment indication.", ParameterType="body")
public var useDropshipment:Bool?
/**
* Delivery address.
*/
// @ApiMember(Description="Delivery address.", ParameterType="body")
public var deliveryAddress:NewOrderAddress
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case items
case useDropshipment
case deliveryAddress
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
items = try container.decodeIfPresent(NewOrderItemList.self, forKey: .items)
useDropshipment = try container.decodeIfPresent(Bool.self, forKey: .useDropshipment)
deliveryAddress = try container.decodeIfPresent(NewOrderAddress.self, forKey: .deliveryAddress)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if items != nil { try container.encode(items, forKey: .items) }
if useDropshipment != nil { try container.encode(useDropshipment, forKey: .useDropshipment) }
if deliveryAddress != nil { try container.encode(deliveryAddress, forKey: .deliveryAddress) }
}
}
public class AuthenticatedRequest : Codable
{
/**
* Session token received from successful authentication.
*/
// @ApiMember(Description="Session token received from successful authentication.", IsRequired=true, ParameterType="query")
public var sessionToken:String
required public init(){}
}
public class NewOrderItemList : List<NewOrderItem>
{
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 NewOrderItem : Codable
{
/**
* Unique ID for the part.
*/
// @ApiMember(Description="Unique ID for the part.", IsRequired=true, ParameterType="body")
public var partId:Int
/**
* Quantity to order.
*/
// @ApiMember(Description="Quantity to order.", IsRequired=true, ParameterType="body")
public var quantity:Int
/**
* Custom reference.
*/
// @ApiMember(Description="Custom reference.", ParameterType="body")
public var reference:String
required public init(){}
}
public class NewOrderAddress : IAddress, Codable
{
/**
* Company name.
*/
// @ApiMember(Description="Company name.", ParameterType="body")
public var companyName:String
/**
* First name.
*/
// @ApiMember(Description="First name.", ParameterType="body")
public var firstName:String
/**
* Last name.
*/
// @ApiMember(Description="Last name.", ParameterType="body")
public var lastName:String
/**
* Street name.
*/
// @ApiMember(Description="Street name.", IsRequired=true, ParameterType="body")
public var streetName:String
/**
* House number.
*/
// @ApiMember(Description="House number.", IsRequired=true, ParameterType="body")
public var houseNumber:String
/**
* House number addition.
*/
// @ApiMember(Description="House number addition.", ParameterType="body")
public var houseNumberAddition:String
/**
* Postal code.
*/
// @ApiMember(Description="Postal code.", IsRequired=true, ParameterType="body")
public var postalCode:String
/**
* City.
*/
// @ApiMember(Description="City.", IsRequired=true, ParameterType="body")
public var city:String
/**
* Country code.
*/
// @ApiMember(Description="Country code.", IsRequired=true, ParameterType="body")
public var countryCode:String
/**
* Telephone number.
*/
// @ApiMember(Description="Telephone number.", ParameterType="body")
public var telephoneNumber:String
required public init(){}
}
public class NewOrderResponse : OperationResult_1<NewOrderResult>
{
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 OperationResult_1<T : Codable> : OperationResult
{
/**
* Result value
*/
// @ApiMember(Description="Result value", ParameterType="model")
public var result:PartResults
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case result
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
result = try container.decodeIfPresent(PartResults.self, forKey: .result)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if result != nil { try container.encode(result, forKey: .result) }
}
}
public class OperationResult : Codable
{
/**
* Specifies if the operation was successful.
*/
// @ApiMember(Description="Specifies if the operation was successful.", ParameterType="model")
public var isSuccessful:Bool
/**
* States error message in case of unsuccessful operation.
*/
// @ApiMember(Description="States error message in case of unsuccessful operation.", ParameterType="model")
public var errorMessage:String
required public init(){}
}
public class PartResults : Codable
{
/**
* Total number of parts available.
*/
// @ApiMember(Description="Total number of parts available.")
public var totalNumberOfParts:Int
/**
* Indication if there are more parts to retrieve.
*/
// @ApiMember(Description="Indication if there are more parts to retrieve.")
public var hasMoreRecords:Bool
/**
* Part records.
*/
// @ApiMember(Description="Part records.")
public var parts:[PartInfoResult]
required public init(){}
}
public class PartInfoResult : Codable
{
/**
* Unique ID for the part.
*/
// @ApiMember(Description="Unique ID for the part.")
public var id:Int
/**
* Part number.
*/
// @ApiMember(Description="Part number.")
public var partNumber:String
/**
* Description of the part.
*/
// @ApiMember(Description="Description of the part.")
public var Description:String
/**
* Part manufacturer.
*/
// @ApiMember(Description="Part manufacturer.")
public var manufacturer:String
/**
* Determines if the part can be ordered.
*/
// @ApiMember(Description="Determines if the part can be ordered.")
public var canBeOrdered:Bool
/**
* Textual representation of the status of the part.
*/
// @ApiMember(Description="Textual representation of the status of the part.")
public var statusText:String
/**
* Available stock to order.
*/
// @ApiMember(Description="Available stock to order.")
public var availableStockQuantity:Int
/**
* Average days needed for delivery.
*/
// @ApiMember(Description="Average days needed for delivery.")
public var averageDeliveryInDays:Int?
/**
* Price of a single unit, excluding VAT.
*/
// @ApiMember(Description="Price of a single unit, excluding VAT.")
public var unitPrice:Double?
/**
* EAN number.
*/
// @ApiMember(Description="EAN number.")
public var eanNumber:String
/**
* Images
*/
// @ApiMember(Description="Images")
public var images:[PartInfoResultImage]
/**
* Secondary article numbers
*/
// @ApiMember(Description="Secondary article numbers")
public var secondaryArticleNumbers:[String]
/**
* Replacement article numbers
*/
// @ApiMember(Description="Replacement article numbers")
public var replacementArticleNumbers:[String]
/**
* Stock quantities
*/
// @ApiMember(Description="Stock quantities")
public var stockQuantities:[PartStockQuantity]
required public init(){}
}
public class PartInfoResultImage : Codable
{
/**
* Image number
*/
// @ApiMember(Description="Image number")
public var imageNumber:Int
/**
* Image URL
*/
// @ApiMember(Description="Image URL")
public var imageUrl:String
required public init(){}
}
public class PartStockQuantity : Codable
{
/**
* Location ID
*/
// @ApiMember(Description="Location ID")
public var locationId:Int
/**
* Location code
*/
// @ApiMember(Description="Location code")
public var locationCode:String
/**
* Stock quantity in location
*/
// @ApiMember(Description="Stock quantity in location")
public var stockQuantity:Int
required public init(){}
}
public class NewOrderResult : Codable
{
/**
* Number for the order that has been placed.
*/
// @ApiMember(Description="Number for the order that has been placed.", ParameterType="model")
public var orderNumber:String
required public init(){}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /dealers/order HTTP/1.1
Host: services.acct.2service.nl
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"Items":[{"PartId":0,"Quantity":0,"Reference":"String"}],"UseDropshipment":false,"DeliveryAddress":{"CompanyName":"String","FirstName":"String","LastName":"String","StreetName":"String","HouseNumber":"String","HouseNumberAddition":"String","PostalCode":"String","City":"String","CountryCode":"String","TelephoneNumber":"String"},"SessionToken":"String"}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length
{"Result":{"OrderNumber":"String"},"IsSuccessful":false,"ErrorMessage":"String"}