| POST | /v1/configurator | Validate and save a car configurator code for a back order | This endpoint calls Agency API to validate and save a car configurator code for a back order. The code is validated and saved in the database and returns a response from a third party CCS which provides car configuration details. These get saved to open search and returned to the front-end |
|---|
# frozen_string_literal: true
# encoding: utf-8
require 'json'
require 'servicestack'
class KeyInformation
include ServiceStack::DTO
# @return [String]
attr_accessor :b_m7_n_s_t
# @return [String]
attr_accessor :configuration_date
# @return [String]
attr_accessor :model_year
# @return [String]
attr_accessor :half_year
# @return [String]
attr_accessor :type_class
# @return [TrueClass]
attr_accessor :is_private_van
def self.properties
{
b_m7_n_s_t: { name: 'bM7NST' },
configuration_date: { name: 'configurationDate' },
model_year: { name: 'modelYear' },
half_year: { name: 'halfYear' },
type_class: { name: 'typeClass' },
is_private_van: { name: 'isPrivateVan' },
}
end
end
class EquipmentCache
include ServiceStack::DTO
# @return [String]
attr_accessor :code
# @return [String]
attr_accessor :description
# @return [String]
attr_accessor :standard_flag
# @return [BigDecimal]
attr_accessor :price
# @return [String]
attr_accessor :category
# @return [String]
attr_accessor :importance
def self.properties
{
code: { name: 'code' },
description: { name: 'description' },
standard_flag: { name: 'standardFlag' },
price: { name: 'price' },
category: { name: 'category' },
importance: { name: 'importance' },
}
end
end
class OrderingOptions
include ServiceStack::DTO
# @return [List]
attr_accessor :interior
# @return [List]
attr_accessor :exterior
# @return [List]
attr_accessor :options
# @return [List]
attr_accessor :wheel_options
# @return [List]
attr_accessor :trim_options
# @return [List]
attr_accessor :equipment_option_codes
# @return [List]
attr_accessor :option_codes
def self.properties
{
interior: { name: 'interior' },
exterior: { name: 'exterior' },
options: { name: 'options' },
wheel_options: { name: 'wheelOptions', type: [EquipmentCache] },
trim_options: { name: 'trimOptions', type: [EquipmentCache] },
equipment_option_codes: { name: 'equipmentOptionCodes', type: [EquipmentCache] },
option_codes: { name: 'optionCodes', type: [EquipmentCache] },
}
end
end
class ResponseStatus
include ServiceStack::DTO
# @return [String]
attr_accessor :error_code
# @return [String]
attr_accessor :message
def self.properties
{
error_code: { name: 'errorCode' },
message: { name: 'message' },
}
end
end
class CarConfiguratorResponse
include ServiceStack::DTO
# @return [String]
attr_accessor :name
# @return [KeyInformation]
attr_accessor :key_information
# @return [OrderingOptions]
attr_accessor :ordering_options
# @return [ResponseStatus]
attr_accessor :response_status
# @return [String]
attr_accessor :configurator_code
def self.properties
{
name: { name: 'name' },
key_information: { name: 'keyInformation', type: KeyInformation },
ordering_options: { name: 'orderingOptions', type: OrderingOptions },
response_status: { name: 'responseStatus', type: ResponseStatus },
configurator_code: { name: 'configuratorCode' },
}
end
end
class CarConfiguratorRequest
include ServiceStack::DTO
# @ApiMember(Description: "Configurator code", IsRequired: "true")
# @return [String]
attr_accessor :configurator_code
def self.properties
{
configurator_code: { name: 'configuratorCode' },
}
end
def response_type() = CarConfiguratorResponse
def get_type_name() = 'CarConfiguratorRequest'
end
Ruby CarConfiguratorRequest 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/configurator HTTP/1.1
Host: prod-api-agency-orch-mb-dhc.rapp-customers.co.uk
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"ConfiguratorCode":"String"}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length
{"Name":"String","KeyInformation":{"BM7NST":"String","ConfigurationDate":"String","ModelYear":"String","HalfYear":"String","TypeClass":"String","IsPrivateVan":false},"OrderingOptions":{"Interior":["String"],"Exterior":["String"],"Options":["String"],"WheelOptions":[{"Code":"String","Description":"String","StandardFlag":"String","Price":0,"Category":"String","Importance":"String"}],"TrimOptions":[{"Code":"String","Description":"String","StandardFlag":"String","Price":0,"Category":"String","Importance":"String"}],"EquipmentOptionCodes":[{"Code":"String","Description":"String","StandardFlag":"String","Price":0,"Category":"String","Importance":"String"}],"OptionCodes":[{"Code":"String","Description":"String","StandardFlag":"String","Price":0,"Category":"String","Importance":"String"}]},"ResponseStatus":{"ErrorCode":"String","Message":"String"},"ConfiguratorCode":"String"}