mirror of
https://github.com/confirmedcode/Lockdown-iOS.git
synced 2025-12-21 12:14:02 +01:00
change expiration date to Date type in model
This commit is contained in:
@@ -129,7 +129,11 @@ class Client {
|
||||
URLSession.shared.dataTask(.promise, with: try makePostRequest(urlString: mainURL + "/active-subscriptions", parameters: [:]))
|
||||
}.map { data, response -> [Subscription] in
|
||||
try self.validateApiResponse(data: data, response: response)
|
||||
var subscriptions = try JSONDecoder().decode([Subscription].self, from: data)
|
||||
let decoder = JSONDecoder()
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.sss'Z'"
|
||||
decoder.dateDecodingStrategy = .formatted(formatter)
|
||||
var subscriptions = try decoder.decode([Subscription].self, from: data)
|
||||
DDLogInfo("API RESULT: active-subscriptions: \(subscriptions)")
|
||||
// sort subscriptions with highest tier at the top
|
||||
subscriptions.sort(by: { (sub1: Subscription, sub2: Subscription) -> Bool in
|
||||
|
||||
@@ -28,10 +28,10 @@ struct SubscriptionEvent: Codable {
|
||||
struct Subscription: Codable {
|
||||
let planType: PlanType
|
||||
let receiptId: String
|
||||
let expirationDate: String
|
||||
let expirationDate: Date
|
||||
let expirationDateString: String
|
||||
let expirationDateMs: Int
|
||||
let cancellationDate: String?
|
||||
let cancellationDate: Date?
|
||||
let cancellationDateString: String?
|
||||
let cancellationDateMs: Int?
|
||||
|
||||
@@ -45,7 +45,7 @@ struct Subscription: Codable {
|
||||
static let anonymousMonthly = PlanType(rawValue: "ios-monthly")
|
||||
static let anonymousAnnual = PlanType(rawValue: "ios-annual")
|
||||
static let universalMonthly = PlanType(rawValue: "all-monthly")
|
||||
static let universalAnnual = PlanType(rawValue: "all-annual")
|
||||
static let universalAnnual = PlanType(rawValue: "all-annual")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user