BokaMera.API.Host

<back to all web services

CurrencyQuery

The following routes are available for this service:
GET/currenciesGet all valid currenciesGet all valid currencies.
import Foundation
import ServiceStack

public class CurrencyQuery : QueryDb2<Currency, CurrencyQueryResponse>
{
    /**
    * Id of the currency
    */
    // @ApiMember(Description="Id of the currency")
    public var id:String

    /**
    * Only active currencies
    */
    // @ApiMember(Description="Only active currencies")
    public var active:Bool

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

    private enum CodingKeys : String, CodingKey {
        case id
        case active
    }

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

    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) }
        if active != nil { try container.encode(active, forKey: .active) }
    }
}

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

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

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

    public var modifiedDate:Date?
    // @Required()
    public var id:String?

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

    private enum CodingKeys : String, CodingKey {
        case name
        case currencySign
        case active
        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)
        currencySign = try container.decodeIfPresent(String.self, forKey: .currencySign)
        active = try container.decodeIfPresent(Bool.self, forKey: .active)
        modifiedDate = try container.decodeIfPresent(Date.self, forKey: .modifiedDate)
        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 name != nil { try container.encode(name, forKey: .name) }
        if currencySign != nil { try container.encode(currencySign, forKey: .currencySign) }
        if active != nil { try container.encode(active, forKey: .active) }
        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 CurrencyQueryResponse : Codable
{
    public var id:String
    public var name:String
    public var Description:String
    public var currencySign:String
    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 CurrencyQuery DTOs

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

HTTP + OTHER

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

GET /currencies HTTP/1.1 
Host: testapi.bokamera.se 
Accept: text/jsonl
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

{"Offset":0,"Total":0,"Results":[{"Id":"String","Name":"String","Description":"String","CurrencySign":"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"}}}