GET | /invoiceitems | ||
---|---|---|---|
GET | /invoiceitems/{InvoiceLineId} |
import Foundation
import ServiceStack
public class QueryInvoiceItems : QueryDb<InvoiceItems>, IGet
{
public var invoiceLineId:Int?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case invoiceLineId
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
invoiceLineId = try container.decodeIfPresent(Int.self, forKey: .invoiceLineId)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if invoiceLineId != nil { try container.encode(invoiceLineId, forKey: .invoiceLineId) }
}
}
public class InvoiceItems : Codable
{
public var invoiceLineId:Int
public var invoiceId:Int
public var trackId:Int
public var unitPrice:Double
public var quantity:Int
required public init(){}
}
public class Todo : Codable
{
public var id:Int
public var text:String
public var isFinished:Bool
required public init(){}
}
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.
GET /invoiceitems HTTP/1.1 Host: blazor-gallery.servicestack.net Accept: text/jsv
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { offset: 0, total: 0, results: [ { invoiceLineId: 0, invoiceId: 0, trackId: 0, unitPrice: 0, quantity: 0 } ], meta: { String: String }, responseStatus: { errorCode: String, message: String, stackTrace: String, errors: [ { errorCode: String, fieldName: String, message: String, meta: { String: String } } ], meta: { String: String } } }