Requires any of the roles: | bookingsupplier-administrator-write, superadmin |
POST | /customfields | Create a custom field | Creates a new custom field, if an admin user is making the request, the user will be associated with the admin user's company. |
---|
Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Runtime.Serialization
Imports ServiceStack
Imports ServiceStack.DataAnnotations
Imports BokaMera.API.ServiceModel.Dtos
Namespace Global
Namespace BokaMera.API.ServiceModel.Dtos
<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 Partial Class CreateCustomField
Implements ICompany
Public Sub New()
Values = New List(Of CustomFieldGroupValue)
Services = New List(Of CustomFieldServices)
End Sub
'''<Summary>
'''The company id, if empty will use the company id for the user you are logged in with.
'''</Summary>
<ApiMember(Description:="The company id, if empty will use the company id for the user you are logged in with.")>
Public Overridable Property CompanyId As Nullable(Of Guid)
'''<Summary>
'''Field id
'''</Summary>
<ApiMember(Description:="Field id")>
Public Overridable Property FieldId As Integer
'''<Summary>
'''Configuration name. Example: 'Number of persons'.
'''</Summary>
<ApiMember(Description:="Configuration name. Example: 'Number of persons'.", IsRequired:=true)>
Public Overridable Property Name As String
'''<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?'", IsRequired:=true)>
Public Overridable Property Description As String
'''<Summary>
'''Custom field icon id. Example: '1 House,2 Calendar,3 Building,4 Cart,5 Find,6 Blue flag,7 Green flag,8 Information,9 Lightning,10 Page edit,11 Pencil,12 Link,13 Star,14 User,15 Tick,16 Wrench,17 Clock'
'''</Summary>
<ApiMember(Description:="Custom field icon id. Example: '1 House,2 Calendar,3 Building,4 Cart,5 Find,6 Blue flag,7 Green flag,8 Information,9 Lightning,10 Page edit,11 Pencil,12 Link,13 Star,14 User,15 Tick,16 Wrench,17 Clock'", IsRequired:=true)>
Public Overridable Property IconId As Integer
'''<Summary>
'''Field width. Example: 20
'''</Summary>
<ApiMember(Description:="Field width. Example: 20")>
Public Overridable Property Width As Integer
'''<Summary>
'''Data field of custom field. Valid values are: TextBox, DropDown Example: 'TextBox'
'''</Summary>
<ApiMember(Description:="Data field of custom field. Valid values are: TextBox, DropDown Example: 'TextBox'")>
Public Overridable Property Datatype As String
'''<Summary>
'''Default value of the field. Example: '3'
'''</Summary>
<ApiMember(Description:="Default value of the field. Example: '3'")>
Public Overridable Property DefaultValue As String
'''<Summary>
'''Determines if the field is required to have a value or not. Default is false
'''</Summary>
<ApiMember(Description:="Determines if the field is required to have a value or not. Default is false")>
Public Overridable Property IsMandatory As Boolean
'''<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 Overridable Property MandatoryErrorMessage As String
'''<Summary>
'''Max lenght of the field. Default is 500
'''</Summary>
<ApiMember(Description:="Max lenght of the field. Default is 500", IsRequired:=true)>
Public Overridable Property MaxLength As Integer
'''<Summary>
'''If the field should have multiple lines. Defualt is false
'''</Summary>
<ApiMember(Description:="If the field should have multiple lines. Defualt is false")>
Public Overridable Property MultipleLineText As Boolean
'''<Summary>
'''Regular expression used for validation of the field
'''</Summary>
<ApiMember(Description:="Regular expression used for validation of the field")>
Public Overridable Property RegExId As Nullable(Of Integer)
'''<Summary>
'''Error message shown if the regular expression validation failed
'''</Summary>
<ApiMember(Description:="Error message shown if the regular expression validation failed")>
Public Overridable Property RegExErrorMessage As String
'''<Summary>
'''If the field is visible to the customer. Default is true
'''</Summary>
<ApiMember(Description:="If the field is visible to the customer. Default is true")>
Public Overridable Property IsPublic As Boolean
'''<Summary>
'''If the field should be hidden in lists. Default is false
'''</Summary>
<ApiMember(Description:="If the field should be hidden in lists. Default is false")>
Public Overridable Property IsHidden As Boolean
'''<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 Overridable Property Values As List(Of CustomFieldGroupValue)
'''<Summary>
'''The services that is connected to the custom field. If null it will be connected to all services.
'''</Summary>
<ApiMember(Description:="The services that is connected to the custom field. If null it will be connected to all services.")>
Public Overridable Property Services As List(Of CustomFieldServices)
End Class
Public Partial Class CustomFieldGroupValue
Public Overridable Property SortOrder As Nullable(Of Short)
Public Overridable Property Value As String
End Class
Public Partial Class CustomFieldLookupResponse
Public Overridable Property Id As Nullable(Of Integer)
Public Overridable Property Active As Nullable(Of Boolean)
Public Overridable Property SortOrder As Nullable(Of Integer)
Public Overridable Property Value As String
End Class
Public Partial Class CustomFieldQueryResponse
Public Sub New()
Values = New List(Of CustomFieldLookupResponse)
Services = New List(Of CustomFieldServices)
End Sub
'''<Summary>
'''Custom field id
'''</Summary>
<ApiMember(Description:="Custom field id")>
Public Overridable Property Id As Integer
'''<Summary>
'''Reference to company that owns the custom field configuration
'''</Summary>
<ApiMember(Description:="Reference to company that owns the custom field configuration")>
Public Overridable Property CompanyId As Guid
'''<Summary>
'''Group id
'''</Summary>
<ApiMember(Description:="Group id")>
Public Overridable Property GroupId As Nullable(Of Integer)
'''<Summary>
'''Field id
'''</Summary>
<ApiMember(Description:="Field id")>
Public Overridable Property FieldId As Integer
'''<Summary>
'''Configuration name. Example: 'Number of persons'.
'''</Summary>
<ApiMember(Description:="Configuration name. Example: 'Number of persons'.")>
Public Overridable Property Name As String
'''<Summary>
'''Field width. Example: 20
'''</Summary>
<ApiMember(Description:="Field width. Example: 20")>
Public Overridable Property Width As Integer
'''<Summary>
'''Column in database where to store the information. Example: 'TextField1'
'''</Summary>
<ApiMember(Description:="Column in database where to store the information. Example: 'TextField1'")>
Public Overridable Property Column As String
'''<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 Overridable Property Description As String
'''<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 Overridable Property DataType As String
'''<Summary>
'''Default value of the field. Example: '3'
'''</Summary>
<ApiMember(Description:="Default value of the field. Example: '3'")>
Public Overridable Property DefaultValue As String
'''<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 Overridable Property IsMandatory As Boolean
'''<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 Overridable Property MandatoryErrorMessage As String
'''<Summary>
'''Max lenght of the field
'''</Summary>
<ApiMember(Description:="Max lenght of the field")>
Public Overridable Property MaxLength As Integer
'''<Summary>
'''If the field should have multiple lines
'''</Summary>
<ApiMember(Description:="If the field should have multiple lines")>
Public Overridable Property MultipleLineText As Boolean
'''<Summary>
'''Regular expression used for validation of the field
'''</Summary>
<ApiMember(Description:="Regular expression used for validation of the field")>
Public Overridable Property RegEx As String
'''<Summary>
'''Regular expression id for validation of the field
'''</Summary>
<ApiMember(Description:="Regular expression id for validation of the field")>
Public Overridable Property RegExId As Nullable(Of Integer)
'''<Summary>
'''Error message shown if the regular expression validation failed
'''</Summary>
<ApiMember(Description:="Error message shown if the regular expression validation failed")>
Public Overridable Property RegExErrorMessage As String
'''<Summary>
'''If the field is visible to the customer
'''</Summary>
<ApiMember(Description:="If the field is visible to the customer")>
Public Overridable Property IsPublic As Boolean
'''<Summary>
'''If the field should be hidden in lists
'''</Summary>
<ApiMember(Description:="If the field should be hidden in lists")>
Public Overridable Property IsHidden As Boolean
'''<Summary>
'''Table to which the field belongs
'''</Summary>
<ApiMember(Description:="Table to which the field belongs")>
Public Overridable Property Table As String
'''<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 Overridable Property Values As List(Of CustomFieldLookupResponse)
'''<Summary>
'''The services that is connected to the custom field
'''</Summary>
<ApiMember(Description:="The services that is connected to the custom field")>
Public Overridable Property Services As List(Of CustomFieldServices)
End Class
Public Partial Class CustomFieldServices
Public Overridable Property Id As Integer
'''<Summary>
'''Name of the service
'''</Summary>
<ApiMember(Description:="Name of the service")>
Public Overridable Property Name As String
'''<Summary>
'''The image url of the service
'''</Summary>
<ApiMember(Description:="The image url of the service")>
Public Overridable Property ImageUrl As Uri
End Class
End Namespace
End Namespace
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 /customfields HTTP/1.1
Host: api.bokamera.se
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<CreateCustomField xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
<CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
<Datatype>String</Datatype>
<DefaultValue>String</DefaultValue>
<Description>String</Description>
<FieldId>0</FieldId>
<IconId>0</IconId>
<IsHidden>false</IsHidden>
<IsMandatory>false</IsMandatory>
<IsPublic>false</IsPublic>
<MandatoryErrorMessage>String</MandatoryErrorMessage>
<MaxLength>0</MaxLength>
<MultipleLineText>false</MultipleLineText>
<Name>String</Name>
<RegExErrorMessage>String</RegExErrorMessage>
<RegExId>0</RegExId>
<Services>
<CustomFieldServices>
<Id>0</Id>
<ImageUrl i:nil="true" />
<Name>String</Name>
</CustomFieldServices>
</Services>
<Values>
<CustomFieldGroupValue>
<SortOrder>0</SortOrder>
<Value>String</Value>
</CustomFieldGroupValue>
</Values>
<Width>0</Width>
</CreateCustomField>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <CustomFieldQueryResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos"> <Column>String</Column> <CompanyId>00000000-0000-0000-0000-000000000000</CompanyId> <DataType>String</DataType> <DefaultValue>String</DefaultValue> <Description>String</Description> <FieldId>0</FieldId> <GroupId>0</GroupId> <Id>0</Id> <IsHidden>false</IsHidden> <IsMandatory>false</IsMandatory> <IsPublic>false</IsPublic> <MandatoryErrorMessage>String</MandatoryErrorMessage> <MaxLength>0</MaxLength> <MultipleLineText>false</MultipleLineText> <Name>String</Name> <RegEx>String</RegEx> <RegExErrorMessage>String</RegExErrorMessage> <RegExId>0</RegExId> <Services> <CustomFieldServices> <Id>0</Id> <ImageUrl i:nil="true" /> <Name>String</Name> </CustomFieldServices> </Services> <Table>String</Table> <Values> <CustomFieldLookupResponse> <Active>false</Active> <Id>0</Id> <SortOrder>0</SortOrder> <Value>String</Value> </CustomFieldLookupResponse> </Values> <Width>0</Width> </CustomFieldQueryResponse>