MyApp

<back to all web services

QueryInvoices

Media Store
The following routes are available for this service:
GET/invoices
GET/invoices/{InvoiceId}
import Foundation
import ServiceStack

public class QueryInvoices : QueryDb<Invoices>, IGet
{
    public var invoiceId:Int?

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

    private enum CodingKeys : String, CodingKey {
        case invoiceId
    }

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

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

public class Invoices : Codable
{
    public var invoiceId:Int
    public var customerId:Int
    public var invoiceDate:Date
    public var billingAddress:String
    public var billingCity:String
    public var billingState:String
    public var billingCountry:String
    public var billingPostalCode:String
    public var total:Double

    required public init(){}
}

public class Todo : Codable
{
    public var id:Int
    public var text:String
    public var isFinished:Bool

    required public init(){}
}


Swift QueryInvoices 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 /invoices HTTP/1.1 
Host: blazor-gallery.servicestack.net 
Accept: text/jsonl
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

{"offset":0,"total":0,"results":[{"invoiceId":0,"customerId":0,"invoiceDate":"0001-01-01T00:00:00","billingAddress":"String","billingCity":"String","billingState":"String","billingCountry":"String","billingPostalCode":"String","total":0}],"meta":{"String":"String"},"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}