POST | /api/AddCustomer |
---|
import Foundation
import ServiceStack
/**
* AddCustomerRequires active-e Customer Service.
*/
// @DataContract
public class AddCustomerRequest : BaseSecureRequest
{
/**
* Location ID
*/
// @DataMember
// @ApiMember(DataType="integer", Description="Location ID", Format="int64", IsRequired=true, Name="LocationId", ParameterType="query")
public var locationId:Int?
/**
* Customer Default Id
*/
// @DataMember
// @ApiMember(DataType="integer", Description="Customer Default Id", Format="int64", IsRequired=true, Name="CustomerDefaultId", ParameterType="query")
public var customerDefaultId:Int?
/**
* Tax Authority Id
*/
// @DataMember
// @ApiMember(DataType="integer", Description="Tax Authority Id", Format="int64", IsRequired=true, Name="TaxAuthorityId", ParameterType="query")
public var taxAuthorityId:Int?
// @DataMember
public var name:String
// @DataMember
public var attn:String
// @DataMember
public var address1:String
// @DataMember
public var address2:String
// @DataMember
public var city:String
// @DataMember
public var state:String
// @DataMember
public var zip:String
// @DataMember
public var country:String
// @DataMember
public var homePhone:String
// @DataMember
public var workPhone:String
// @DataMember
public var cellPhone:String
// @DataMember
public var employer:String
// @DataMember
public var ss:String
// @DataMember
public var email:String
/**
* Email Method. Set this to Word, PDF, HTML, or None
*/
// @DataMember
// @ApiMember(DataType="string", Description="Email Method. Set this to Word, PDF, HTML, or None", Name="EmailMethod", ParameterType="query")
public var emailMethod:String
// @DataMember
public var notes:String
// @DataMember
public var driversLicenseInfo:LicenseInfo
/**
*
*/
// @DataMember
// @ApiMember(DataType="array", Description="", Name="FormInputList", ParameterType="query")
public var formInputList:[FormInput] = []
/**
* Can be SKIP, CHECK, or CHECKONLY. Defaults to SKIP. SKIP will not do a duplicate check. CHECK will do a duplicate check and the customer will not added if duplicates are found. CHECKONLY will just do a duplicate check; the customer will not be added. Duplicate check logic is based on the AIM system variable CustDupCheck.
*/
// @DataMember
// @ApiMember(Description="Can be SKIP, CHECK, or CHECKONLY. Defaults to SKIP. SKIP will not do a duplicate check. CHECK will do a duplicate check and the customer will not added if duplicates are found. CHECKONLY will just do a duplicate check; the customer will not be added. Duplicate check logic is based on the AIM system variable CustDupCheck.", Name="DuplicateCheckMode")
public var duplicateCheckMode:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case locationId
case customerDefaultId
case taxAuthorityId
case name
case attn
case address1
case address2
case city
case state
case zip
case country
case homePhone
case workPhone
case cellPhone
case employer
case ss
case email
case emailMethod
case notes
case driversLicenseInfo
case formInputList
case duplicateCheckMode
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
locationId = try container.decodeIfPresent(Int.self, forKey: .locationId)
customerDefaultId = try container.decodeIfPresent(Int.self, forKey: .customerDefaultId)
taxAuthorityId = try container.decodeIfPresent(Int.self, forKey: .taxAuthorityId)
name = try container.decodeIfPresent(String.self, forKey: .name)
attn = try container.decodeIfPresent(String.self, forKey: .attn)
address1 = try container.decodeIfPresent(String.self, forKey: .address1)
address2 = try container.decodeIfPresent(String.self, forKey: .address2)
city = try container.decodeIfPresent(String.self, forKey: .city)
state = try container.decodeIfPresent(String.self, forKey: .state)
zip = try container.decodeIfPresent(String.self, forKey: .zip)
country = try container.decodeIfPresent(String.self, forKey: .country)
homePhone = try container.decodeIfPresent(String.self, forKey: .homePhone)
workPhone = try container.decodeIfPresent(String.self, forKey: .workPhone)
cellPhone = try container.decodeIfPresent(String.self, forKey: .cellPhone)
employer = try container.decodeIfPresent(String.self, forKey: .employer)
ss = try container.decodeIfPresent(String.self, forKey: .ss)
email = try container.decodeIfPresent(String.self, forKey: .email)
emailMethod = try container.decodeIfPresent(String.self, forKey: .emailMethod)
notes = try container.decodeIfPresent(String.self, forKey: .notes)
driversLicenseInfo = try container.decodeIfPresent(LicenseInfo.self, forKey: .driversLicenseInfo)
formInputList = try container.decodeIfPresent([FormInput].self, forKey: .formInputList) ?? []
duplicateCheckMode = try container.decodeIfPresent(String.self, forKey: .duplicateCheckMode)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if locationId != nil { try container.encode(locationId, forKey: .locationId) }
if customerDefaultId != nil { try container.encode(customerDefaultId, forKey: .customerDefaultId) }
if taxAuthorityId != nil { try container.encode(taxAuthorityId, forKey: .taxAuthorityId) }
if name != nil { try container.encode(name, forKey: .name) }
if attn != nil { try container.encode(attn, forKey: .attn) }
if address1 != nil { try container.encode(address1, forKey: .address1) }
if address2 != nil { try container.encode(address2, forKey: .address2) }
if city != nil { try container.encode(city, forKey: .city) }
if state != nil { try container.encode(state, forKey: .state) }
if zip != nil { try container.encode(zip, forKey: .zip) }
if country != nil { try container.encode(country, forKey: .country) }
if homePhone != nil { try container.encode(homePhone, forKey: .homePhone) }
if workPhone != nil { try container.encode(workPhone, forKey: .workPhone) }
if cellPhone != nil { try container.encode(cellPhone, forKey: .cellPhone) }
if employer != nil { try container.encode(employer, forKey: .employer) }
if ss != nil { try container.encode(ss, forKey: .ss) }
if email != nil { try container.encode(email, forKey: .email) }
if emailMethod != nil { try container.encode(emailMethod, forKey: .emailMethod) }
if notes != nil { try container.encode(notes, forKey: .notes) }
if driversLicenseInfo != nil { try container.encode(driversLicenseInfo, forKey: .driversLicenseInfo) }
if formInputList.count > 0 { try container.encode(formInputList, forKey: .formInputList) }
if duplicateCheckMode != nil { try container.encode(duplicateCheckMode, forKey: .duplicateCheckMode) }
}
}
// @DataContract
public class BaseSecureRequest : BaseRequest
{
/**
*
*/
// @DataMember
// @ApiMember(DataType="string", Description="", Name="Token", ParameterType="Header")
public var token:String
/**
*
*/
// @DataMember
// @ApiMember(DataType="string", Description="", Name="DeviceId", ParameterType="Header")
public var deviceId:String
/**
*
*/
// @DataMember
// @ApiMember(DataType="string", Description="", IsRequired=true, Name="AppId", ParameterType="Header")
public var appId:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case token
case deviceId
case appId
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
token = try container.decodeIfPresent(String.self, forKey: .token)
deviceId = try container.decodeIfPresent(String.self, forKey: .deviceId)
appId = try container.decodeIfPresent(String.self, forKey: .appId)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if token != nil { try container.encode(token, forKey: .token) }
if deviceId != nil { try container.encode(deviceId, forKey: .deviceId) }
if appId != nil { try container.encode(appId, forKey: .appId) }
}
}
// @DataContract
public class BaseRequest : Codable
{
/**
* This is your AIM API Key provided by Tri-Tech
*/
// @DataMember
// @ApiMember(DataType="string", Description="This is your AIM API Key provided by Tri-Tech", IsRequired=true, Name="ApiKey", ParameterType="header")
public var apiKey:String
// @DataMember
// @ApiMember(DataType="string", Name="OAuthToken", ParameterType="header")
public var oAuthToken:String
required public init(){}
}
// @DataContract
public class LicenseInfo : Codable
{
// @DataMember
public var number:String
// @DataMember
public var height:String
// @DataMember
public var weight:String
// @DataMember
public var hair:String
// @DataMember
public var eyes:String
// @DataMember
public var expiration:String
// @DataMember
public var birthday:String
// @DataMember
public var ethnicity:String
// @DataMember
public var gender:String
// @DataMember
public var state:String
required public init(){}
}
// @DataContract(Name="FormInput")
public class FormInput : Codable
{
/**
* Field Name of the Input Field
*/
// @DataMember
// @ApiMember(DataType="string", Description="Field Name of the Input Field", IsRequired=true, Name="Key", ParameterType="query")
public var key:String
/**
* Value of the Input Field.
*/
// @DataMember
// @ApiMember(DataType="string", Description="Value of the Input Field.", IsRequired=true, Name="Value", ParameterType="query")
public var value:String
/**
* Whether or not the field is encryped with the C2B encryption key.
*/
// @DataMember
// @ApiMember(DataType="boolean", Description="Whether or not the field is encryped with the C2B encryption key.", IsRequired=true, Name="Encrypted", ParameterType="query")
public var encrypted:Bool
required public init(){}
}
// @DataContract
public class AddCustomerResponse : BaseResponse
{
// @DataMember
public var id:Int?
/**
* Only returned if PerformDuplicateCheck parameter was passed in and possible duplicates were found. If this is returned, the customer record was *not* created.
*/
// @DataMember
// @ApiMember(DataType="string", Description="Only returned if PerformDuplicateCheck parameter was passed in and possible duplicates were found. If this is returned, the customer record was *not* created.", Name="PossibleDuplicates")
public var possibleDuplicates:[CustomerSearchRecord] = []
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case id
case possibleDuplicates
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decodeIfPresent(Int.self, forKey: .id)
possibleDuplicates = try container.decodeIfPresent([CustomerSearchRecord].self, forKey: .possibleDuplicates) ?? []
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if id != nil { try container.encode(id, forKey: .id) }
if possibleDuplicates.count > 0 { try container.encode(possibleDuplicates, forKey: .possibleDuplicates) }
}
}
// @DataContract
public class BaseResponse : Codable
{
/**
*
*/
// @DataMember
// @ApiMember(DataType="BaseResponseResult", Description="", Name="Status", ParameterType="body")
public var status:BaseResponseResult
required public init(){}
}
// @DataContract
public class BaseResponseResult : Codable
{
/**
*
*/
// @DataMember
// @ApiMember(DataType="string", Description="", Name="StatusCode", ParameterType="body")
public var statusCode:String
/**
*
*/
// @DataMember
// @ApiMember(DataType="string", Description="", Name="Login", ParameterType="body")
public var login:String
/**
*
*/
// @DataMember
// @ApiMember(DataType="string", Description="", Name="ErrorCode", ParameterType="body")
public var errorCode:String
/**
*
*/
// @DataMember
// @ApiMember(DataType="string", Description="", Name="ErrorDisplayText", ParameterType="body")
public var errorDisplayText:String
/**
*
*/
// @DataMember
// @ApiMember(DataType="string", Description="", Name="ErrorMessage", ParameterType="body")
public var errorMessage:String
/**
*
*/
// @DataMember
// @ApiMember(DataType="string", Description="", ExcludeInSchema=true, Name="DomainName", ParameterType="body")
public var domainName:String
/**
*
*/
// @DataMember
// @ApiMember(DataType="string", Description="", ExcludeInSchema=true, Name="IPAddress", ParameterType="body")
public var ipAddress:String
required public init(){}
}
// @DataContract
public class CustomerSearchRecord : BindableObject
{
// @DataMember
public var pk:Int
// @DataMember
public var acct:Int
// @DataMember
public var last:String
// @DataMember
public var name:String
// @DataMember
public var addr1:String
// @DataMember
public var addr2:String
// @DataMember
public var city:String
// @DataMember
public var st:String
// @DataMember
public var zip:String
// @DataMember
public var phone:String
// @DataMember
public var email:String
// @DataMember
public var openInvoices:Bool
// @DataMember
public var rentalActivity:Bool
// @DataMember
public var stLoc:String
// @DataMember
public var hold:Bool
// @DataMember
public var barcode:String
// @DataMember
public var color:Int
// @DataMember
public var dependantInfo:[DependantRecord] = []
// @DataMember
public var additionalDetails:AdditionalDetail
// @DataMember
public var matchedOn:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case pk
case acct
case last
case name
case addr1
case addr2
case city
case st
case zip
case phone
case email
case openInvoices
case rentalActivity
case stLoc
case hold
case barcode
case color
case dependantInfo
case additionalDetails
case matchedOn
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
pk = try container.decodeIfPresent(Int.self, forKey: .pk)
acct = try container.decodeIfPresent(Int.self, forKey: .acct)
last = try container.decodeIfPresent(String.self, forKey: .last)
name = try container.decodeIfPresent(String.self, forKey: .name)
addr1 = try container.decodeIfPresent(String.self, forKey: .addr1)
addr2 = try container.decodeIfPresent(String.self, forKey: .addr2)
city = try container.decodeIfPresent(String.self, forKey: .city)
st = try container.decodeIfPresent(String.self, forKey: .st)
zip = try container.decodeIfPresent(String.self, forKey: .zip)
phone = try container.decodeIfPresent(String.self, forKey: .phone)
email = try container.decodeIfPresent(String.self, forKey: .email)
openInvoices = try container.decodeIfPresent(Bool.self, forKey: .openInvoices)
rentalActivity = try container.decodeIfPresent(Bool.self, forKey: .rentalActivity)
stLoc = try container.decodeIfPresent(String.self, forKey: .stLoc)
hold = try container.decodeIfPresent(Bool.self, forKey: .hold)
barcode = try container.decodeIfPresent(String.self, forKey: .barcode)
color = try container.decodeIfPresent(Int.self, forKey: .color)
dependantInfo = try container.decodeIfPresent([DependantRecord].self, forKey: .dependantInfo) ?? []
additionalDetails = try container.decodeIfPresent(AdditionalDetail.self, forKey: .additionalDetails)
matchedOn = try container.decodeIfPresent(String.self, forKey: .matchedOn)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if pk != nil { try container.encode(pk, forKey: .pk) }
if acct != nil { try container.encode(acct, forKey: .acct) }
if last != nil { try container.encode(last, forKey: .last) }
if name != nil { try container.encode(name, forKey: .name) }
if addr1 != nil { try container.encode(addr1, forKey: .addr1) }
if addr2 != nil { try container.encode(addr2, forKey: .addr2) }
if city != nil { try container.encode(city, forKey: .city) }
if st != nil { try container.encode(st, forKey: .st) }
if zip != nil { try container.encode(zip, forKey: .zip) }
if phone != nil { try container.encode(phone, forKey: .phone) }
if email != nil { try container.encode(email, forKey: .email) }
if openInvoices != nil { try container.encode(openInvoices, forKey: .openInvoices) }
if rentalActivity != nil { try container.encode(rentalActivity, forKey: .rentalActivity) }
if stLoc != nil { try container.encode(stLoc, forKey: .stLoc) }
if hold != nil { try container.encode(hold, forKey: .hold) }
if barcode != nil { try container.encode(barcode, forKey: .barcode) }
if color != nil { try container.encode(color, forKey: .color) }
if dependantInfo.count > 0 { try container.encode(dependantInfo, forKey: .dependantInfo) }
if additionalDetails != nil { try container.encode(additionalDetails, forKey: .additionalDetails) }
if matchedOn != nil { try container.encode(matchedOn, forKey: .matchedOn) }
}
}
// @DataContract
public class BindableObject : Codable
{
required public init(){}
}
// @DataContract
public class DependantRecord : Codable
{
// @DataMember
public var name:String
// @DataMember
public var onlineId:String
// @DataMember
public var schoolDistrict:String
// @DataMember
public var school:String
// @DataMember
public var id:Int
required public init(){}
}
// @DataContract
public class AdditionalDetail : Codable
{
// @DataMember
public var creationDate:Date
// @DataMember
public var lastModifiedDate:Date
// @DataMember
public var notes:String
// @DataMember
public var customerDefault:CustomerDefaultInfo
// @DataMember
public var taxAuthority:TaxAuthorityInfo
// @DataMember
public var canCharge:Bool
// @DataMember
public var popupNotes:String
// @DataMember
public var dlNumber:String
// @DataMember
public var phone2:String
// @DataMember
public var phone3:String
// @DataMember
public var phone4:String
// @DataMember
public var location:LocationInfo
required public init(){}
}
// @DataContract
public class CustomerDefaultInfo : Codable
{
// @DataMember
public var id:Int
// @DataMember
public var desc:String
// @DataMember
public var shortDesc:String
required public init(){}
}
// @DataContract
public class TaxAuthorityInfo : Codable
{
// @DataMember
public var id:Int
// @DataMember
public var desc:String
// @DataMember
public var shortDesc:String
required public init(){}
}
// @DataContract
public class LocationInfo : Codable
{
// @DataMember
public var id:Int
// @DataMember
public var desc:String
// @DataMember
public var shortDesc:String
// @DataMember
public var region:String
// @DataMember
public var latitude:Double
// @DataMember
public var longitude:Double
// @DataMember
public var inStorePickup:String
// @DataMember
public var active:Bool
// @DataMember
public var cashSaleAcct:Int?
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 /api/AddCustomer HTTP/1.1
Host: active-ewebservice.biz
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<AddCustomerRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/AIM.WebService">
<ApiKey>String</ApiKey>
<OAuthToken>String</OAuthToken>
<AppId>String</AppId>
<DeviceId>String</DeviceId>
<Token>String</Token>
<Address1>String</Address1>
<Address2>String</Address2>
<Attn>String</Attn>
<CellPhone>String</CellPhone>
<City>String</City>
<Country>String</Country>
<CustomerDefaultId>0</CustomerDefaultId>
<DriversLicenseInfo>
<Birthday>String</Birthday>
<Ethnicity>String</Ethnicity>
<Expiration>String</Expiration>
<Eyes>String</Eyes>
<Gender>String</Gender>
<Hair>String</Hair>
<Height>String</Height>
<Number>String</Number>
<State>String</State>
<Weight>String</Weight>
</DriversLicenseInfo>
<DuplicateCheckMode>String</DuplicateCheckMode>
<Email>String</Email>
<EmailMethod>String</EmailMethod>
<Employer>String</Employer>
<FormInputList>
<FormInput>
<Encrypted>false</Encrypted>
<Key>String</Key>
<Value>String</Value>
</FormInput>
</FormInputList>
<HomePhone>String</HomePhone>
<LocationId>0</LocationId>
<Name>String</Name>
<Notes>String</Notes>
<SS>String</SS>
<State>String</State>
<TaxAuthorityId>0</TaxAuthorityId>
<WorkPhone>String</WorkPhone>
<Zip>String</Zip>
</AddCustomerRequest>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <AddCustomerResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/AIM.WebService"> <Status> <DomainName>String</DomainName> <ErrorCode>String</ErrorCode> <ErrorDisplayText>String</ErrorDisplayText> <ErrorMessage>String</ErrorMessage> <IpAddress>String</IpAddress> <Login>String</Login> <StatusCode>String</StatusCode> </Status> <Id>0</Id> <PossibleDuplicates xmlns:d2p1="http://schemas.datacontract.org/2004/07/AIM"> <d2p1:CustomerSearchRecord> <d2p1:Acct>0</d2p1:Acct> <d2p1:AdditionalDetails> <d2p1:CanCharge>false</d2p1:CanCharge> <d2p1:CreationDate>0001-01-01T00:00:00</d2p1:CreationDate> <d2p1:CustomerDefault> <d2p1:Desc>String</d2p1:Desc> <d2p1:Id>0</d2p1:Id> <d2p1:ShortDesc>String</d2p1:ShortDesc> </d2p1:CustomerDefault> <d2p1:DlNumber>String</d2p1:DlNumber> <d2p1:LastModifiedDate>0001-01-01T00:00:00</d2p1:LastModifiedDate> <d2p1:Location> <d2p1:Active>false</d2p1:Active> <d2p1:CashSaleAcct>0</d2p1:CashSaleAcct> <d2p1:Desc>String</d2p1:Desc> <d2p1:Id>0</d2p1:Id> <d2p1:InStorePickup>String</d2p1:InStorePickup> <d2p1:Latitude>0</d2p1:Latitude> <d2p1:Longitude>0</d2p1:Longitude> <d2p1:Region>String</d2p1:Region> <d2p1:ShortDesc>String</d2p1:ShortDesc> </d2p1:Location> <d2p1:Notes>String</d2p1:Notes> <d2p1:Phone2>String</d2p1:Phone2> <d2p1:Phone3>String</d2p1:Phone3> <d2p1:Phone4>String</d2p1:Phone4> <d2p1:PopupNotes>String</d2p1:PopupNotes> <d2p1:TaxAuthority> <d2p1:Desc>String</d2p1:Desc> <d2p1:Id>0</d2p1:Id> <d2p1:ShortDesc>String</d2p1:ShortDesc> </d2p1:TaxAuthority> </d2p1:AdditionalDetails> <d2p1:Addr1>String</d2p1:Addr1> <d2p1:Addr2>String</d2p1:Addr2> <d2p1:Barcode>String</d2p1:Barcode> <d2p1:City>String</d2p1:City> <d2p1:Color>0</d2p1:Color> <d2p1:DependantInfo> <d2p1:CustomerSearchRecord.DependantRecord> <d2p1:Id>0</d2p1:Id> <d2p1:Name>String</d2p1:Name> <d2p1:OnlineId>String</d2p1:OnlineId> <d2p1:School>String</d2p1:School> <d2p1:SchoolDistrict>String</d2p1:SchoolDistrict> </d2p1:CustomerSearchRecord.DependantRecord> </d2p1:DependantInfo> <d2p1:Email>String</d2p1:Email> <d2p1:Hold>false</d2p1:Hold> <d2p1:Last>String</d2p1:Last> <d2p1:MatchedOn>String</d2p1:MatchedOn> <d2p1:Name>String</d2p1:Name> <d2p1:OpenInvoices>false</d2p1:OpenInvoices> <d2p1:Phone>String</d2p1:Phone> <d2p1:Pk>0</d2p1:Pk> <d2p1:RentalActivity>false</d2p1:RentalActivity> <d2p1:St>String</d2p1:St> <d2p1:StLoc>String</d2p1:StLoc> <d2p1:Zip>String</d2p1:Zip> </d2p1:CustomerSearchRecord> </PossibleDuplicates> </AddCustomerResponse>