v2.0.4 — Show spent, limit and balance from dedicated billing endpoints

This commit is contained in:
superdooper86
2026-05-07 14:04:19 +02:00
parent ccf3468621
commit 1507c6490f
6 changed files with 92 additions and 24 deletions
+33 -11
View File
@@ -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)
}
}