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. |
---|
namespace BokaMera.API.ServiceModel.Db
open System
open System.Collections
open System.Collections.Generic
open System.Runtime.Serialization
open ServiceStack
open ServiceStack.DataAnnotations
[<AllowNullLiteral>]
type CustomFieldValueResponse() =
member val Value:String = null with get,set
[<AllowNullLiteral>]
type CustomFieldConfigData() =
///<summary>
///Custom field id
///</summary>
[<ApiMember(Description="Custom field id")>]
member val Id:Int32 = new Int32() with get,set
///<summary>
///Configuration name. Example: 'Number of persons'.
///</summary>
[<ApiMember(Description="Configuration name. Example: 'Number of persons'.")>]
member val Name:String = null with 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?'")>]
member val Description:String = null with get,set
///<summary>
///Field width. Example: 20 for 20px
///</summary>
[<ApiMember(Description="Field width. Example: 20 for 20px")>]
member val Width:Nullable<Int32> = new Nullable<Int32>() with 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'")>]
member val DataType:String = null with get,set
///<summary>
///Default value of the field. Example: '3'
///</summary>
[<ApiMember(Description="Default value of the field. Example: '3'")>]
member val DefaultValue:String = null with 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")>]
member val IsMandatory:Boolean = new Boolean() with 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")>]
member val MandatoryErrorMessage:String = null with get,set
///<summary>
///Max lenght of the field
///</summary>
[<ApiMember(Description="Max lenght of the field")>]
member val MaxLength:Int32 = new Int32() with get,set
///<summary>
///If the field should have multiple lines
///</summary>
[<ApiMember(Description="If the field should have multiple lines")>]
member val MultipleLineText:Boolean = new Boolean() with get,set
///<summary>
///Regular expression used for validation of the field
///</summary>
[<ApiMember(Description="Regular expression used for validation of the field")>]
member val RegEx:String = null with get,set
///<summary>
///Error message shown if the regular expression validation failed
///</summary>
[<ApiMember(Description="Error message shown if the regular expression validation failed")>]
member val RegExErrorMessage:String = null with 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")>]
member val Values:ResizeArray<CustomFieldValueResponse> = new ResizeArray<CustomFieldValueResponse>() with get,set
[<AllowNullLiteral>]
type CustomFieldDataResponse() =
member val Id:Int32 = new Int32() with get,set
member val Column:String = null with get,set
member val Name:String = null with get,set
member val Description:String = null with get,set
member val Value:String = null with 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'")>]
member val DataType:String = null with get,set
[<AllowNullLiteral>]
type CustomerCommentsResponse() =
member val Id:Int32 = new Int32() with get,set
member val CustomerId:Guid = new Guid() with get,set
member val Comments:String = null with get,set
member val Updated:DateTime = new DateTime() with get,set
member val Created:DateTime = new DateTime() with get,set
member val ImageUrl:Uri = null with get,set
[<AllowNullLiteral>]
type BaseModel() =
class end
[<AllowNullLiteral>]
type UserAccessKeys() =
inherit BaseModel()
[<Required>]
member val CompanyId:Guid = new Guid() with get,set
[<Required>]
member val AccessKeyTypeId:Int32 = new Int32() with get,set
[<Required>]
member val Value:String = null with get,set
[<Required>]
member val CustomerId:Guid = new Guid() with get,set
member val Description:String = null with get,set
[<Required>]
member val Id:Guid = new Guid() with get,set
[<AllowNullLiteral>]
type InvoiceAddress() =
member val CorporateIdentityNumber:String = null with get,set
member val InvoiceAddress1:String = null with get,set
member val InvoiceAddress2:String = null with get,set
member val InvoiceCity:String = null with get,set
member val InvoicePostalCode:String = null with get,set
member val InvoiceCountryCode:String = null with get,set
[<AllowNullLiteral>]
type CustomerQueryResponse() =
member val Id:Guid = new Guid() with get,set
member val Firstname:String = null with get,set
member val Lastname:String = null with get,set
member val Email:String = null with get,set
member val Phone:String = null with get,set
member val ImageUrl:String = null with get,set
member val CustomFields:ResizeArray<CustomFieldConfigData> = new ResizeArray<CustomFieldConfigData>() with get,set
member val CustomFieldValues:ResizeArray<CustomFieldDataResponse> = new ResizeArray<CustomFieldDataResponse>() with get,set
member val Comments:ResizeArray<CustomerCommentsResponse> = new ResizeArray<CustomerCommentsResponse>() with get,set
member val AccessKeys:ResizeArray<UserAccessKeys> = new ResizeArray<UserAccessKeys>() with get,set
member val Updated:DateTime = new DateTime() with get,set
member val Created:DateTime = new DateTime() with get,set
member val ResponseStatus:Object = null with get,set
member val SubscribedToNewsletter:Boolean = new Boolean() with get,set
member val InvoiceAddress:InvoiceAddress = null with get,set
[<AllowNullLiteral>]
type UpdateCustomerResponse() =
inherit CustomerQueryResponse()
member val FacebookUserName:String = null with get,set
member val UserId:Nullable<Guid> = new Nullable<Guid>() with get,set
member val CompanyId:Nullable<Guid> = new Nullable<Guid>() with get,set
member val CreatedDate:Nullable<DateTime> = new Nullable<DateTime>() with get,set
member val DeletedAccessKeys:ResizeArray<UserAccessKeys> = new ResizeArray<UserAccessKeys>() with get,set
member val CreatedOrUpdatedAccessKeys:ResizeArray<UserAccessKeys> = new ResizeArray<UserAccessKeys>() with get,set
[<AllowNullLiteral>]
type AddCustomField() =
member val Id:Int32 = new Int32() with get,set
member val Value:String = null with get,set
[<AllowNullLiteral>]
type AddUserAccessKey() =
member val Id:Nullable<Guid> = new Nullable<Guid>() with get,set
member val CompanyId:Nullable<Guid> = new Nullable<Guid>() with get,set
member val AccessKeyTypeId:Int32 = new Int32() with get,set
member val Value:String = null with get,set
member val CustomerId:Nullable<Guid> = new Nullable<Guid>() with get,set
member val Description:String = null with 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(Validator="IsAuthenticated")>]
[<AllowNullLiteral>]
type CreateCustomer() =
///<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")>]
member val CompanyId:Nullable<Guid> = new Nullable<Guid>() with get,set
[<ApiMember(IsRequired=true)>]
member val Firstname:String = null with get,set
[<ApiMember(IsRequired=true)>]
member val Lastname:String = null with get,set
[<ApiMember(IsRequired=true)>]
member val Phone:String = null with get,set
[<ApiMember>]
member val Email:String = null with 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")>]
member val CustomFields:ResizeArray<AddCustomField> = new ResizeArray<AddCustomField>() with get,set
///<summary>
///List of Access Keys
///</summary>
[<ApiMember(Description="List of Access Keys")>]
member val AccessKeys:ResizeArray<AddUserAccessKey> = new ResizeArray<AddUserAccessKey>() with get,set
///<summary>
///Customer invoice adress
///</summary>
[<ApiMember(Description="Customer invoice adress")>]
member val InvoiceAddress:InvoiceAddress = null with get,set
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
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: text/jsv
Content-Type: text/jsv
Content-Length: length
{
CompanyId: 00000000-0000-0000-0000-000000000000,
Firstname: String,
Lastname: String,
Phone: String,
Email: String,
CustomFields:
[
{
Id: 0,
Value: String
}
],
AccessKeys:
[
{
Id: 00000000-0000-0000-0000-000000000000,
CompanyId: 00000000-0000-0000-0000-000000000000,
AccessKeyTypeId: 0,
Value: String,
CustomerId: 00000000-0000-0000-0000-000000000000,
Description: String
}
],
InvoiceAddress:
{
CorporateIdentityNumber: String,
InvoiceAddress1: String,
InvoiceAddress2: String,
InvoiceCity: String,
InvoicePostalCode: String,
InvoiceCountryCode: String
}
}
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { FacebookUserName: String, UserId: 00000000-0000-0000-0000-000000000000, CompanyId: 00000000-0000-0000-0000-000000000000, CreatedDate: "0001-01-01T00:00:00", DeletedAccessKeys: [ { AccessKeyTypeId: 0, Value: String, Description: String } ], CreatedOrUpdatedAccessKeys: [ { AccessKeyTypeId: 0, Value: String, Description: String } ], Firstname: String, Lastname: String, Email: String, Phone: String, ImageUrl: String, CustomFields: [ { "Id": 0, "Name": "String", "Description": "String", "Width": 0, "DataType": "String", "DefaultValue": "String", "IsMandatory": false, "MandatoryErrorMessage": "String", "MaxLength": 0, "MultipleLineText": false, "RegEx": "String", "RegExErrorMessage": "String", "Values": [ { "Value": "String" } ] } ], CustomFieldValues: [ { Id: 0, Column: String, Name: String, Description: String, Value: String, DataType: String } ], Comments: [ { Id: 0, Comments: String } ], AccessKeys: [ { AccessKeyTypeId: 0, Value: String, Description: String } ], ResponseStatus: {}, SubscribedToNewsletter: False, InvoiceAddress: { CorporateIdentityNumber: String, InvoiceAddress1: String, InvoiceAddress2: String, InvoiceCity: String, InvoicePostalCode: String, InvoiceCountryCode: String } }