BokaMera.API.Host

<back to all web services

CreateCustomField

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
POST/customfieldsCreate a custom fieldCreates a new custom field, if an admin user is making the request, the user will be associated with the admin user's company.
import 'package:servicestack/servicestack.dart';

class CustomFieldLookupResponse implements IConvertible
{
    int? Id;
    bool? Active;
    int? SortOrder;
    String? Value;

    CustomFieldLookupResponse({this.Id,this.Active,this.SortOrder,this.Value});
    CustomFieldLookupResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        Id = json['Id'];
        Active = json['Active'];
        SortOrder = json['SortOrder'];
        Value = json['Value'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'Id': Id,
        'Active': Active,
        'SortOrder': SortOrder,
        'Value': Value
    };

    getTypeName() => "CustomFieldLookupResponse";
    TypeContext? context = _ctx;
}

class CustomFieldServices implements IConvertible
{
    int? Id;
    /**
    * Name of the service
    */
    // @ApiMember(Description="Name of the service")
    String? Name;

    /**
    * The image url of the service
    */
    // @ApiMember(Description="The image url of the service")
    Uri? ImageUrl;

    CustomFieldServices({this.Id,this.Name,this.ImageUrl});
    CustomFieldServices.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        Id = json['Id'];
        Name = json['Name'];
        ImageUrl = JsonConverters.fromJson(json['ImageUrl'],'Uri',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'Id': Id,
        'Name': Name,
        'ImageUrl': JsonConverters.toJson(ImageUrl,'Uri',context!)
    };

    getTypeName() => "CustomFieldServices";
    TypeContext? context = _ctx;
}

class CustomFieldQueryResponse implements IConvertible
{
    /**
    * Custom field id
    */
    // @ApiMember(Description="Custom field id")
    int? Id;

    /**
    * Reference to company that owns the custom field configuration
    */
    // @ApiMember(Description="Reference to company that owns the custom field configuration")
    String? CompanyId;

    /**
    * Group id
    */
    // @ApiMember(Description="Group id")
    int? GroupId;

    /**
    * Field id
    */
    // @ApiMember(Description="Field id")
    int? FieldId;

    /**
    * Configuration name. Example: 'Number of persons'.
    */
    // @ApiMember(Description="Configuration name. Example: 'Number of persons'.")
    String? Name;

    /**
    * Field width. Example: 20
    */
    // @ApiMember(Description="Field width. Example: 20")
    int? Width;

    /**
    * Column in database where to store the information. Example: 'TextField1'
    */
    // @ApiMember(Description="Column in database where to store the information. Example: 'TextField1'")
    String? Column;

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

    /**
    * Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'
    */
    // @ApiMember(Description="Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'")
    String? DataType;

    /**
    * Default value of the field. Example: '3'
    */
    // @ApiMember(Description="Default value of the field. Example: '3'")
    String? DefaultValue;

    /**
    * 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")
    bool? IsMandatory;

    /**
    * 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")
    String? MandatoryErrorMessage;

    /**
    * Max lenght of the field
    */
    // @ApiMember(Description="Max lenght of the field")
    int? MaxLength;

    /**
    * If the field should have multiple lines
    */
    // @ApiMember(Description="If the field should have multiple lines")
    bool? MultipleLineText;

    /**
    * Regular expression used for validation of the field
    */
    // @ApiMember(Description="Regular expression used for validation of the field")
    String? RegEx;

    /**
    * Regular expression id for validation of the field
    */
    // @ApiMember(Description="Regular expression id for validation of the field")
    int? RegExId;

    /**
    * Error message shown if the regular expression validation failed
    */
    // @ApiMember(Description="Error message shown if the regular expression validation failed")
    String? RegExErrorMessage;

    /**
    * If the field is visible to the customer
    */
    // @ApiMember(Description="If the field is visible to the customer")
    bool? IsPublic;

    /**
    * If the field should be hidden in lists
    */
    // @ApiMember(Description="If the field should be hidden in lists")
    bool? IsHidden;

    /**
    * Table to which the field belongs
    */
    // @ApiMember(Description="Table to which the field belongs")
    String? Table;

    /**
    * 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")
    List<CustomFieldLookupResponse>? Values;

    /**
    * The services that is connected to the custom field
    */
    // @ApiMember(Description="The services that is connected to the custom field")
    List<CustomFieldServices>? Services;

