/* Options: Date: 2024-11-21 11:40:10 SwiftVersion: 5.0 Version: 8.23 Tip: To override a DTO option, remove "//" prefix before updating BaseUrl: https://api.bokamera.se //BaseClass: //AddModelExtensions: True //AddServiceStackTypes: True IncludeTypes: CountryQuery.* //ExcludeTypes: //ExcludeGenericBaseTypes: False //AddResponseStatus: False //AddImplicitVersion: //AddDescriptionAsComments: True //InitializeCollections: True //TreatTypesAsStrings: //DefaultImports: Foundation,ServiceStack */ import Foundation import ServiceStack // @Route("/countries", "GET") public class CountryQuery : QueryDb2, IReturn { public typealias Return = QueryResponse /** * Id of the country */ // @ApiMember(Description="Id of the country") public var id:String 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(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 id != nil { try container.encode(id, forKey: .id) } } } public class Country : BaseModel { // @References(typeof(Currency)) public var currencyId:String public var currencyInfo:Currency // @Required() public var name:String? public var culture:String public var timeZone:String public var modifiedDate:Date? // @Required() public var id:String? required public init(){ super.init() } private enum CodingKeys : String, CodingKey { case currencyId case currencyInfo case name case culture case timeZone case modifiedDate case id } required public init(from decoder: Decoder) throws { try super.init(from: decoder) let container = try decoder.container(keyedBy: CodingKeys.self) currencyId = try container.decodeIfPresent(String.self, forKey: .currencyId) currencyInfo = try container.decodeIfPresent(Currency.self, forKey: .currencyInfo) name = try container.decodeIfPresent(String.self, forKey: .name) culture = try container.decodeIfPresent(String.self, forKey: .culture) timeZone = try container.decodeIfPresent(String.self, forKey: .timeZone) 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 currencyId != nil { try container.encode(currencyId, forKey: .currencyId) } if currencyInfo != nil { try container.encode(currencyInfo, forKey: .currencyInfo) } if name != nil { try container.encode(name, forKey: .name) } if culture != nil { try container.encode(culture, forKey: .culture) } if timeZone != nil { try container.encode(timeZone, forKey: .timeZone) } if modifiedDate != nil { try container.encode(modifiedDate, forKey: .modifiedDate) } if id != nil { try container.encode(id, forKey: .id) } } } public class CountryQueryResponse : Codable { public var id:String public var name:String public var Description:String public var responseStatus:ResponseStatus required public init(){} } 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 enum Currency : Int, Codable { case SEK = 1 case EUR = 2 }