Requires any of the roles: | bookingsupplier-administrator-write, superadmin |
PUT | /customfields/{Id} | Update 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. |
---|
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 CustomFieldLookupResponse:
id: Optional[int] = None
active: Optional[bool] = None
sort_order: Optional[int] = None
value: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomFieldServices:
id: int = 0
# @ApiMember(Description="Name of the service")
name: Optional[str] = None
"""
Name of the service
"""
# @ApiMember(Description="The image url of the service")
image_url: Optional[str] = None
"""
The image url of the service
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomFieldQueryResponse:
# @ApiMember(Description="Custom field id")
id: int = 0
"""
Custom field id
"""
# @ApiMember(Description="Reference to company that owns the custom field configuration")
company_id: Optional[str] = None
"""
Reference to company that owns the custom field configuration
"""
# @ApiMember(Description="Group id")
group_id: Optional[int] = None
"""
Group id
"""
# @ApiMember(Description="Field id")
field_id: int = 0
"""
Field id
"""
# @ApiMember(Description="Configuration name. Example: 'Number of persons'.")
name: Optional[str] = None
"""
Configuration name. Example: 'Number of persons'.
"""
# @ApiMember(Description="Field width. Example: 20")
width: int = 0
"""
Field width. Example: 20
"""
# @ApiMember(Description="Column in database where to store the information. Example: 'TextField1'")
column: Optional[str] = None
"""
Column in database where to store the information. Example: 'TextField1'
"""
# @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="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="Regular expression id for validation of the field")
reg_ex_id: Optional[int] = None
"""
Regular expression id 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="If the field is visible to the customer")
is_public: bool = False
"""
If the field is visible to the customer
"""
# @ApiMember(Description="If the field should be hidden in lists")
is_hidden: bool = False
"""
If the field should be hidden in lists
"""
# @ApiMember(Description="Table to which the field belongs")
table: Optional[str] = None
"""
Table to which the field belongs
"""
# @ApiMember(Description="The values to select from if Datatype is DropDown for this custom field")
values: Optional[List[CustomFieldLookupResponse]] = None
"""
The values to select from if Datatype is DropDown for this custom field
"""
# @ApiMember(Description="The services that is connected to the custom field")
services: Optional[List[CustomFieldServices]] = None
"""
The services that is connected to the custom field
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomFieldGroupValue:
sort_order: Optional[int] = None
value: 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 UpdateCustomField(ICompany):
# @ApiMember(Description="Custom field id", IsRequired=true, ParameterType="path")
id: int = 0
"""
Custom field id
"""
# @ApiMember(Description="The company id, if empty will use the company id for the user you are logged in with.")
company_id: Optional[str] = None
"""
The company id, if empty will use the company id for the user you are logged in with.
"""
# @ApiMember(Description="Group id")
group_id: Optional[int] = None
"""
Group id
"""
# @ApiMember(Description="Field id")
field_id: int = 0
"""
Field id
"""
# @ApiMember(Description="Configuration name. Example: 'Number of persons'.", IsRequired=true)
name: Optional[str] = None
"""
Configuration name. Example: 'Number of persons'.
"""
# @ApiMember(Description="Custom field description. Example: 'For how many persons is this booking?'", IsRequired=true)
description: Optional[str] = None
"""
Custom field description. Example: 'For how many persons is this booking?'
"""
# @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)
icon_id: int = 0
"""
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'
"""
# @ApiMember(Description="Field width. Example: 20")
width: int = 0
"""
Field width. Example: 20
"""
# @ApiMember(Description="Data field of custom field. Valid values are: TextBox, DropDown Example: 'TextBox'")
datatype: Optional[str] = None
"""
Data field of custom field. Valid values are: TextBox, DropDown 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. Default is false")
is_mandatory: Optional[bool] = None
"""
Determines if the field is required to have a value or not. Default is false
"""
# @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. Default is 500", IsRequired=true)
max_length: int = 0
"""
Max lenght of the field. Default is 500
"""
# @ApiMember(Description="If the field should have multiple lines. Defualt is false")
multiple_line_text: Optional[bool] = None
"""
If the field should have multiple lines. Defualt is false
"""
# @ApiMember(Description="Regular expression used for validation of the field")
reg_ex_id: Optional[int] = 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="If the field is visible to the customer. Default is true")
is_public: Optional[bool] = None
"""
If the field is visible to the customer. Default is true
"""
# @ApiMember(Description="If the field should be hidden in lists. Default is false")
is_hidden: Optional[bool] = None
"""
If the field should be hidden in lists. Default is false
"""
# @ApiMember(Description="The values to select from if Datatype is DropDown for this custom field")
values: Optional[List[CustomFieldGroupValue]] = None
"""
The values to select from if Datatype is DropDown for this custom field
"""
# @ApiMember(Description="The services that is connected to the custom field. If null it will be connected to all services.")
services: Optional[List[CustomFieldServices]] = None
"""
The services that is connected to the custom field. If null it will be connected to all services.
"""
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.
PUT /customfields/{Id} HTTP/1.1
Host: api.bokamera.se
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
Id: 0,
CompanyId: 00000000-0000-0000-0000-000000000000,
GroupId: 0,
FieldId: 0,
Name: String,
Description: String,
IconId: 0,
Width: 0,
Datatype: String,
DefaultValue: String,
IsMandatory: False,
MandatoryErrorMessage: String,
MaxLength: 0,
MultipleLineText: False,
RegExId: 0,
RegExErrorMessage: String,
IsPublic: False,
IsHidden: False,
Values:
[
{
SortOrder: 0,
Value: String
}
],
Services:
[
{
Id: 0,
Name: String
}
]
}
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { Id: 0, GroupId: 0, FieldId: 0, Name: String, Width: 0, Column: String, Description: String, DataType: String, DefaultValue: String, IsMandatory: False, MandatoryErrorMessage: String, MaxLength: 0, MultipleLineText: False, RegEx: String, RegExId: 0, RegExErrorMessage: String, IsPublic: False, IsHidden: False, Table: String, Values: [ { Id: 0, Active: False, SortOrder: 0, Value: String } ], Services: [ { Id: 0, Name: String } ] }