BokaMera.API.Host

<back to all web services

AddTagsToCustomer

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
POST/customers/{CustomerId}/tagsAdd tags to a customerAttaches one or more tags to an existing customer.
import Foundation
import ServiceStack

// @ApiResponse(Description="Returned if a tag does not belong to this company or has the wrong scope", StatusCode=400)
// @ApiResponse(Description="Returned if the customer was not found", StatusCode=404)
// @ApiResponse(Description="Returned if the current user is not allowed to perform the action", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
public class AddTagsToCustomer : ICompany, Codable
{
    /**
    * 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.")
    public var companyId:String?

    /**
    * The customer id.
    */
    // @ApiMember(Description="The customer id.", IsRequired=true, ParameterType="path")
    public var customerId:String

    /**
    * The ids of the tags to attach.
    */
    // @ApiMember(Description="The ids of the tags to attach.", IsRequired=true)
    public var tagIds:[Int] = []

    required public init(){}
}

public class CustomerQueryResponse : Codable
{
    public var id:String
    public var firstname:String
    public var lastname:String
    public var email:String
    public var phone:String
    public var imageUrl:String
    public var personalIdentityNumber:String
    public var customFields:[CustomFieldConfigData] = []
    public var customFieldValues:[CustomFieldDataResponse] = []
    public var comments:[CustomerCommentsResponse] = []
    public var accessKeys:[UserAccessKeys] = []
    public var updated:Date
    public var created:Date
    public var responseStatus:String
    public var subscribedToNewsletter:Bool
    public var invoiceAddress:InvoiceAddressResponse
    public var tags:[TagResponse] = []

    required public init(){}
}

public class CustomFieldConfigData : Codable
{
    /**
    * Custom field id
    */
    // @ApiMember(Description="Custom field id")
    public var id:Int

    /**
    * Configuration name. Example: 'Number of persons'.
    */
    // @ApiMember(Description="Configuration name. Example: 'Number of persons'.")
    public var name:String

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

    /**
    * Field width. Example: 20 for 20px
    */
    // @ApiMember(Description="Field width. Example: 20 for 20px")
    public var width:Int?

    /**
    * Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'
    */
    // @ApiMember(Description="Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'")
    public var dataType:String

    /**
    * Default value of the field. Example: '3'
    */
    // @ApiMember(Description="Default value of the field. Example: '3'")
    public var defaultValue:String

    /**
    * 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")
    public var isMandatory:Bool

    /**
    * 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")
    public var mandatoryErrorMessage:String

    /**
    * Max lenght of the field
    */
    // @ApiMember(Description="Max lenght of the field")
    public var maxLength:Int

    /**
    * If the field should have multiple lines
    */
    // @ApiMember(Description="If the field should have multiple lines")
    public var multipleLineText:Bool

    /**
    * Regular expression used for validation of the field
    */
    // @ApiMember(Description="Regular expression used for validation of the field")
    public var regEx:String

    /**
    * Error message shown if the regular expression validation failed
    */
    // @ApiMember(Description="Error message shown if the regular expression validation failed")
    public var regExErrorMessage:String

    /**
    * 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")
    public var values:[CustomFieldValueResponse] = []

    required public init(){}
}

public class CustomFieldValueResponse : Codable
{
    public var value:String

    required public init(){}
}

public class CustomFieldDataResponse : Codable
{
    public var id:Int
    public var column:String
    public var name:String
    public var Description:String
    public var value:String
    /**
    * Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'
    */
    // @ApiMember(Description="Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'")
    public var dataType:String

    required public init(){}
}

public class CustomerCommentsResponse : Codable
{
    public var id:Int
    public var customerId:String
    public var comments:String
    public var updated:Date
    public var created:Date
    public var imageUrl:Uri

    required public init(){}
}

public class UserAccessKeys : BaseModel
{
    // @Required()
    public var companyId:String?

    // @Required()
    public var accessKeyTypeId:Int?

    // @Required()
    public var value:String?

    // @Required()
    public var customerId:String?

    public var Description:String
    // @Required()
    public var id:String?

    required public init(){ super.init() }

    private enum CodingKeys : String, CodingKey {
        case companyId
        case accessKeyTypeId
        case value
        case customerId
        case Description
        case id
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        companyId = try container.decodeIfPresent(String.self, forKey: .companyId)
        accessKeyTypeId = try container.decodeIfPresent(Int.self, forKey: .accessKeyTypeId)
        value = try container.decodeIfPresent(String.self, forKey: .value)
        customerId = try container.decodeIfPresent(String.self, forKey: .customerId)
        Description = try container.decodeIfPresent(String.self, forKey: .Description)
        id = try container.decodeIfPresent(String.self, forKey: .id)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if companyId != nil { try container.encode(companyId, forKey: .companyId) }
        if accessKeyTypeId != nil { try container.encode(accessKeyTypeId, forKey: .accessKeyTypeId) }
        if value != nil { try container.encode(value, forKey: .value) }
        if customerId != nil { try container.encode(customerId, forKey: .customerId) }
        if Description != nil { try container.encode(Description, forKey: .Description) }
        if id != nil { try container.encode(id, forKey: .id) }
    }
}

public class BaseModel : Codable
{
    required public init(){}
}

public class InvoiceAddressResponse : Codable
{
    public var invoiceAddressId:String
    public var userId:String?
    public var corporateIdentityNumber:String
    public var invoiceAddress1:String
    public var invoiceAddress2:String
    public var invoiceCity:String
    public var invoicePostalCode:String
    public var invoiceCountryCode:String

    required public init(){}
}

public class TagResponse : Codable
{
    public var id:Int
    public var companyId:String
    public var name:String
    public var scope:Int
    public var color:String
    public var sortOrder:Int
    public var active:Bool
    public var createdDate:Date
    public var responseStatus:ResponseStatus

    required public init(){}
}


Swift AddTagsToCustomer DTOs

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

To embed the response in a jsonp callback, append ?callback=myCallback

HTTP + JSON

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /customers/{CustomerId}/tags HTTP/1.1 
Host: api.bookmore.com 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"CompanyId":"00000000-0000-0000-0000-000000000000","TagIds":[0]}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"Firstname":"String","Lastname":"String","Email":"String","Phone":"String","ImageUrl":"String","PersonalIdentityNumber":"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":{"UserId":"00000000-0000-0000-0000-000000000000","CorporateIdentityNumber":"String","InvoiceAddress1":"String","InvoiceAddress2":"String","InvoiceCity":"String","InvoicePostalCode":"String","InvoiceCountryCode":"String"},"Tags":[{"Id":0,"Name":"String","Scope":0,"Color":"String","SortOrder":0,"Active":false,"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}}]}