| Required role: | bookingsupplier-administrator-write |
| POST | /customers | Create a new customer | Creates a new customer, if an admin user is making the request, the user will be associated with the admin user's company. |
|---|
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using ServiceStack;
using ServiceStack.DataAnnotations;
using BokaMera.API.ServiceModel.Dtos;
using BokaMera.API.ServiceModel.Dtos.Commons;
using BokaMera.API.ServiceModel.Db;
namespace BokaMera.API.ServiceModel.Db
{
public partial class BaseModel
{
}
public partial class UserAccessKeys
: BaseModel
{
[Required]
public virtual Guid CompanyId { get; set; }
[Required]
public virtual int AccessKeyTypeId { get; set; }
[Required]
public virtual string Value { get; set; }
[Required]
public virtual Guid CustomerId { get; set; }
public virtual string Description { get; set; }
[Required]
public virtual Guid Id { get; set; }
}
}
namespace BokaMera.API.ServiceModel.Dtos
{
public partial class AddCustomField
{
public virtual int Id { get; set; }
public virtual string Value { get; set; }
}
public partial class AddUserAccessKey
{
///<summary>
///Specify 'Id' to update an existing access key, leave empty to create a new one
///</summary>
[ApiMember(Description="Specify 'Id' to update an existing access key, leave empty to create a new one")]
public virtual Guid? Id { get; set; }
///<summary>
///The company ID associated with this access key
///</summary>
[ApiMember(Description="The company ID associated with this access key")]
public virtual Guid? CompanyId { get; set; }
///<summary>
///The type of access key to create
///</summary>
[ApiMember(Description="The type of access key to create")]
public virtual int AccessKeyTypeId { get; set; }
///<summary>
///The actual key value or token
///</summary>
[ApiMember(Description="The actual key value or token")]
public virtual string Value { get; set; }
///<summary>
///The customer ID this access key is associated with
///</summary>
[ApiMember(Description="The customer ID this access key is associated with")]
public virtual Guid? CustomerId { get; set; }
///<summary>
///A description or note about this access key
///</summary>
[ApiMember(Description="A description or note about this access key")]
public virtual string Description { get; set; }
}
[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("IsAuthenticated")]
public partial class CreateCustomer
: CustomerBase
{
///<summary>
///Enter the company and id for the customer, if blank company id and you are an admin, your company id will be used.
///</summary>
[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 virtual Guid? CompanyId { get; set; }
///<summary>
///If Custom Fields are added to the customer, here you will send the id and the value for each custom field to be updated
///</summary>
[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 virtual List<AddCustomField> CustomFields { get; set; } = [];
///<summary>
///List of Access Keys
///</summary>
[ApiMember(Description="List of Access Keys")]
public virtual List<AddUserAccessKey> AccessKeys { get; set; } = [];
///<summary>
///Customer invoice adress
///</summary>
[ApiMember(Description="Customer invoice adress")]
public virtual InvoiceAddressToHandle InvoiceAddress { get; set; }
}
public partial class CustomerCommentsResponse
{
public virtual int Id { get; set; }
public virtual Guid CustomerId { get; set; }
public virtual string Comments { get; set; }
public virtual DateTime Updated { get; set; }
public virtual DateTime Created { get; set; }
public virtual Uri ImageUrl { get; set; }
}
public partial class CustomerQueryResponse
{
public virtual Guid Id { get; set; }
public virtual string Firstname { get; set; }
public virtual string Lastname { get; set; }
public virtual string Email { get; set; }
public virtual string Phone { get; set; }
public virtual string ImageUrl { get; set; }
public virtual List<CustomFieldConfigData> CustomFields { get; set; } = [];
public virtual List<CustomFieldDataResponse> CustomFieldValues { get; set; } = [];
public virtual List<CustomerCommentsResponse> Comments { get; set; } = [];
public virtual List<UserAccessKeys> AccessKeys { get; set; } = [];
public virtual DateTime Updated { get; set; }
public virtual DateTime Created { get; set; }
public virtual Object ResponseStatus { get; set; }
public virtual bool SubscribedToNewsletter { get; set; }
public virtual InvoiceAddressResponse InvoiceAddress { get; set; }
}
public partial class CustomFieldConfigData
{
///<summary>
///Custom field id
///</summary>
[ApiMember(Description="Custom field id")]
public virtual int Id { get; set; }
///<summary>
///Configuration name. Example: 'Number of persons'.
///</summary>
[ApiMember(Description="Configuration name. Example: 'Number of persons'.")]
public virtual string Name { get; set; }
///<summary>
///Custom field description. Example: 'For how many persons is this booking?'
///</summary>
[ApiMember(Description="Custom field description. Example: 'For how many persons is this booking?'")]
public virtual string Description { get; set; }
///<summary>
///Field width. Example: 20 for 20px
///</summary>
[ApiMember(Description="Field width. Example: 20 for 20px")]
public virtual int? Width { get; set; }
///<summary>
///Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'
///</summary>
[ApiMember(Description="Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'")]
public virtual string DataType { get; set; }
///<summary>
///Default value of the field. Example: '3'
///</summary>
[ApiMember(Description="Default value of the field. Example: '3'")]
public virtual string DefaultValue { get; set; }
///<summary>
///Determines if the field is required to have a value or not
///</summary>
[ApiMember(Description="Determines if the field is required to have a value or not")]
public virtual bool IsMandatory { get; set; }
///<summary>
///Error message shown to the user if the field data is required but not entered
///</summary>
[ApiMember(Description="Error message shown to the user if the field data is required but not entered")]
public virtual string MandatoryErrorMessage { get; set; }
///<summary>
///Max lenght of the field
///</summary>
[ApiMember(Description="Max lenght of the field")]
public virtual int MaxLength { get; set; }
///<summary>
///If the field should have multiple lines
///</summary>
[ApiMember(Description="If the field should have multiple lines")]
public virtual bool MultipleLineText { get; set; }
///<summary>
///Regular expression used for validation of the field
///</summary>
[ApiMember(Description="Regular expression used for validation of the field")]
public virtual string RegEx { get; set; }
///<summary>
///Error message shown if the regular expression validation failed
///</summary>
[ApiMember(Description="Error message shown if the regular expression validation failed")]
public virtual string RegExErrorMessage { get; set; }
///<summary>
///The values to select from if Datatype is DropDown for this custom field
///</summary>
[ApiMember(Description="The values to select from if Datatype is DropDown for this custom field")]
public virtual List<CustomFieldValueResponse> Values { get; set; } = [];
}
public partial class CustomFieldDataResponse
{
public virtual int Id { get; set; }
public virtual string Column { get; set; }
public virtual string Name { get; set; }
public virtual string Description { get; set; }
public virtual string Value { get; set; }
///<summary>
///Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'
///</summary>
[ApiMember(Description="Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'")]
public virtual string DataType { get; set; }
}
public partial class CustomFieldValueResponse
{
public virtual string Value { get; set; }
}
public partial class InvoiceAddressResponse
{
public virtual Guid InvoiceAddressId { get; set; }
public virtual Guid? UserId { get; set; }
public virtual string CorporateIdentityNumber { get; set; }
public virtual string InvoiceAddress1 { get; set; }
public virtual string InvoiceAddress2 { get; set; }
public virtual string InvoiceCity { get; set; }
public virtual string InvoicePostalCode { get; set; }
public virtual string InvoiceCountryCode { get; set; }
}
public partial class InvoiceAddressToHandle
: IInvoiceAddress
{
public virtual string CorporateIdentityNumber { get; set; }
public virtual string InvoiceAddress1 { get; set; }
public virtual string InvoiceAddress2 { get; set; }
public virtual string InvoiceCity { get; set; }
public virtual string InvoicePostalCode { get; set; }
public virtual string InvoiceCountryCode { get; set; }
}
public partial class UpdateCustomerResponse
: CustomerQueryResponse
{
public virtual string FacebookUserName { get; set; }
public virtual Guid? UserId { get; set; }
public virtual Guid? CompanyId { get; set; }
public virtual DateTime? CreatedDate { get; set; }
public virtual List<UserAccessKeys> DeletedAccessKeys { get; set; } = [];
public virtual List<UserAccessKeys> CreatedOrUpdatedAccessKeys { get; set; } = [];
}
}
namespace BokaMera.API.ServiceModel.Dtos.Commons
{
public partial class CustomerBase
: ICustomerBase
{
public virtual Guid? CustomerId { get; set; }
public virtual string Firstname { get; set; }
public virtual string Lastname { get; set; }
public virtual string Email { get; set; }
public virtual string Phone { get; set; }
public virtual bool SubscribedToNewsletter { get; set; }
}
}
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 /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">
<CustomerId xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos.Commons">00000000-0000-0000-0000-000000000000</CustomerId>
<Email xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos.Commons">String</Email>
<Firstname xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos.Commons">String</Firstname>
<Lastname xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos.Commons">String</Lastname>
<Phone xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos.Commons">String</Phone>
<SubscribedToNewsletter xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos.Commons">false</SubscribedToNewsletter>
<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>
<InvoiceAddress>
<CorporateIdentityNumber>String</CorporateIdentityNumber>
<InvoiceAddress1>String</InvoiceAddress1>
<InvoiceAddress2>String</InvoiceAddress2>
<InvoiceCity>String</InvoiceCity>
<InvoiceCountryCode>String</InvoiceCountryCode>
<InvoicePostalCode>String</InvoicePostalCode>
</InvoiceAddress>
</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>
<InvoiceAddressId>00000000-0000-0000-0000-000000000000</InvoiceAddressId>
<InvoiceCity>String</InvoiceCity>
<InvoiceCountryCode>String</InvoiceCountryCode>
<InvoicePostalCode>String</InvoicePostalCode>
<UserId>00000000-0000-0000-0000-000000000000</UserId>
</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>