    CustomFieldQueryResponse({this.Id,this.CompanyId,this.GroupId,this.FieldId,this.Name,this.Width,this.Column,this.Description,this.DataType,this.DefaultValue,this.IsMandatory,this.MandatoryErrorMessage,this.MaxLength,this.MultipleLineText,this.RegEx,this.RegExId,this.RegExErrorMessage,this.IsPublic,this.IsHidden,this.Table,this.Values,this.Services});
    CustomFieldQueryResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        Id = json['Id'];
        CompanyId = json['CompanyId'];
        GroupId = json['GroupId'];
        FieldId = json['FieldId'];
        Name = json['Name'];
        Width = json['Width'];
        Column = json['Column'];
        Description = json['Description'];
        DataType = json['DataType'];
        DefaultValue = json['DefaultValue'];
        IsMandatory = json['IsMandatory'];
        MandatoryErrorMessage = json['MandatoryErrorMessage'];
        MaxLength = json['MaxLength'];
        MultipleLineText = json['MultipleLineText'];
        RegEx = json['RegEx'];
        RegExId = json['RegExId'];
        RegExErrorMessage = json['RegExErrorMessage'];
        IsPublic = json['IsPublic'];
        IsHidden = json['IsHidden'];
        Table = json['Table'];
        Values = JsonConverters.fromJson(json['Values'],'List<CustomFieldLookupResponse>',context!);
        Services = JsonConverters.fromJson(json['Services'],'List<CustomFieldServices>',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'Id': Id,
        'CompanyId': CompanyId,
        'GroupId': GroupId,
        'FieldId': FieldId,
        'Name': Name,
        'Width': Width,
        'Column': Column,
        'Description': Description,
        'DataType': DataType,
        'DefaultValue': DefaultValue,
        'IsMandatory': IsMandatory,
        'MandatoryErrorMessage': MandatoryErrorMessage,
        'MaxLength': MaxLength,
        'MultipleLineText': MultipleLineText,
        'RegEx': RegEx,
        'RegExId': RegExId,
        'RegExErrorMessage': RegExErrorMessage,
        'IsPublic': IsPublic,
        'IsHidden': IsHidden,
        'Table': Table,
        'Values': JsonConverters.toJson(Values,'List<CustomFieldLookupResponse>',context!),
        'Services': JsonConverters.toJson(Services,'List<CustomFieldServices>',context!)
    };

    getTypeName() => "CustomFieldQueryResponse";
    TypeContext? context = _ctx;
}

class CustomFieldGroupValue implements IConvertible
{
    int? SortOrder;
    String? Value;

    CustomFieldGroupValue({this.SortOrder,this.Value});
    CustomFieldGroupValue.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        SortOrder = json['SortOrder'];
        Value = json['Value'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'SortOrder': SortOrder,
        'Value': Value
    };

    getTypeName() => "CustomFieldGroupValue";
    TypeContext? context = _ctx;
}

// @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")
class CreateCustomField implements ICompany, IConvertible
{
    /**
    * The company id, if empty will use the company id for the user you are logged in with.
    */
    // @ApiMember(Description="The company id, if empty will use the company id for the user you are logged in with.")
    String? CompanyId;

    /**
    * Field id
    */
    // @ApiMember(Description="Field id")
    int? FieldId;

    /**
    * Configuration name. Example: 'Number of persons'.
    */
    // @ApiMember(Description="Configuration name. Example: 'Number of persons'.", IsRequired=true)
    String? Name;

    /**
    * Custom field description. Example: 'For how many persons is this booking?'
    */
    // @ApiMember(Description="Custom field description. Example: 'For how many persons is this booking?'", IsRequired=true)
    String? 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'
    */
    // @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)
    int? IconId;

    /**
    * Field width. Example: 20
    */
    // @ApiMember(Description="Field width. Example: 20")
    int? Width;

    /**
    * Data field of custom field. Valid values are: TextBox, DropDown Example: 'TextBox'
    */
    // @ApiMember(Description="Data field of custom field. Valid values are: TextBox, DropDown Example: 'TextBox'")
    String? Datatype;

    /**
    * Default value of the field. Example: '3'
    */
    // @ApiMember(Description="Default value of the field. Example: '3'")
    String? DefaultValue;

    /**
    * Determines if the field is required to have a value or not. Default is false
    */
    // @ApiMember(Description="Determines if the field is required to have a value or not. Default is false")
    bool? IsMandatory;

    /**
    * 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")
    String? MandatoryErrorMessage;

    /**
    * Max lenght of the field. Default is 500
    */
    // @ApiMember(Description="Max lenght of the field. Default is 500", IsRequired=true)
    int? MaxLength;

