BokaMera.API.Host

<back to all web services

CreateCustomer

Requires Authentication
Required role:bookingsupplier-administrator-write
The following routes are available for this service:
POST/customersCreate a new customerCreates a new customer, if an admin user is making the request, the user will be associated with the admin user's company.
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 CustomFieldValueResponse:
    value: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomFieldConfigData:
    # @ApiMember(Description="Custom field id")
    id: int = 0
    """
    Custom field id
    """


    # @ApiMember(Description="Configuration name. Example: 'Number of persons'.")
    name: Optional[str] = None
    """
    Configuration name. Example: 'Number of persons'.
    """


    # @ApiMember(Description="Custom field description. Example: 'For how many persons is this booking?'")
    description: Optional[str] = None
    """
    Custom field description. Example: 'For how many persons is this booking?'
    """


    # @ApiMember(Description="Field width. Example: 20 for 20px")
    width: Optional[int] = None
    """
    Field width. Example: 20 for 20px
    """


    # @ApiMember(Description="Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'")
    data_type: Optional[str] = None
    """
    Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'
    """


    # @ApiMember(Description="Default value of the field. Example: '3'")
    default_value: Optional[str] = None
    """
    Default value of the field. Example: '3'
    """


    # @ApiMember(Description="Determines if the field is required to have a value or not")
    is_mandatory: bool = False
    """
    Determines if the field is required to have a value or not
    """


    # @ApiMember(Description="Error message shown to the user if the field data is required but not entered")
    mandatory_error_message: Optional[str] = None
    """
    Error message shown to the user if the field data is required but not entered
    """


    # @ApiMember(Description="Max lenght of the field")
    max_length: int = 0
    """
    Max lenght of the field
    """


    # @ApiMember(Description="If the field should have multiple lines")
    multiple_line_text: bool = False
    """
    If the field should have multiple lines
    """


    # @ApiMember(Description="Regular expression used for validation of the field")
    reg_ex: Optional[str] = None
    """
    Regular expression used for validation of the field
    """


    # @ApiMember(Description="Error message shown if the regular expression validation failed")
    reg_ex_error_message: Optional[str] = None
    """
    Error message shown if the regular expression validation failed
    """


    # @ApiMember(Description="The values to select from if Datatype is DropDown for this custom field")
    values: Optional[List[CustomFieldValueResponse]] = None
    """
    The values to select from if Datatype is DropDown for this custom field
    """


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomFieldDataResponse:
    id: int = 0
    column: Optional[str] = None
    name: Optional[str] = None
    description: Optional[str] = None
    value: Optional[str] = None
    # @ApiMember(Description="Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'")
    data_type: Optional[str] = None
    """
    Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'
    """


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomerCommentsResponse:
    id: int = 0
    customer_id: Optional[str] = None
    comments: Optional[str] = None
    updated: datetime.datetime = datetime.datetime(1, 1, 1)
    created: datetime.datetime = datetime.datetime(1, 1, 1)
    image_url: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BaseModel:
    pass


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class UserAccessKeys(BaseModel):
    # @Required()
    company_id: Optional[str] = None

    # @Required()
    access_key_type_id: int = 0

    # @Required()
    value: Optional[str] = None

    # @Required()
    customer_id: Optional[str] = None

    description: Optional[str] = None
    # @Required()
    id: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class InvoiceAddress:
    corporate_identity_number: Optional[str] = None
    invoice_address1: Optional[str] = None
    invoice_address2: Optional[str] = None
    invoice_city: Optional[str] = None
    invoice_postal_code: Optional[str] = None
    invoice_country_code: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomerQueryResponse:
    id: Optional[str] = None
    firstname: Optional[str] = None
    lastname: Optional[str] = None
    email: Optional[str] = None
    phone: Optional[str] = None
    image_url: Optional[str] = None
    custom_fields: Optional[List[CustomFieldConfigData]] = None
    custom_field_values: Optional[List[CustomFieldDataResponse]] = None
    comments: Optional[List[CustomerCommentsResponse]] = None
    access_keys: Optional[List[UserAccessKeys]] = None
    updated: datetime.datetime = datetime.datetime(1, 1, 1)
    created: datetime.datetime = datetime.datetime(1, 1, 1)
    response_status: Optional[Object] = None
    subscribed_to_newsletter: bool = False
    invoice_address: Optional[InvoiceAddress] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class UpdateCustomerResponse(CustomerQueryResponse):
    facebook_user_name: Optional[str] = None
    user_id: Optional[str] = None
    company_id: Optional[str] = None
    created_date: Optional[datetime.datetime] = None
    deleted_access_keys: Optional[List[UserAccessKeys]] = None
    created_or_updated_access_keys: Optional[List[UserAccessKeys]] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AddCustomField:
    id: int = 0
    value: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AddUserAccessKey:
    id: Optional[str] = None
    company_id: Optional[str] = None
    access_key_type_id: int = 0
    value: Optional[str] = None
    customer_id: Optional[str] = None
    description: Optional[str] = None


