Files
Chirag Aggarwal 7f801a9ed5 feat: SDK update for version 19.0.0 (#123)
* chore: update Apple SDK to 18.3.0

* chore: update Apple SDK to 18.3.0

* chore: update Apple SDK to 19.0.0

* docs: state the SDK targets Appwrite server version 2.0.x

* fix: regenerate with the latest sdk-generator and add auto image gravity
2026-09-07 10:48:33 -07:00

53 lines
1.2 KiB
Swift

import Foundation
import JSONCodable
/// Country
open class Country: Codable {
enum CodingKeys: String, CodingKey {
case name = "name"
case code = "code"
}
/// Country name.
public let name: String
/// Country two-character ISO 3166-1 alpha code.
public let code: String
init(
name: String,
code: String
) {
self.name = name
self.code = code
}
public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.name = try container.decode(String.self, forKey: .name)
self.code = try container.decode(String.self, forKey: .code)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(name, forKey: .name)
try container.encode(code, forKey: .code)
}
public func toMap() -> [String: Any] {
return [
"name": name as Any,
"code": code as Any,
]
}
public static func from(map: [String: Any]) -> Country {
return Country(
name: map["name"] as! String,
code: map["code"] as! String
)
}
}