    /**
    * If the field should have multiple lines. Defualt is false
    */
    // @ApiMember(Description="If the field should have multiple lines. Defualt is false")
    bool? MultipleLineText;

    /**
    * Regular expression used for validation of the field
    */
    // @ApiMember(Description="Regular expression used for validation of the field")
    int? RegExId;

    /**
    * Error message shown if the regular expression validation failed
    */
    // @ApiMember(Description="Error message shown if the regular expression validation failed")
    String? RegExErrorMessage;

    /**
    * If the field is visible to the customer. Default is true
    */
    // @ApiMember(Description="If the field is visible to the customer. Default is true")
    bool? IsPublic;

    /**
    * If the field should be hidden in lists. Default is false
    */
    // @ApiMember(Description="If the field should be hidden in lists. Default is false")
    bool? IsHidden;

    /**
    * 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")
    List<CustomFieldGroupValue>? Values;

    /**
    * The services that is connected to the custom field. If null it will be connected to all services.
    */
    // @ApiMember(Description="The services that is connected to the custom field. If null it will be connected to all services.")
    List<CustomFieldServices>? Services;

    CreateCustomField({this.CompanyId,this.FieldId,this.Name,this.Description,this.IconId,this.Width,this.Datatype,this.DefaultValue,this.IsMandatory,this.MandatoryErrorMessage,this.MaxLength,this.MultipleLineText,this.RegExId,this.RegExErrorMessage,this.IsPublic,this.IsHidden,this.Values,this.Services});
    CreateCustomField.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        CompanyId = json['CompanyId'];
        FieldId = json['FieldId'];
        Name = json['Name'];
        Description = json['Description'];
        IconId = json['IconId'];
        Width = json['Width'];
        Datatype = json['Datatype'];
        DefaultValue = json['DefaultValue'];
        IsMandatory = json['IsMandatory'];
        MandatoryErrorMessage = json['MandatoryErrorMessage'];
        MaxLength = json['MaxLength'];
        MultipleLineText = json['MultipleLineText'];
        RegExId = json['RegExId'];
        RegExErrorMessage = json['RegExErrorMessage'];
        IsPublic = json['IsPublic'];
        IsHidden = json['IsHidden'];
        Values = JsonConverters.fromJson(json['Values'],'List<CustomFieldGroupValue>',context!);
        Services = JsonConverters.fromJson(json['Services'],'List<CustomFieldServices>',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'CompanyId': CompanyId,
        'FieldId': FieldId,
        'Name': Name,
        'Description': Description,
        'IconId': IconId,
        'Width': Width,
        'Datatype': Datatype,
        'DefaultValue': DefaultValue,
        'IsMandatory': IsMandatory,
        'MandatoryErrorMessage': MandatoryErrorMessage,
        'MaxLength': MaxLength,
        'MultipleLineText': MultipleLineText,
        'RegExId': RegExId,
        'RegExErrorMessage': RegExErrorMessage,
        'IsPublic': IsPublic,
        'IsHidden': IsHidden,
        'Values': JsonConverters.toJson(Values,'List<CustomFieldGroupValue>',context!),
        'Services': JsonConverters.toJson(Services,'List<CustomFieldServices>',context!)
    };

    getTypeName() => "CreateCustomField";
    TypeContext? context = _ctx;
}

TypeContext _ctx = TypeContext(library: 'api.bokamera.se', types: <String, TypeInfo> {
    'CustomFieldLookupResponse': TypeInfo(TypeOf.Class, create:() => CustomFieldLookupResponse()),
    'CustomFieldServices': TypeInfo(TypeOf.Class, create:() => CustomFieldServices()),
    'Uri': TypeInfo(TypeOf.Class, create:() => Uri()),
    'CustomFieldQueryResponse': TypeInfo(TypeOf.Class, create:() => CustomFieldQueryResponse()),
    'List<CustomFieldLookupResponse>': TypeInfo(TypeOf.Class, create:() => <CustomFieldLookupResponse>[]),
    'List<CustomFieldServices>': TypeInfo(TypeOf.Class, create:() => <CustomFieldServices>[]),
    'CustomFieldGroupValue': TypeInfo(TypeOf.Class, create:() => CustomFieldGroupValue()),
    'CreateCustomField': TypeInfo(TypeOf.Class, create:() => CreateCustomField()),
    'List<CustomFieldGroupValue>': TypeInfo(TypeOf.Class, create:() => <CustomFieldGroupValue>[]),
});

Dart CreateCustomField DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv

HTTP + JSV

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: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	CompanyId: 00000000-0000-0000-0000-000000000000,
	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
		}
	]
}