# @ApiResponse(Description="Returned if there is a validation error on the input parameters", StatusCode=400)
# @ApiResponse(Description="Returned if the current user is not allowed to perform the action", StatusCode=401)
# @ValidateRequest(Validator="IsAuthenticated")
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreateCustomer:
    # @ApiMember(Description="Enter the company and id for the customer, if blank company id and you are an admin, your company id will be used.", ParameterType="query")
    company_id: Optional[str] = None
    """
    Enter the company and id for the customer, if blank company id and you are an admin, your company id will be used.
    """


    # @ApiMember(IsRequired=true)
    firstname: Optional[str] = None

    # @ApiMember(IsRequired=true)
    lastname: Optional[str] = None

    # @ApiMember(IsRequired=true)
    phone: Optional[str] = None

    # @ApiMember()
    email: Optional[str] = None

    # @ApiMember(Description="If Custom Fields are added to the customer, here you will send the id and the value for each custom field to be updated")
    custom_fields: Optional[List[AddCustomField]] = None
    """
    If Custom Fields are added to the customer, here you will send the id and the value for each custom field to be updated
    """


    # @ApiMember(Description="List of Access Keys")
    access_keys: Optional[List[AddUserAccessKey]] = None
    """
    List of Access Keys
    """


    # @ApiMember(Description="Customer invoice adress")
    invoice_address: Optional[InvoiceAddress] = None
    """
    Customer invoice adress
    """

Python CreateCustomer DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml

HTTP + XML

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /customers HTTP/1.1 
Host: api.bokamera.se 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<CreateCustomer xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
  <AccessKeys>
    <AddUserAccessKey>
      <AccessKeyTypeId>0</AccessKeyTypeId>
      <CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
      <CustomerId>00000000-0000-0000-0000-000000000000</CustomerId>
      <Description>String</Description>
      <Id>00000000-0000-0000-0000-000000000000</Id>
      <Value>String</Value>
    </AddUserAccessKey>
  </AccessKeys>
  <CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
  <CustomFields>
    <AddCustomField>
      <Id>0</Id>
      <Value>String</Value>
    </AddCustomField>
  </CustomFields>
  <Email>String</Email>
  <Firstname>String</Firstname>
  <InvoiceAddress>
    <CorporateIdentityNumber>String</CorporateIdentityNumber>
    <InvoiceAddress1>String</InvoiceAddress1>
    <InvoiceAddress2>String</InvoiceAddress2>
    <InvoiceCity>String</InvoiceCity>
    <InvoiceCountryCode>String</InvoiceCountryCode>
    <InvoicePostalCode>String</InvoicePostalCode>
  </InvoiceAddress>
  <Lastname>String</Lastname>
  <Phone>String</Phone>
