/* Options: Date: 2024-11-24 10:22:35 SwiftVersion: 5.0 Version: 6.111 Tip: To override a DTO option, remove "//" prefix before updating BaseUrl: https://sharpscript.net //BaseClass: //AddModelExtensions: True //AddServiceStackTypes: True IncludeTypes: QueryCustomers.* //ExcludeTypes: //ExcludeGenericBaseTypes: False //AddResponseStatus: False //AddImplicitVersion: //AddDescriptionAsComments: True //InitializeCollections: True //TreatTypesAsStrings: //DefaultImports: Foundation,ServiceStack */ import Foundation import ServiceStack public class QueryCustomers : QueryDb, IReturn { public typealias Return = QueryResponse public var customerId:String public var companyNameContains:String public var countryIn:[String] = [] required public init(){ super.init() } private enum CodingKeys : String, CodingKey { case customerId case companyNameContains case countryIn } required public init(from decoder: Decoder) throws { try super.init(from: decoder) let container = try decoder.container(keyedBy: CodingKeys.self) customerId = try container.decodeIfPresent(String.self, forKey: .customerId) companyNameContains = try container.decodeIfPresent(String.self, forKey: .companyNameContains) countryIn = try container.decodeIfPresent([String].self, forKey: .countryIn) ?? [] } public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) if customerId != nil { try container.encode(customerId, forKey: .customerId) } if companyNameContains != nil { try container.encode(companyNameContains, forKey: .companyNameContains) } if countryIn.count > 0 { try container.encode(countryIn, forKey: .countryIn) } } } public class Customer : Codable { public var customerId:String public var companyName:String public var address:String public var city:String public var region:String public var postalCode:String public var country:String public var phone:String public var fax:String public var orders:[Order] = [] required public init(){} } public class Order : Codable { public var orderId:Int public var customerId:String public var orderDate:Date public var total:Double required public init(){} }