POST, GET | /api/C2BPostContract |
---|
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
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BaseRequest:
# @ApiMember(DataType="string", Description="This is your AIM API Key provided by Tri-Tech", IsRequired=true, Name="ApiKey", ParameterType="header")
api_key: Optional[str] = None
"""
This is your AIM API Key provided by Tri-Tech
"""
# @ApiMember(DataType="string", Name="OAuthToken", ParameterType="header")
o_auth_token: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BaseSecureRequest(BaseRequest):
# @ApiMember(DataType="string", Description="", Name="Token", ParameterType="Header")
token: Optional[str] = None
"""
"""
# @ApiMember(DataType="string", Description="", Name="DeviceId", ParameterType="Header")
device_id: Optional[str] = None
"""
"""
# @ApiMember(DataType="string", Description="", IsRequired=true, Name="AppId", ParameterType="Header")
app_id: Optional[str] = None
"""
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BaseResponseResult:
# @ApiMember(DataType="string", Description="", Name="StatusCode", ParameterType="body")
status_code: Optional[str] = None
"""
"""
# @ApiMember(DataType="string", Description="", Name="Login", ParameterType="body")
login: Optional[str] = None
"""
"""
# @ApiMember(DataType="string", Description="", Name="ErrorCode", ParameterType="body")
error_code: Optional[str] = None
"""
"""
# @ApiMember(DataType="string", Description="", Name="ErrorDisplayText", ParameterType="body")
error_display_text: Optional[str] = None
"""
"""
# @ApiMember(DataType="string", Description="", Name="ErrorMessage", ParameterType="body")
error_message: Optional[str] = None
"""
"""
# @ApiMember(DataType="string", Description="", ExcludeInSchema=true, Name="DomainName", ParameterType="body")
domain_name: Optional[str] = None
"""
"""
# @ApiMember(DataType="string", Description="", ExcludeInSchema=true, Name="IPAddress", ParameterType="body")
ip_address: Optional[str] = None
"""
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BaseResponse:
# @ApiMember(DataType="BaseResponseResult", Description="", Name="Status", ParameterType="body")
status: Optional[BaseResponseResult] = None
"""
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class C2BPostContractResponse(BaseResponse):
payment_required: bool = False
topic: Optional[str] = None
web_ref: Optional[str] = None
base_url: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Rate:
plan_code: Optional[str] = None
level: Optional[int] = None
grade: Optional[str] = None
down_pay: Optional[Decimal] = None
mo_pay: Optional[Decimal] = None
down_maint: Optional[Decimal] = None
mo_maint: Optional[Decimal] = None
rdf_type: Optional[str] = None
contract_default_id: Optional[int] = None
# @ApiMember(DataType="int", Description="The Number of Months covered by the downpayment", Name="Months")
months: Optional[int] = None
"""
The Number of Months covered by the downpayment
"""
down_lease: Optional[Decimal] = None
mo_lease: Optional[Decimal] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Accessory:
desc: Optional[str] = None
price: Decimal = decimal.Decimal(0)
type: Optional[str] = None
cat_num: int = 0
sku: Optional[str] = None
report: Optional[bool] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class FormInput:
# @ApiMember(DataType="string", Description="Field Name of the Input Field", IsRequired=true, Name="Key", ParameterType="query")
key: Optional[str] = None
"""
Field Name of the Input Field
"""
# @ApiMember(DataType="string", Description="Value of the Input Field.", IsRequired=true, Name="Value", ParameterType="query")
value: Optional[str] = None
"""
Value of the Input Field.
"""
# @ApiMember(DataType="boolean", Description="Whether or not the field is encryped with the C2B encryption key.", IsRequired=true, Name="Encrypted", ParameterType="query")
encrypted: bool = False
"""
Whether or not the field is encryped with the C2B encryption key.
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CcInfo:
# @ApiMember(DataType="string", Description="Token returned from processor", IsRequired=true, Name="TokenStr", ParameterType="query")
token_str: Optional[str] = None
"""
Token returned from processor
"""
# @ApiMember(DataType="string", Description="Card Type (VISA, MCARD, AMEX, DSCVR)", IsRequired=true, Name="CardType", ParameterType="query")
card_type: Optional[str] = None
"""
Card Type (VISA, MCARD, AMEX, DSCVR)
"""
# @ApiMember(DataType="string", Description="Last four of the card", IsRequired=true, Name="LastFour", ParameterType="query")
last_four: Optional[str] = None
"""
Last four of the card
"""
# @ApiMember(DataType="string", Description="Expiration Date of the Card. (MM/YY)", Name="Expiration", ParameterType="query")
expiration: Optional[str] = None
"""
Expiration Date of the Card. (MM/YY)
"""
# @ApiMember(DataType="string", Description="Reason the card is on file.", Name="ReasonOnFile", ParameterType="query")
reason_on_file: Optional[str] = None
"""
Reason the card is on file.
"""
# @ApiMember(DataType="integer", Description="ID of the existing Token Record in AIM, if applicable", Format="int64", Name="TokenPk", ParameterType="query")
token_pk: Optional[int] = None
"""
ID of the existing Token Record in AIM, if applicable
"""
# @ApiMember(DataType="boolean", Description="Is this the customer's primary card? Defaults to false.", Name="Primary", ParameterType="query")
primary: Optional[bool] = None
"""
Is this the customer's primary card? Defaults to false.
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomerInfo:
# @ApiMember(DataType="integer", Description="The WebId of the customer. Optional.", Format="int32", IsRequired=true, Name="WebId", ParameterType="query")
web_id: Optional[int] = None
"""
The WebId of the customer. Optional.
"""
# @ApiMember(DataType="string", Description="Name of the customer.", IsRequired=true, Name="Name", ParameterType="query")
name: Optional[str] = None
"""
Name of the customer.
"""
# @ApiMember(DataType="string", Description="Address line 1 of the customer", Name="Addr1", ParameterType="query")
addr1: Optional[str] = None
"""
Address line 1 of the customer
"""
# @ApiMember(DataType="string", Description="Address line 2 of the customer", Name="Addr2", ParameterType="query")
addr2: Optional[str] = None
"""
Address line 2 of the customer
"""
# @ApiMember(DataType="string", Description="City of the customer", Name="City", ParameterType="query")
city: Optional[str] = None
"""
City of the customer
"""
# @ApiMember(DataType="string", Description="State/Province of the customer", Name="St", ParameterType="query")
st: Optional[str] = None
"""
State/Province of the customer
"""
# @ApiMember(DataType="string", Description="Zip code of the customer", Name="Zip", ParameterType="query")
zip: Optional[str] = None
"""
Zip code of the customer
"""
# @ApiMember(DataType="string", Description="Country of the customer", Name="Country", ParameterType="query")
country: Optional[str] = None
"""
Country of the customer
"""
# @ApiMember(DataType="string", Description="Phone number of the customer", Name="Phone", ParameterType="query")
phone: Optional[str] = None
"""
Phone number of the customer
"""
# @ApiMember(DataType="string", Description="Email address of the customer. Required.", IsRequired=true, Name="Email", ParameterType="query")
email: Optional[str] = None
"""
Email address of the customer. Required.
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class C2BPostContractRequest(BaseSecureRequest):
"""
C2BPostContractRequires active-e Contracts Service.
"""
# @ApiMember(DataType="integer", Description="ID of the teacher to associate the contract with.", Format="int64", Name="TeacherId", ParameterType="query")
teacher_id: Optional[int] = None
"""
ID of the teacher to associate the contract with.
"""
# @ApiMember(DataType="string", Description="Used to associate the contract with a school by school name.", Name="SchoolName", ParameterType="query")
school_name: Optional[str] = None
"""
Used to associate the contract with a school by school name.
"""
# @ApiMember(DataType="string", Description="Used to associate the contract with a school by the AIM School ID", Name="AIMSchoolId", ParameterType="query")
aim_school_id: Optional[int] = None
"""
Used to associate the contract with a school by the AIM School ID
"""
# @ApiMember(DataType="string", Description="Used to associate the contract with a location by location code.", Name="Stloc", ParameterType="query")
stloc: Optional[str] = None
"""
Used to associate the contract with a location by location code.
"""
# @ApiMember(DataType="integer", Description="ID of the instrument to associate the contract with.", Format="int64", Name="InstrumentId", ParameterType="query")
instrument_id: Optional[int] = None
"""
ID of the instrument to associate the contract with.
"""
# @ApiMember(DataType="string", Description="", Name="Sku", ParameterType="query")
sku: Optional[str] = None
"""
"""
# @ApiMember(DataType="string", Description="", Name="Desc", ParameterType="query")
desc: Optional[str] = None
"""
"""
# @ApiMember(DataType="integer", Description="The ID from the C2BGradeGeneric object", Format="int64", Name="RateId", ParameterType="query")
rate_id: Optional[int] = None
"""
The ID from the C2BGradeGeneric object
"""
# @ApiMember(DataType="object", Description="", Name="Rate", ParameterType="query")
rate: Optional[Rate] = None
"""
"""
# @ApiMember(DataType="array", Description="", Name="AccessoryIdList", ParameterType="query")
accessory_id_list: Optional[List[int]] = None
"""
"""
# @ApiMember(DataType="array", Description="", Name="AccessoryList", ParameterType="query")
accessory_list: Optional[List[Accessory]] = None
"""
"""
# @ApiMember(DataType="array", Description="", Name="FormInputList", ParameterType="query")
form_input_list: Optional[List[FormInput]] = None
"""
"""
# @ApiMember(DataType="object", Description="", Name="CcInfo", ParameterType="query")
cc_info: Optional[CcInfo] = None
"""
"""
# @ApiMember(DataType="object", Description="", Name="CustomerInfo", ParameterType="query")
customer_info: Optional[CustomerInfo] = None
"""
"""
# @ApiMember(DataType="integer", Description="", Format="int32", Name="CusAcct", ParameterType="query")
cus_acct: Optional[int] = None
"""
"""
# @ApiMember(DataType="int", Description="", Name="Cat", ParameterType="query")
cat: Optional[int] = None
"""
"""
# @ApiMember(DataType="int", Description="", Name="Sub", ParameterType="query")
sub: Optional[int] = None
"""
"""
return_topic: Optional[bool] = None
status_id: Optional[int] = None
card_terminal_id: Optional[str] = None
Python C2BPostContractRequest 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 /api/C2BPostContract HTTP/1.1
Host: active-ewebservice.biz
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<C2BPostContractRequest 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>
<AIMSchoolId>0</AIMSchoolId>
<AccessoryIdList xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:long>0</d2p1:long>
</AccessoryIdList>
<AccessoryList>
<Accessory>
<CatNum>0</CatNum>
<Desc>String</Desc>
<Price>0</Price>
<Report>false</Report>
<Sku>String</Sku>
<Type>String</Type>
</Accessory>
</AccessoryList>
<CardTerminalId>String</CardTerminalId>
<Cat>0</Cat>
<CcInfo>
<CardType>String</CardType>
<Expiration>String</Expiration>
<LastFour>String</LastFour>
<Primary>false</Primary>
<ReasonOnFile>String</ReasonOnFile>
<TokenPk>0</TokenPk>
<TokenStr>String</TokenStr>
</CcInfo>
<CusAcct>0</CusAcct>
<CustomerInfo>
<Addr1>String</Addr1>
<Addr2>String</Addr2>
<City>String</City>
<Country>String</Country>
<Email>String</Email>
<Name>String</Name>
<Phone>String</Phone>
<St>String</St>
<WebId>0</WebId>
<Zip>String</Zip>
</CustomerInfo>
<Desc>String</Desc>
<FormInputList>
<FormInput>
<Encrypted>false</Encrypted>
<Key>String</Key>
<Value>String</Value>
</FormInput>
</FormInputList>
<InstrumentId>0</InstrumentId>
<Rate>
<ContractDefaultId>0</ContractDefaultId>
<DownLease>0</DownLease>
<DownMaint>0</DownMaint>
<DownPay>0</DownPay>
<Grade>String</Grade>
<Level>0</Level>
<MoLease>0</MoLease>
<MoMaint>0</MoMaint>
<MoPay>0</MoPay>
<Months>0</Months>
<PlanCode>String</PlanCode>
<RdfType>String</RdfType>
</Rate>
<RateId>0</RateId>
<ReturnTopic>false</ReturnTopic>
<SchoolName>String</SchoolName>
<Sku>String</Sku>
<StatusId>0</StatusId>
<Stloc>String</Stloc>
<Sub>0</Sub>
<TeacherId>0</TeacherId>
</C2BPostContractRequest>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <C2BPostContractResponse 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> <BaseUrl>String</BaseUrl> <PaymentRequired>false</PaymentRequired> <Topic>String</Topic> <WebRef>String</WebRef> </C2BPostContractResponse>