BokaMera.API.Host

<back to all web services

CategoryQuery

The following routes are available for this service:
GET/categoriesFind service categoriesFind service categories that a company can belong to.
import Foundation
import ServiceStack

public class CategoryQuery : QueryDb2<CompanyCategory, CategoryQueryResponse>
{
    /**
    * Id of the category
    */
    // @ApiMember(Description="Id of the category")
    public var id:Int?

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

    private enum CodingKeys : String, CodingKey {
        case id
    }

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

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

public class CompanyCategory : BaseModel
{
    // @Required()
    public var name:String?

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

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

    public var imageUrl:Uri
    // @Required()
    public var active:Bool?

    public var sortOrder:Int?
    public var modifiedDate:Date?
    public var id:Int

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

    private enum CodingKeys : String, CodingKey {
        case name
        case header
        case Description
        case imageUrl
        case active
        case sortOrder
        case modifiedDate
        case id
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        name = try container.decodeIfPresent(String.self, forKey: .name)
        header = try container.decodeIfPresent(String.self, forKey: .header)
        Description = try container.decodeIfPresent(String.self, forKey: .Description)
        imageUrl = try container.decodeIfPresent(Uri.self, forKey: .imageUrl)
        active = try container.decodeIfPresent(Bool.self, forKey: .active)
        sortOrder = try container.decodeIfPresent(Int.self, forKey: .sortOrder)
        modifiedDate = try container.decodeIfPresent(Date.self, forKey: .modifiedDate)
        id = try container.decodeIfPresent(Int.self, forKey: .id)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if name != nil { try container.encode(name, forKey: .name) }
        if header != nil { try container.encode(header, forKey: .header) }
        if Description != nil { try container.encode(Description, forKey: .Description) }
        if imageUrl != nil { try container.encode(imageUrl, forKey: .imageUrl) }
        if active != nil { try container.encode(active, forKey: .active) }
        if sortOrder != nil { try container.encode(sortOrder, forKey: .sortOrder) }
        if modifiedDate != nil { try container.encode(modifiedDate, forKey: .modifiedDate) }
        if id != nil { try container.encode(id, forKey: .id) }
    }
}

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

public class CategoryQueryResponse : Codable
{
    public var id:Int
    public var name:String
    public var Description:String
    public var header:String
    public var imageUrl:Uri
    public var active:Bool
    public var responseStatus:ResponseStatus

    required public init(){}
}

public class AccessKeyTypeResponse : Codable
{
    public var id:Int
    public var keyType:String
    public var Description:String

    required public init(){}
}


Swift CategoryQuery 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.

GET /categories HTTP/1.1 
Host: api.bokamera.se 
Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"Offset":0,"Total":0,"Results":[{"Id":0,"Name":"String","Description":"String","Header":"String","Active":false,"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}}],"Meta":{"String":"String"},"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}}