POST | /customer | Create customer | Create CRM customer |
---|
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 Email:
# @ApiMember(Description="Email", IsRequired=true)
email: Optional[str] = None
"""
Email
"""
# @ApiMember(Description="Main email", IsRequired=true)
is_main_email: bool = False
"""
Main email
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Phone:
# @ApiMember(Description="Phone e.g. cn: 13888889999, jp: 352858088, kr: 023123456", IsRequired=true)
phone: Optional[str] = None
"""
Phone e.g. cn: 13888889999, jp: 352858088, kr: 023123456
"""
# @ApiMember(Description="Prefix Country Id e.g. it, fr, az", IsRequired=true)
country_prefix: Optional[str] = None
"""
Prefix Country Id e.g. it, fr, az
"""
# @ApiMember(Description="Phone type e.g. 'Home', 'Mobile', 'Work', 'Other', 'Secondary Address'")
phone_type: Optional[str] = None
"""
Phone type e.g. 'Home', 'Mobile', 'Work', 'Other', 'Secondary Address'
"""
# @ApiMember(Description="Main Phone", IsRequired=true)
is_main_phone: bool = False
"""
Main Phone
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Address:
# @ApiMember(Description="Address type e.g. Home, Office, Shipping", IsRequired=true)
address_type: Optional[str] = None
"""
Address type e.g. Home, Office, Shipping
"""
# @ApiMember(Description="Country Id e.g. it, cn, az, gb, de", IsRequired=true)
country_id: Optional[str] = None
"""
Country Id e.g. it, cn, az, gb, de
"""
# @ApiMember(Description="House Number")
house_number: Optional[str] = None
"""
House Number
"""
# @ApiMember(Description="Region/State")
state_id: Optional[str] = None
"""
Region/State
"""
# @ApiMember(Description="City Name")
city: Optional[str] = None
"""
City Name
"""
# @ApiMember(Description="Postal Code")
zip_code: Optional[str] = None
"""
Postal Code
"""
# @ApiMember(Description="Street Name and Number")
street: Optional[str] = None
"""
Street Name and Number
"""
# @ApiMember(Description="Street 2")
street2: Optional[str] = None
"""
Street 2
"""
# @ApiMember(Description="Street 3")
street3: Optional[str] = None
"""
Street 3
"""
# @ApiMember(Description="Street 4")
street4: Optional[str] = None
"""
Street 4
"""
# @ApiMember(Description="Street 5")
street5: Optional[str] = None
"""
Street 5
"""
# @ApiMember(Description="Main Address", IsRequired=true)
is_main_address: bool = False
"""
Main Address
"""
# @ApiMember(Description="Post Office Box")
po_box: Optional[str] = None
"""
Post Office Box
"""
# @ApiMember(Description="Additional Information")
additional_information: Optional[str] = None
"""
Additional Information
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Event:
# @ApiMember(Description="Event type e.g. 'Birthday', 'Wedding', 'Anniversary', 'Barmitza', 'Other'", IsRequired=true)
event_type: Optional[str] = None
"""
Event type e.g. 'Birthday', 'Wedding', 'Anniversary', 'Barmitza', 'Other'
"""
# @ApiMember(Description="Event date e.g. '2021-01-20'", IsRequired=true)
event_date: datetime.datetime = datetime.datetime(1, 1, 1)
"""
Event date e.g. '2021-01-20'
"""
# @ApiMember(Description="Event notes")
event_notes: Optional[str] = None
"""
Event notes
"""
# @ApiMember(Description="Event other name")
event_other_name: Optional[str] = None
"""
Event other name
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Interest:
# @ApiMember(Description="Interest description", IsRequired=true)
interest: Optional[str] = None
"""
Interest description
"""
# @ApiMember(Description="SAP Interest ID, e.g. 'CA-1'", IsRequired=true)
sap_interest_id: Optional[str] = None
"""
SAP Interest ID, e.g. 'CA-1'
"""
# @ApiMember(Description="Interest description translation")
translation: Optional[str] = None
"""
Interest description translation
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Hobby:
# @ApiMember(Description="Hobby description", IsRequired=true)
hobby: Optional[str] = None
"""
Hobby description
"""
# @ApiMember(Description="SAP Hobby ID, e.g. 'ART'", IsRequired=true)
sap_hobby_id: Optional[str] = None
"""
SAP Hobby ID, e.g. 'ART'
"""
# @ApiMember(Description="Hobby description translation")
translation: Optional[str] = None
"""
Hobby description translation
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ProductCollection:
# @ApiMember(Description="Product Collection description", IsRequired=true)
product_collection: Optional[str] = None
"""
Product Collection description
"""
# @ApiMember(Description="SAP ProductCollection ID, e.g. 'CA-1'", IsRequired=true)
sap_product_collection_id: Optional[str] = None
"""
SAP ProductCollection ID, e.g. 'CA-1'
"""
# @ApiMember(Description="Product Collection description translation", IsRequired=true)
translation: Optional[str] = None
"""
Product Collection description translation
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Customer:
# @ApiMember(Description="Title e.g. 'Mr & Mrs', 'Mr.', 'Mrs.', 'Sama', 'Captain' - Mandatory only when customer type is 'PRIVATE'")
title: Optional[str] = None
"""
Title e.g. 'Mr & Mrs', 'Mr.', 'Mrs.', 'Sama', 'Captain' - Mandatory only when customer type is 'PRIVATE'
"""
# @ApiMember(Description="First Name")
first_name: Optional[str] = None
"""
First Name
"""
# @ApiMember(Description="Last Name - Mandatory only when customer type is 'PRIVATE'")
last_name: Optional[str] = None
"""
Last Name - Mandatory only when customer type is 'PRIVATE'
"""
# @ApiMember(Description="First Name Not Latin")
first_name_not_latin: Optional[str] = None
"""
First Name Not Latin
"""
# @ApiMember(Description="Last Name Not Latin")
last_name_not_latin: Optional[str] = None
"""
Last Name Not Latin
"""
# @ApiMember(Description="Middle Name")
middle_name: Optional[str] = None
"""
Middle Name
"""
# @ApiMember(Description="Name Suffix")
name_suffix: Optional[str] = None
"""
Name Suffix
"""
# @ApiMember(Description="Can be Contacted by Maison e.g. true or false", IsRequired=true)
can_be_contacted_by_maison: bool = False
"""
Can be Contacted by Maison e.g. true or false
"""
# @ApiMember(Description="Customer Type e.g. 'PRIVATE' or 'COMPANY'", IsRequired=true)
client_type: Optional[str] = None
"""
Customer Type e.g. 'PRIVATE' or 'COMPANY'
"""
# @ApiMember(Description="Company Name - Mandatory only when customer type is 'COMPANY'")
company_name: Optional[str] = None
"""
Company Name - Mandatory only when customer type is 'COMPANY'
"""
# @ApiMember(Description="Language Id e.g. ita, chi, aze, eng, ger - Mandatory only when customer type is 'PRIVATE'")
language_id: Optional[str] = None
"""
Language Id e.g. ita, chi, aze, eng, ger - Mandatory only when customer type is 'PRIVATE'
"""
# @ApiMember(Description="Gender e.g. M, F - Mandatory only when customer type is 'PRIVATE'")
gender: Optional[str] = None
"""
Gender e.g. M, F - Mandatory only when customer type is 'PRIVATE'
"""
# @ApiMember(Description="Country Id e.g. it, cn, az, gb, de", IsRequired=true)
country_id: Optional[str] = None
"""
Country Id e.g. it, cn, az, gb, de
"""
# @ApiMember(Description="Birth Date e.g. '2020-12-30'")
birth_date: Optional[datetime.datetime] = None
"""
Birth Date e.g. '2020-12-30'
"""
# @ApiMember(Description="Customer reference")
customer_reference: Optional[str] = None
"""
Customer reference
"""
# @ApiMember(Description="POS Code e.g. ES100:102048", IsRequired=true)
pos_code: Optional[str] = None
"""
POS Code e.g. ES100:102048
"""
# @ApiMember(Description="Brand e.g. CAR, MTB", IsRequired=true)
brand: Optional[str] = None
"""
Brand e.g. CAR, MTB
"""
# @ApiMember(Description="Wedding Date, e.g. '2020-01-18'")
wedding_date: Optional[datetime.datetime] = None
"""
Wedding Date, e.g. '2020-01-18'
"""
# @ApiMember(Description="Preferred Contact Method e.g. 'Fax', 'Tel', 'EMail', 'Mail', 'Survey'")
preferred_contact_method: Optional[str] = None
"""
Preferred Contact Method e.g. 'Fax', 'Tel', 'EMail', 'Mail', 'Survey'
"""
# @ApiMember(Description="Provide 'true' if you want to be contacted by email. Leave empty or 'false' if you do not.")
contact_by_email_flag: bool = False
"""
Provide 'true' if you want to be contacted by email. Leave empty or 'false' if you do not.
"""
# @ApiMember(Description="Provide 'true' if you want to be contacted by mail. Leave empty or 'false' if you do not.")
contact_by_mail_flag: bool = False
"""
Provide 'true' if you want to be contacted by mail. Leave empty or 'false' if you do not.
"""
# @ApiMember(Description="Provide 'true' if you want to be contacted by phone. Leave empty or 'false' if you do not.")
contact_by_phone_flag: bool = False
"""
Provide 'true' if you want to be contacted by phone. Leave empty or 'false' if you do not.
"""
# @ApiMember(Description="Provide 'true' if you want to be contacted by SMS. Leave empty or 'false' if you do not.")
contact_by_s_m_s_flag: bool = False
"""
Provide 'true' if you want to be contacted by SMS. Leave empty or 'false' if you do not.
"""
# @ApiMember(Description="Provide 'true' if you want to be contacted by social media. Leave empty or 'false' if you do not.")
contact_by_social_media_flag: bool = False
"""
Provide 'true' if you want to be contacted by social media. Leave empty or 'false' if you do not.
"""
# @ApiMember(Description="Sale Representative Email e.g. rauf.aliyev@richemont.com")
sale_representative_email: Optional[str] = None
"""
Sale Representative Email e.g. rauf.aliyev@richemont.com
"""
# @ApiMember(Description="Consent for allowing Cross Border Data Transfer")
allow_store_data_abroad: Optional[bool] = None
"""
Consent for allowing Cross Border Data Transfer
"""
# @ApiMember(Description="Consent for allowing Cross Border Data Transfer For TimeVallée")
tv_allow_store_data_abroad: Optional[bool] = None
"""
Consent for allowing Cross Border Data Transfer For TimeVallée
"""
# @ApiMember(Description="Customer emails")
emails: Optional[List[Email]] = None
"""
Customer emails
"""
# @ApiMember(Description="Customer phones")
phones: Optional[List[Phone]] = None
"""
Customer phones
"""
# @ApiMember(Description="Customer addresses")
addresses: Optional[List[Address]] = None
"""
Customer addresses
"""
# @ApiMember(Description="Customer events")
events: Optional[List[Event]] = None
"""
Customer events
"""
# @ApiMember(Description="Customer interests")
interests: Optional[List[Interest]] = None
"""
Customer interests
"""
# @ApiMember(Description="Customer hobbies")
hobbies: Optional[List[Hobby]] = None
"""
Customer hobbies
"""
# @ApiMember(Description="Customer product collections")
product_collections: Optional[List[ProductCollection]] = None
"""
Customer product collections
"""
# @ApiMember(Description="Provide 'true' if you allow data sharing consent. Leave empty or 'false' if you do not.")
data_sharing_consent: Optional[bool] = None
"""
Provide 'true' if you allow data sharing consent. Leave empty or 'false' if you do not.
"""
# @ApiMember(Description="Notes")
notes: Optional[str] = None
"""
Notes
"""
# @ApiMember(Description="Reference Sale Representative Email")
reference_sale_representative_email: Optional[str] = None
"""
Reference Sale Representative Email
"""
# @ApiMember(Description="Registration Date")
registration_date: Optional[datetime.datetime] = None
"""
Registration Date
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreateCustomerResponse:
# @ApiMember(Description="Booster Customer ID", IsRequired=true)
booster_customer_id: int = 0
"""
Booster Customer ID
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreateCustomer(Customer):
# @ApiMember(Description="Privacy policy acceptance for data storage", IsRequired=true)
privacy_policy_acceptance_storage: bool = False
"""
Privacy policy acceptance for data storage
"""
# @ApiMember(Description="Privacy policy acceptance of data storage for TimeVallée")
tv_privacy_policy_acceptance_storage: Optional[bool] = None
"""
Privacy policy acceptance of data storage for TimeVallée
"""
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 /customer HTTP/1.1
Host: dev-api-booster.richemont.com
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"privacyPolicyAcceptanceStorage":false,"tvPrivacyPolicyAcceptanceStorage":false,"title":"String","firstName":"String","lastName":"String","firstNameNotLatin":"String","lastNameNotLatin":"String","middleName":"String","nameSuffix":"String","canBeContactedByMaison":false,"clientType":"String","companyName":"String","languageId":"String","gender":"String","countryId":"String","birthDate":"\/Date(-62135596800000-0000)\/","customerReference":"String","posCode":"String","brand":"String","weddingDate":"\/Date(-62135596800000-0000)\/","preferredContactMethod":"String","contactByEmailFlag":false,"contactByMailFlag":false,"contactByPhoneFlag":false,"contactBySMSFlag":false,"contactBySocialMediaFlag":false,"saleRepresentativeEmail":"String","allowStoreDataAbroad":false,"tvAllowStoreDataAbroad":false,"emails":[{"email":"String","isMainEmail":false}],"phones":[{"phone":"String","countryPrefix":"String","phoneType":"String","isMainPhone":false}],"addresses":[{"addressType":"String","countryId":"String","houseNumber":"String","stateId":"String","city":"String","zipCode":"String","street":"String","street2":"String","street3":"String","street4":"String","street5":"String","isMainAddress":false,"poBox":"String","additionalInformation":"String"}],"events":[{"eventType":"String","eventDate":"\/Date(-62135596800000-0000)\/","eventNotes":"String","eventOtherName":"String"}],"interests":[{"interest":"String","sapInterestId":"String","translation":"String"}],"hobbies":[{"hobby":"String","sapHobbyId":"String","translation":"String"}],"productCollections":[{"productCollection":"String","sapProductCollectionId":"String","translation":"String"}],"dataSharingConsent":false,"notes":"String","referenceSaleRepresentativeEmail":"String","registrationDate":"\/Date(-62135596800000-0000)\/"}
HTTP/1.1 200 OK Content-Type: text/csv Content-Length: length {"boosterCustomerId":0}