| POST | /consumerinitiation |
|---|
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 ValidateError:
error_number: Optional[str] = None
error_description: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ConsumerInitiationResponse:
# @ApiMember(Description="Response message")
message: Optional[str] = None
"""
Response message
"""
# @ApiMember(Description="File identifier for the created initiation")
file_id: Optional[str] = None
"""
File identifier for the created initiation
"""
# @ApiMember(Description="List of validation errors, if any")
errors: Optional[List[ValidateError]] = None
"""
List of validation errors, if any
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class RelocationsRequestFileTransfereeDetails:
# @ApiMember(Description="First name of the transferee", IsRequired=true)
first_name: Optional[str] = None
"""
First name of the transferee
"""
# @ApiMember(Description="Last name of the transferee", IsRequired=true)
last_name: Optional[str] = None
"""
Last name of the transferee
"""
# @ApiMember(Description="Preferred email address", IsRequired=true)
preferred_email: Optional[str] = None
"""
Preferred email address
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AssignmentLocationDetails:
# @ApiMember(Description="Work city", IsRequired=true)
work_city: Optional[str] = None
"""
Work city
"""
# @ApiMember(Description="Current work location state")
current_work_state: Optional[str] = None
"""
Current work location state
"""
# @ApiMember(Description="Work state or province")
work_state: Optional[str] = None
"""
Work state or province
"""
# @ApiMember(Description="Destination work location state")
destination_work_state: Optional[str] = None
"""
Destination work location state
"""
# @ApiMember(Description="Work country", IsRequired=true)
work_country: Optional[str] = None
"""
Work country
"""
# @ApiMember(Description="Preferred work location state")
preferred_work_state: Optional[str] = None
"""
Preferred work location state
"""
# @ApiMember(Description="Preferred work location country")
preferred_work_country: Optional[str] = None
"""
Preferred work location country
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class RelocationsRequestFileAssignmentDetails:
# @ApiMember(Description="Program name or code", IsRequired=true)
program: Optional[str] = None
"""
Program name or code
"""
# @ApiMember(Description="Type of assignment", IsRequired=true)
assignment_type: Optional[str] = None
"""
Type of assignment
"""
# @ApiMember(Description="Assignment start date", IsRequired=true)
start_date: Optional[datetime.datetime] = None
"""
Assignment start date
"""
# @ApiMember(Description="Company name", IsRequired=true)
company_name: Optional[str] = None
"""
Company name
"""
# @ApiMember(Description="Contact", IsRequired=true)
contact: Optional[str] = None
"""
Contact
"""
# @ApiMember(Description="Current assignment location details", IsRequired=true)
current: Optional[AssignmentLocationDetails] = None
"""
Current assignment location details
"""
# @ApiMember(Description="Destination assignment location details", IsRequired=true)
destination: Optional[AssignmentLocationDetails] = None
"""
Destination assignment location details
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class RelocationsRequestFile:
# @ApiMember(Description="Command type for the request (INITIATE)", IsRequired=true)
command: Optional[str] = None
"""
Command type for the request (INITIATE)
"""
# @ApiMember(Description="External identifier for the transferee", IsRequired=true)
external_i_d: Optional[str] = None
"""
External identifier for the transferee
"""
# @ApiMember(Description="Details about the transferee", IsRequired=true)
transferee_details: Optional[RelocationsRequestFileTransfereeDetails] = None
"""
Details about the transferee
"""
# @ApiMember(Description="List of addresses associated with the transferee", IsRequired=true)
addresses: Optional[List[RelocationsRequestFileAddress]] = None
"""
List of addresses associated with the transferee
"""
# @ApiMember(Description="List of phone numbers associated with the transferee", IsRequired=true)
phones: Optional[List[RelocationsRequestFilePhone]] = None
"""
List of phone numbers associated with the transferee
"""
# @ApiMember(Description="Assignment details for the relocation", IsRequired=true)
assignment_details: Optional[RelocationsRequestFileAssignmentDetails] = None
"""
Assignment details for the relocation
"""
# @Api(Description="Consumer Initiation Service")
# @ApiResponse(Description="Returned when the consumer initiation was successfully processed", StatusCode=200)
# @ApiResponse(Description="Returned if the request validation failed", StatusCode=400)
# @ApiResponse(Description="Returned if the client is not authorized", StatusCode=401)
# @ApiResponse(Description="Returned if an error occurred while processing the request", StatusCode=500)
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ConsumerInitiation(IPost):
"""
Consumer Initiation Service
"""
# @ApiMember(Description="Client identifier", IsRequired=true)
client_i_d: Optional[str] = None
"""
Client identifier
"""
# @ApiMember(Description="Consumer relocation request file details", IsRequired=true)
file: Optional[RelocationsRequestFile] = None
"""
Consumer relocation request file details
"""
class AddressType(str, Enum):
CURRENT_HOME = 'CurrentHome'
DESTINATION_HOME = 'DestinationHome'
CURRENT_WORK = 'CurrentWork'
DESTINATION_WORK = 'DestinationWork'
class YesNo(str, Enum):
Y = 'Y'
N = 'N'
ITEM = 'Item'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class RelocationsRequestFileAddress:
# @ApiMember(Description="Type of address (CurrentHome, DestinationHome, CurrentWork, DestinationWork)", IsRequired=true)
address_type: Optional[AddressType] = None
"""
Type of address (CurrentHome, DestinationHome, CurrentWork, DestinationWork)
"""
# @ApiMember(Description="Indicates if this is the primary address", IsRequired=true)
primary: Optional[YesNo] = None
"""
Indicates if this is the primary address
"""
# @ApiMember(Description="Address line 1", IsRequired=true)
address_line1: Optional[str] = None
"""
Address line 1
"""
# @ApiMember(Description="City", IsRequired=true)
city: Optional[str] = None
"""
City
"""
# @ApiMember(Description="Country", IsRequired=true)
country: Optional[str] = None
"""
Country
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class RelocationsRequestFilePhone:
# @ApiMember(Description="Phone type (e.g., Mobile, OriginHome)", IsRequired=true)
type: Optional[str] = None
"""
Phone type (e.g., Mobile, OriginHome)
"""
# @ApiMember(Description="Indicates if this is the primary phone number", IsRequired=true)
primary: Optional[YesNo] = None
"""
Indicates if this is the primary phone number
"""
# @ApiMember(Description="Phone number", IsRequired=true)
number: Optional[str] = None
"""
Phone number
"""
Python ConsumerInitiation 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 /consumerinitiation HTTP/1.1
Host: initiation-pen.sirva.com
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<ConsumerInitiation xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Client_Initiations.ServiceModel">
<ClientID>String</ClientID>
<File>
<Addresses>
<RelocationsRequestFileAddress>
<AddressLine1>String</AddressLine1>
<AddressType>CurrentHome</AddressType>
<City>String</City>
<Country>String</Country>
<Primary>Y</Primary>
</RelocationsRequestFileAddress>
</Addresses>
<AssignmentDetails>
<AssignmentType>String</AssignmentType>
<CompanyName>String</CompanyName>
<Contact>String</Contact>
<Current>
<CurrentWorkState>String</CurrentWorkState>
<DestinationWorkState>String</DestinationWorkState>
<PreferredWorkCountry>String</PreferredWorkCountry>
<PreferredWorkState>String</PreferredWorkState>
<WorkCity>String</WorkCity>
<WorkCountry>String</WorkCountry>
<WorkState>String</WorkState>
</Current>
<Destination>
<CurrentWorkState>String</CurrentWorkState>
<DestinationWorkState>String</DestinationWorkState>
<PreferredWorkCountry>String</PreferredWorkCountry>
<PreferredWorkState>String</PreferredWorkState>
<WorkCity>String</WorkCity>
<WorkCountry>String</WorkCountry>
<WorkState>String</WorkState>
</Destination>
<Program>String</Program>
<StartDate>0001-01-01T00:00:00</StartDate>
</AssignmentDetails>
<Command>String</Command>
<ExternalID>String</ExternalID>
<Phones>
<RelocationsRequestFilePhone>
<Number>String</Number>
<Primary>Y</Primary>
<Type>String</Type>
</RelocationsRequestFilePhone>
</Phones>
<TransfereeDetails>
<FirstName>String</FirstName>
<LastName>String</LastName>
<PreferredEmail>String</PreferredEmail>
</TransfereeDetails>
</File>
</ConsumerInitiation>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length
<ConsumerInitiationResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Client_Initiations.ServiceModel">
<Errors xmlns:d2p1="http://schemas.datacontract.org/2004/07/Client_Initiations.ServiceModel.Types">
<d2p1:ValidateError>
<d2p1:ErrorDescription>String</d2p1:ErrorDescription>
<d2p1:ErrorNumber>String</d2p1:ErrorNumber>
</d2p1:ValidateError>
</Errors>
<FileId>String</FileId>
<Message>String</Message>
</ConsumerInitiationResponse>