| GET | /api/v1/utils/countries |
|---|
import Foundation
import ServiceStack
public class GetCountries : IGet, Codable
{
required public init(){}
}
public class GetCountriesResponse : BaseResponse
{
public var countries:[Country] = []
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case countries
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
countries = try container.decodeIfPresent([Country].self, forKey: .countries) ?? []
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if countries.count > 0 { try container.encode(countries, forKey: .countries) }
}
}
public class BaseResponse : Codable
{
public var status:Status
required public init(){}
}
public class Status : Codable
{
public var message:String
public var statusCode:Int
required public init(){}
}
public class Country : Codable
{
public var id:Int
// @Required()
// @StringLength(2)
public var code:String?
// @Required()
// @StringLength(3)
public var phoneCode:String?
// @Required()
// @StringLength(200)
public var name:String?
// @Required()
// @StringLength(5)
public var currencySymbol:String?
// @Required()
// @StringLength(200)
public var currencyName:String?
// @Required()
public var order:Int?
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 /api/v1/utils/countries HTTP/1.1 Host: pecuario-backend.develsystems.com Accept: text/jsv
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
countries:
[
{
id: 0,
code: String,
phoneCode: String,
name: String,
currencySymbol: String,
currencyName: String,
order: 0
}
]
}