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 Foundation
import ServiceStack

// @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")
public class CreateCustomer : Codable
{
    /**
    * Enter the company and id for the customer, if blank company id and you are an admin, your company id will be used.
    */
    // @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")
    public var companyId:String?

    // @ApiMember(IsRequired=true)
    public var firstname:String

    // @ApiMember(IsRequired=true)
    public var lastname:String

    // @ApiMember(IsRequired=true)
    public var phone:String

    // @ApiMember()
    public var email:String

    /**
    * 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="If Custom Fields are added to the customer, here you will send the id and the value for each custom field to be updated")
    public var customFields:[AddCustomField] = []

    /**
    * List of Access Keys
    */
    // @ApiMember(Description="List of Access Keys")
    public var accessKeys:[AddUserAccessKey] = []

    /**
    * Customer invoice adress
    */
    // @ApiMember(Description="Customer invoice adress")
    public var invoiceAddress:InvoiceAddress

    required public init(){}
}

public class AddCustomField : Codable
{
    public var id:Int
    public var value:String

    required public init(){}
}

public class AddUserAccessKey : Codable
{
    public var id:String?
    public var companyId:String?
    public var accessKeyTypeId:Int
    public var value:String
    public var customerId:String?
    public var Description:String

    required public init(){}
}

public class InvoiceAddress : Codable
{
    public var corporateIdentityNumber:String
    public var invoiceAddress1:String
    public var invoiceAddress2:String
    public var invoiceCity:String
    public var invoicePostalCode:String
    public var invoiceCountryCode:String

    required public init(){}
}

public class UpdateCustomerResponse : CustomerQueryResponse
{
    public var facebookUserName:String
    public var userId:String?
    public var companyId:String?
    public var createdDate:Date?
    public var deletedAccessKeys:[UserAccessKeys] = []
    public var createdOrUpdatedAccessKeys:[UserAccessKeys] = []

    required public init(){ super.init() }

    private enum CodingKeys : String, CodingKey {
        case facebookUserName
        case userId
        case companyId
        case createdDate
        case deletedAccessKeys
        case createdOrUpdatedAccessKeys
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        facebookUserName = try container.decodeIfPresent(String.self, forKey: .facebookUserName)
        userId = try container.decodeIfPresent(String.self, forKey: .userId)
        companyId = try container.decodeIfPresent(String.self, forKey: .companyId)
        createdDate = try container.decodeIfPresent(Date.self, forKey: .createdDate)
        deletedAccessKeys = try container.decodeIfPresent([UserAccessKeys].self, forKey: .deletedAccessKeys) ?? []
        createdOrUpdatedAccessKeys = try container.decodeIfPresent([UserAccessKeys].self, forKey: .createdOrUpdatedAccessKeys) ?? []
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if facebookUserName != nil { try container.encode(facebookUserName, forKey: .facebookUserName) }
        if userId != nil { try container.encode(userId, forKey: .userId) }
        if companyId != nil { try container.encode(companyId, forKey: .companyId) }
        if createdDate != nil { try container.encode(createdDate, forKey: .createdDate) }
        if deletedAccessKeys.count > 0 { try container.encode(deletedAccessKeys, forKey: .deletedAccessKeys) }
        if createdOrUpdatedAccessKeys.count > 0 { try container.encode(createdOrUpdatedAccessKeys, forKey: .createdOrUpdatedAccessKeys) }
    }
}

public class CustomerQueryResponse : Codable
{
    public var id:String
    public var firstname:String
    public var lastname:String
    public var email:String
    public var phone:String
    public var imageUrl:String
    public var customFields:[CustomFieldConfigData] = []
    public var customFieldValues:[CustomFieldDataResponse] = []
    public var comments:[CustomerCommentsResponse] = []
    public var accessKeys:[UserAccessKeys] = []
    public var updated:Date
    public var created:Date
    //responseStatus:Object ignored. Type could not be extended in Swift
    public var subscribedToNewsletter:Bool
    public var invoiceAddress:InvoiceAddress

    required public init(){}
}

