v2.0.4 — Show spent, limit and balance from dedicated billing endpoints
This commit is contained in:
+33
-11
@@ -83,24 +83,46 @@ struct UsageWindow: Codable {
|
||||
|
||||
struct ExtraUsage: Codable {
|
||||
let isEnabled: Bool
|
||||
let monthlyLimit: Double?
|
||||
let usedCredits: Double?
|
||||
let utilization: Double?
|
||||
let currency: String?
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case isEnabled = "is_enabled"
|
||||
case monthlyLimit = "monthly_limit"
|
||||
case usedCredits = "used_credits"
|
||||
case utilization
|
||||
case currency
|
||||
}
|
||||
init(from decoder: Decoder) throws {
|
||||
let c = try decoder.container(keyedBy: CodingKeys.self)
|
||||
isEnabled = (try? c.decodeIfPresent(Bool.self, forKey: .isEnabled)) ?? false
|
||||
monthlyLimit = try? c.decodeIfPresent(Double.self, forKey: .monthlyLimit)
|
||||
usedCredits = try? c.decodeIfPresent(Double.self, forKey: .usedCredits)
|
||||
utilization = try? c.decodeIfPresent(Double.self, forKey: .utilization)
|
||||
currency = try? c.decodeIfPresent(String.self, forKey: .currency)
|
||||
isEnabled = (try? c.decodeIfPresent(Bool.self, forKey: .isEnabled)) ?? false
|
||||
currency = try? c.decodeIfPresent(String.self, forKey: .currency)
|
||||
}
|
||||
}
|
||||
|
||||
struct PrepaidCredits: Decodable {
|
||||
let amount: Double?
|
||||
let currency: String?
|
||||
enum CodingKeys: String, CodingKey { case amount, currency }
|
||||
init(from decoder: Decoder) throws {
|
||||
let c = try decoder.container(keyedBy: CodingKeys.self)
|
||||
amount = try? c.decodeIfPresent(Double.self, forKey: .amount)
|
||||
currency = try? c.decodeIfPresent(String.self, forKey: .currency)
|
||||
}
|
||||
}
|
||||
|
||||
struct OverageSpendLimit: Decodable {
|
||||
let isEnabled: Bool
|
||||
let usedCredits: Double?
|
||||
let monthlyCreditLimit: Double?
|
||||
let currency: String?
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case isEnabled = "is_enabled"
|
||||
case usedCredits = "used_credits"
|
||||
case monthlyCreditLimit = "monthly_credit_limit"
|
||||
case currency
|
||||
}
|
||||
init(from decoder: Decoder) throws {
|
||||
let c = try decoder.container(keyedBy: CodingKeys.self)
|
||||
isEnabled = (try? c.decodeIfPresent(Bool.self, forKey: .isEnabled)) ?? false
|
||||
usedCredits = try? c.decodeIfPresent(Double.self, forKey: .usedCredits)
|
||||
monthlyCreditLimit = try? c.decodeIfPresent(Double.self, forKey: .monthlyCreditLimit)
|
||||
currency = try? c.decodeIfPresent(String.self, forKey: .currency)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user