POST | /v1/order | Creates an order for a selected vehicle via the Agency API | This endpoint is called from Online Showroom to create a vehicle order. It builds the order request object for the Agency API before calling it to create the order. The information it retrieves and builds for the Agency API request include 1.) The customer. 2.) The vehicle. 3.) Ourright purchase. 4.) Motability. 5.) Offers applicable to the vehicle Validation is performed on the input data which includes checking for mandatory items: 1.} Customer details 2.) Vehicle Vin 3.) Agent 4.) GSSN Outlet Id 5.) Source 6.) Order Type 7.) Customer Location Id 8.) Estimated Handover Date |
---|
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum
class Source(IntEnum):
ONLINE_SHOWROOM = 1
ONE_ADMIN = 2
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Address:
property: Optional[str] = None
street: Optional[str] = None
town: Optional[str] = None
county: Optional[str] = None
locality: Optional[str] = None
postcode: Optional[str] = None
class CustomerMode(IntEnum):
PRIVATE = 1
BUSINESS = 2
MOTABILITY = 3
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class SalesforceCustomer(ICustomer):
customer_id: Optional[str] = None
is_ciam: bool = False
company_name: Optional[str] = None
title: Optional[str] = None
firstname: Optional[str] = None
surname: Optional[str] = None
email_address: Optional[str] = None
telephone: Optional[str] = None
address: Optional[Address] = None
mode: Optional[CustomerMode] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Preferences:
optin_email: bool = False
optin_post: bool = False
optin_s_m_s: bool = False
optin_telephone: bool = False
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Customer(SalesforceCustomer):
profile_id: Optional[str] = None
preferences: Optional[Preferences] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Vehicle:
vin: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Option:
is_default: bool = False
value: int = 0
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Term:
options: List[Option] = field(default_factory=list)
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Deposit:
default: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Mileage:
options: List[Option] = field(default_factory=list)
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AdvanceRentals:
options: List[Option] = field(default_factory=list)
class VehicleType(str, Enum):
UNASSIGNED = 'UNASSIGNED'
NEW = 'NEW'
USED = 'USED'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class FinanceCriteria:
key: Optional[str] = None
name: Optional[str] = None
type: Optional[str] = None
is_default: bool = False
term: Optional[Term] = None
deposit: Optional[Deposit] = None
mileage: Optional[Mileage] = None
advance_rentals: Optional[AdvanceRentals] = None
is_personalised: bool = False
regular_payment: Optional[str] = None
part_exchange: Optional[str] = None
settlement: Optional[str] = None
customer_type: Optional[str] = None
vehicle_type: Optional[VehicleType] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class OutrightPurchase:
is_outright_purchase: bool = False
reference: Optional[str] = None
discount_rate: Decimal = decimal.Decimal(0)
bm7_n_s_t: Optional[str] = None
is_back_order: bool = False
is_c_o_p_converter: bool = False
class MotabilityType(IntEnum):
PIP = 1
WPMS = 2
UNASSIGNED = 3
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreateOrderBase:
source: Optional[Source] = None
gssn_id: Optional[str] = None
additional_information: Optional[str] = None
cash: bool = False
finance: bool = False
customer: Optional[Customer] = None
vehicle: Optional[Vehicle] = None
finance_criteria: Optional[FinanceCriteria] = None
back_order_guid: Optional[str] = None
tag_url: Optional[str] = None
outright_purchase: Optional[OutrightPurchase] = None
motability: bool = False
motability_pricing_id: Optional[int] = None
finance_application_reference: Optional[str] = None
specialist: bool = False
gas_id: Optional[str] = None
personalised_item_offer_ids: Optional[List[int]] = None
suggested_vin: Optional[str] = None
non_optimum_reason: Optional[str] = None
motability_type: Optional[MotabilityType] = None
estimated_handover_date: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreateOrderResponse:
guid: Optional[str] = None
reference: Optional[str] = None
response_status: Optional[ResponseStatus] = None
back_order_reference: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreateOrderRequest(CreateOrderBase, IGet):
pass
Python CreateOrderRequest DTOs
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 /v1/order HTTP/1.1
Host: prod-api-agency-orch-mb-dhc.rapp-customers.co.uk
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"Source":"OnlineShowroom","GssnId":"String","AdditionalInformation":"String","Cash":false,"Finance":false,"Customer":{"ProfileId":"00000000000000000000000000000000","Preferences":{"OptinEmail":false,"OptinPost":false,"OptinSMS":false,"OptinTelephone":false},"CustomerId":"String","IsCiam":false,"CompanyName":"String","Title":"String","Firstname":"String","Surname":"String","EmailAddress":"String","Telephone":"String","Address":{"Property":"String","Street":"String","Town":"String","County":"String","Locality":"String","Postcode":"String"},"Mode":"Private"},"Vehicle":{"Vin":"String"},"FinanceCriteria":{"Key":"String","Name":"String","Type":"String","IsDefault":false,"Term":{"Options":[{"IsDefault":false,"Value":0}]},"Deposit":{"Default":"String"},"Mileage":{"Options":[{"IsDefault":false,"Value":0}]},"AdvanceRentals":{"Options":[{"IsDefault":false,"Value":0}]},"IsPersonalised":false,"RegularPayment":"String","PartExchange":"String","Settlement":"String","CustomerType":"String","VehicleType":"UNASSIGNED"},"BackOrderGuid":"00000000000000000000000000000000","TagUrl":"String","OutrightPurchase":{"IsOutrightPurchase":false,"Reference":"String","DiscountRate":0,"Bm7NST":"String","IsBackOrder":false,"IsCOPConverter":false},"Motability":false,"MotabilityPricingId":0,"FinanceApplicationReference":"String","Specialist":false,"GasId":"String","PersonalisedItemOfferIds":[0],"SuggestedVin":"String","NonOptimumReason":"String","MotabilityType":"PIP","EstimatedHandoverDate":"String"}
HTTP/1.1 200 OK Content-Type: text/csv Content-Length: length {"Guid":"String","Reference":"String","ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}},"BackOrderReference":"String"}