public class CustomFieldConfigData : Codable
{
    /**
    * Custom field id
    */
    // @ApiMember(Description="Custom field id")
    public var id:Int

    /**
    * Configuration name. Example: 'Number of persons'.
    */
    // @ApiMember(Description="Configuration name. Example: 'Number of persons'.")
    public var name:String

    /**
    * Custom field description. Example: 'For how many persons is this booking?'
    */
    // @ApiMember(Description="Custom field description. Example: 'For how many persons is this booking?'")
    public var Description:String

    /**
    * Field width. Example: 20 for 20px
    */
    // @ApiMember(Description="Field width. Example: 20 for 20px")
    public var width:Int?

    /**
    * Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'
    */
    // @ApiMember(Description="Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'")
    public var dataType:String

    /**
    * Default value of the field. Example: '3'
    */
    // @ApiMember(Description="Default value of the field. Example: '3'")
    public var defaultValue:String

    /**
    * Determines if the field is required to have a value or not
    */
    // @ApiMember(Description="Determines if the field is required to have a value or not")
    public var isMandatory:Bool

    /**
    * Error message shown to the user if the field data is required but not entered
    */
    // @ApiMember(Description="Error message shown to the user if the field data is required but not entered")
    public var mandatoryErrorMessage:String

    /**
    * Max lenght of the field
    */
    // @ApiMember(Description="Max lenght of the field")
    public var maxLength:Int

    /**
    * If the field should have multiple lines
    */
    // @ApiMember(Description="If the field should have multiple lines")
    public var multipleLineText:Bool

    /**
    * Regular expression used for validation of the field
    */
    // @ApiMember(Description="Regular expression used for validation of the field")
    public var regEx:String

    /**
    * Error message shown if the regular expression validation failed
    */
    // @ApiMember(Description="Error message shown if the regular expression validation failed")
    public var regExErrorMessage:String

    /**
    * The values to select from if Datatype is DropDown for this custom field
    */
    // @ApiMember(Description="The values to select from if Datatype is DropDown for this custom field")
    public var values:[CustomFieldValueResponse] = []

    required public init(){}
}

public class CustomFieldValueResponse : Codable
{
    public var value:String

    required public init(){}
}

public class CustomFieldDataResponse : Codable
{
    public var id:Int
    public var column:String
    public var name:String
    public var Description:String
    public var value:String
    /**
    * Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'
    */
    // @ApiMember(Description="Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'")
    public var dataType:String

    required public init(){}
}

public class CustomerCommentsResponse : Codable
{
    public var id:Int
    public var customerId:String
    public var comments:String
    public var updated:Date
    public var created:Date
    public var imageUrl:Uri

    required public init(){}
}

public class UserAccessKeys : BaseModel
{
    // @Required()
    public var companyId:String?

    // @Required()
    public var accessKeyTypeId:Int?

    // @Required()
    public var value:String?

    // @Required()
    public var customerId:String?

    public var Description:String
    // @Required()
    public var id:String?

    required public init(){ super.init() }

    private enum CodingKeys : String, CodingKey {
        case companyId
        case accessKeyTypeId
        case value
        case customerId
        case Description
        case id
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        companyId = try container.decodeIfPresent(String.self, forKey: .companyId)
        accessKeyTypeId = try container.decodeIfPresent(Int.self, forKey: .accessKeyTypeId)
        value = try container.decodeIfPresent(String.self, forKey: .value)
        customerId = try container.decodeIfPresent(String.self, forKey: .customerId)
        Description = try container.decodeIfPresent(String.self, forKey: .Description)
        id = try container.decodeIfPresent(String.self, forKey: .id)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if companyId != nil { try container.encode(companyId, forKey: .companyId) }
        if accessKeyTypeId != nil { try container.encode(accessKeyTypeId, forKey: .accessKeyTypeId) }
        if value != nil { try container.encode(value, forKey: .value) }
        if customerId != nil { try container.encode(customerId, forKey: .customerId) }
        if Description != nil { try container.encode(Description, forKey: .Description) }
        if id != nil { try container.encode(id, forKey: .id) }
    }
}

public class BaseModel : Codable
{
    required public init(){}
}


Swift 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: testapi.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>