Files
plexswift/Sources/Plexswift/models/operations/Location.swift

88 lines
4.1 KiB
Swift

// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations {
/// A model object
public struct Location {
public let city: String?
public let code: String?
public let continentCode: String?
public let coordinates: String?
public let country: String?
public let europeanUnionMember: Bool?
public let inPrivacyRestrictedCountry: Bool?
@DecimalSerialized
public private(set) var postalCode: Double?
public let subdivisions: String?
public let timeZone: String?
/// Creates an object with the specified parameters
///
///
public init(city: String? = nil, code: String? = nil, continentCode: String? = nil, coordinates: String? = nil, country: String? = nil, europeanUnionMember: Bool? = nil, inPrivacyRestrictedCountry: Bool? = nil, postalCode: Double? = nil, subdivisions: String? = nil, timeZone: String? = nil) {
self.city = city
self.code = code
self.continentCode = continentCode
self.coordinates = coordinates
self.country = country
self.europeanUnionMember = europeanUnionMember
self.inPrivacyRestrictedCountry = inPrivacyRestrictedCountry
self._postalCode = DecimalSerialized<Double?>(wrappedValue: postalCode)
self.subdivisions = subdivisions
self.timeZone = timeZone
}
}
}
extension Operations.Location: Codable {
enum CodingKeys: String, CodingKey {
case city
case code
case continentCode = "continent_code"
case coordinates
case country
case europeanUnionMember = "european_union_member"
case inPrivacyRestrictedCountry = "in_privacy_restricted_country"
case postalCode = "postal_code"
case subdivisions
case timeZone = "time_zone"
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.city = try container.decodeIfPresent(String.self, forKey: .city)
self.code = try container.decodeIfPresent(String.self, forKey: .code)
self.continentCode = try container.decodeIfPresent(String.self, forKey: .continentCode)
self.coordinates = try container.decodeIfPresent(String.self, forKey: .coordinates)
self.country = try container.decodeIfPresent(String.self, forKey: .country)
self.europeanUnionMember = try container.decodeIfPresent(Bool.self, forKey: .europeanUnionMember)
self.inPrivacyRestrictedCountry = try container.decodeIfPresent(Bool.self, forKey: .inPrivacyRestrictedCountry)
self._postalCode = try container.decodeIfPresent(DecimalSerialized<Double?>.self, forKey: .postalCode) ?? DecimalSerialized<Double?>(wrappedValue: nil)
self.subdivisions = try container.decodeIfPresent(String.self, forKey: .subdivisions)
self.timeZone = try container.decodeIfPresent(String.self, forKey: .timeZone)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(self.city, forKey: .city)
try container.encodeIfPresent(self.code, forKey: .code)
try container.encodeIfPresent(self.continentCode, forKey: .continentCode)
try container.encodeIfPresent(self.coordinates, forKey: .coordinates)
try container.encodeIfPresent(self.country, forKey: .country)
try container.encodeIfPresent(self.europeanUnionMember, forKey: .europeanUnionMember)
try container.encodeIfPresent(self.inPrivacyRestrictedCountry, forKey: .inPrivacyRestrictedCountry)
if self.postalCode != nil {
try container.encode(self._postalCode, forKey: .postalCode)
}
try container.encodeIfPresent(self.subdivisions, forKey: .subdivisions)
try container.encodeIfPresent(self.timeZone, forKey: .timeZone)
}
}
extension Operations.Location {
var postalCodeWrapper: DecimalSerialized<Double?> {
return _postalCode
}
}