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. |
---|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using ServiceStack;
using ServiceStack.DataAnnotations;
using BokaMera.API.ServiceModel.Dtos;
namespace BokaMera.API.ServiceModel.Dtos
{
public partial class CustomFieldGroupValue
{
public virtual short? SortOrder { get; set; }
public virtual string Value { get; set; }
}
public partial class CustomFieldLookupResponse
{
public virtual int? Id { get; set; }
public virtual bool? Active { get; set; }
public virtual int? SortOrder { get; set; }
public virtual string Value { get; set; }
}
public partial class CustomFieldQueryResponse
{
public CustomFieldQueryResponse()
{
Values = new List<CustomFieldLookupResponse>{};
Services = new List<CustomFieldServices>{};
}
///<summary>
///Custom field id
///</summary>
[ApiMember(Description="Custom field id")]
public virtual int Id { get; set; }
///<summary>
///Reference to company that owns the custom field configuration
///</summary>
[ApiMember(Description="Reference to company that owns the custom field configuration")]
public virtual Guid CompanyId { get; set; }
///<summary>
///Group id
///</summary>
[ApiMember(Description="Group id")]
public virtual int? GroupId { get; set; }
///<summary>
///Field id
///</summary>
[ApiMember(Description="Field id")]
public virtual int FieldId { 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>
///Field width. Example: 20
///</summary>
[ApiMember(Description="Field width. Example: 20")]
public virtual int Width { get; set; }
///<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 virtual string Column { 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>
///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>
///Regular expression id for validation of the field
///</summary>
[ApiMember(Description="Regular expression id for validation of the field")]
public virtual int? RegExId { 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>
///If the field is visible to the customer
///</summary>
[ApiMember(Description="If the field is visible to the customer")]
public virtual bool IsPublic { get; set; }
///<summary>
///If the field should be hidden in lists
///</summary>
[ApiMember(Description="If the field should be hidden in lists")]
public virtual bool IsHidden { get; set; }
///<summary>
///Table to which the field belongs
///</summary>
[ApiMember(Description="Table to which the field belongs")]
public virtual string Table { 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<CustomFieldLookupResponse> Values { get; set; }
///<summary>
///The services that is connected to the custom field
///</summary>
[ApiMember(Description="The services that is connected to the custom field")]
public virtual List<CustomFieldServices> Services { get; set; }
}
public partial class CustomFieldServices
{
public virtual int Id { get; set; }
///<summary>
///Name of the service
///</summary>
[ApiMember(Description="Name of the service")]
public virtual string Name { get; set; }
///<summary>
///The image url of the service
///</summary>
[ApiMember(Description="The image url of the service")]
public virtual Uri ImageUrl { 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 UpdateCustomField
: ICompany
{
public UpdateCustomField()
{
Values = new List<CustomFieldGroupValue>{};
Services = new List<CustomFieldServices>{};
}
///<summary>
///Custom field id
///</summary>
[ApiMember(Description="Custom field id", IsRequired=true, ParameterType="path")]
public virtual int Id { get; set; }
///<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 virtual Guid? CompanyId { get; set; }
///<summary>
///Group id
///</summary>
[ApiMember(Description="Group id")]
public virtual int? GroupId { get; set; }
///<summary>
///Field id
///</summary>
[ApiMember(Description="Field id")]
public virtual int FieldId { get; set; }
///<summary>
///Configuration name. Example: 'Number of persons'.
///</summary>
[ApiMember(Description="Configuration name. Example: 'Number of persons'.", IsRequired=true)]
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?'", IsRequired=true)]
public virtual string Description { get; set; }
///<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 virtual int IconId { get; set; }
///<summary>
///Field width. Example: 20
///</summary>
[ApiMember(Description="Field width. Example: 20")]
public virtual int Width { get; set; }
///<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 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. Default is false
///</summary>
[ApiMember(Description="Determines if the field is required to have a value or not. Default is false")]
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. Default is 500
///</summary>
[ApiMember(Description="Max lenght of the field. Default is 500", IsRequired=true)]
public virtual int MaxLength { get; set; }
///<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 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 int? RegExId { 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>
///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 virtual bool? IsPublic { get; set; }
///<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 virtual bool? IsHidden { 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<CustomFieldGroupValue> Values { get; set; }
///<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 virtual List<CustomFieldServices> Services { 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.
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 } ] }