</CreateCustomer>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<UpdateCustomerResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
  <AccessKeys xmlns:d2p1="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Db">
    <d2p1:UserAccessKeys>
      <d2p1:AccessKeyTypeId>0</d2p1:AccessKeyTypeId>
      <d2p1:CompanyId>00000000-0000-0000-0000-000000000000</d2p1:CompanyId>
      <d2p1:CustomerId>00000000-0000-0000-0000-000000000000</d2p1:CustomerId>
      <d2p1:Description>String</d2p1:Description>
      <d2p1:Id>00000000-0000-0000-0000-000000000000</d2p1:Id>
      <d2p1:Value>String</d2p1:Value>
    </d2p1:UserAccessKeys>
  </AccessKeys>
  <Comments>
    <CustomerCommentsResponse>
      <Comments>String</Comments>
      <Created>0001-01-01T00:00:00</Created>
      <CustomerId>00000000-0000-0000-0000-000000000000</CustomerId>
      <Id>0</Id>
      <ImageUrl i:nil="true" />
      <Updated>0001-01-01T00:00:00</Updated>
    </CustomerCommentsResponse>
  </Comments>
  <Created>0001-01-01T00:00:00</Created>
  <CustomFieldValues>
    <CustomFieldDataResponse>
      <Column>String</Column>
      <DataType>String</DataType>
      <Description>String</Description>
      <Id>0</Id>
      <Name>String</Name>
      <Value>String</Value>
    </CustomFieldDataResponse>
  </CustomFieldValues>
  <CustomFields>
    <CustomFieldConfigData>
      <DataType>String</DataType>
      <DefaultValue>String</DefaultValue>
      <Description>String</Description>
      <Id>0</Id>
      <IsMandatory>false</IsMandatory>
      <MandatoryErrorMessage>String</MandatoryErrorMessage>
      <MaxLength>0</MaxLength>
      <MultipleLineText>false</MultipleLineText>
      <Name>String</Name>
      <RegEx>String</RegEx>
      <RegExErrorMessage>String</RegExErrorMessage>
      <Values>
        <CustomFieldValueResponse>
          <Value>String</Value>
        </CustomFieldValueResponse>
      </Values>
      <Width>0</Width>
    </CustomFieldConfigData>
  </CustomFields>
  <Email>String</Email>
  <Firstname>String</Firstname>
  <Id>00000000-0000-0000-0000-000000000000</Id>
  <ImageUrl>String</ImageUrl>
  <InvoiceAddress>
    <CorporateIdentityNumber>String</CorporateIdentityNumber>
    <InvoiceAddress1>String</InvoiceAddress1>
    <InvoiceAddress2>String</InvoiceAddress2>
    <InvoiceCity>String</InvoiceCity>
    <InvoiceCountryCode>String</InvoiceCountryCode>
    <InvoicePostalCode>String</InvoicePostalCode>
  </InvoiceAddress>
  <Lastname>String</Lastname>
  <Phone>String</Phone>
  <ResponseStatus />
  <SubscribedToNewsletter>false</SubscribedToNewsletter>
  <Updated>0001-01-01T00:00:00</Updated>
  <CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
  <CreatedDate>0001-01-01T00:00:00</CreatedDate>
  <CreatedOrUpdatedAccessKeys xmlns:d2p1="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Db">
    <d2p1:UserAccessKeys>
      <d2p1:AccessKeyTypeId>0</d2p1:AccessKeyTypeId>
      <d2p1:CompanyId>00000000-0000-0000-0000-000000000000</d2p1:CompanyId>
      <d2p1:CustomerId>00000000-0000-0000-0000-000000000000</d2p1:CustomerId>
      <d2p1:Description>String</d2p1:Description>
      <d2p1:Id>00000000-0000-0000-0000-000000000000</d2p1:Id>
      <d2p1:Value>String</d2p1:Value>
    </d2p1:UserAccessKeys>
  </CreatedOrUpdatedAccessKeys>
  <DeletedAccessKeys xmlns:d2p1="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Db">
    <d2p1:UserAccessKeys>
      <d2p1:AccessKeyTypeId>0</d2p1:AccessKeyTypeId>
      <d2p1:CompanyId>00000000-0000-0000-0000-000000000000</d2p1:CompanyId>
      <d2p1:CustomerId>00000000-0000-0000-0000-000000000000</d2p1:CustomerId>
      <d2p1:Description>String</d2p1:Description>
      <d2p1:Id>00000000-0000-0000-0000-000000000000</d2p1:Id>
      <d2p1:Value>String</d2p1:Value>
    </d2p1:UserAccessKeys>
  </DeletedAccessKeys>
  <FacebookUserName>String</FacebookUserName>
  <UserId>00000000-0000-0000-0000-000000000000</UserId>
</UpdateCustomerResponse>