2022-09-19 05:11:02 +00:00
|
|
|
const freeProductID = "free";
|
|
|
|
const stripe = "stripe";
|
|
|
|
const appStore = "appstore";
|
|
|
|
const playStore = "playstore";
|
2021-02-25 14:59:54 +00:00
|
|
|
|
2021-01-06 11:56:03 +00:00
|
|
|
class Subscription {
|
2021-01-29 11:07:58 +00:00
|
|
|
final String productID;
|
2021-02-01 10:38:07 +00:00
|
|
|
final int storage;
|
2021-01-29 11:07:58 +00:00
|
|
|
final String originalTransactionID;
|
|
|
|
final String paymentProvider;
|
2021-01-18 17:02:44 +00:00
|
|
|
final int expiryTime;
|
2021-07-26 16:08:23 +00:00
|
|
|
final String price;
|
|
|
|
final String period;
|
2022-09-19 06:26:31 +00:00
|
|
|
final Attributes? attributes;
|
2021-01-06 11:56:03 +00:00
|
|
|
|
|
|
|
Subscription({
|
2022-09-19 06:26:31 +00:00
|
|
|
required this.productID,
|
|
|
|
required this.storage,
|
|
|
|
required this.originalTransactionID,
|
|
|
|
required this.paymentProvider,
|
|
|
|
required this.expiryTime,
|
|
|
|
required this.price,
|
|
|
|
required this.period,
|
2021-08-19 11:23:48 +00:00
|
|
|
this.attributes,
|
2021-01-06 11:56:03 +00:00
|
|
|
});
|
|
|
|
|
2021-01-31 21:00:12 +00:00
|
|
|
bool isValid() {
|
|
|
|
return expiryTime > DateTime.now().microsecondsSinceEpoch;
|
|
|
|
}
|
|
|
|
|
2021-08-19 07:53:37 +00:00
|
|
|
bool isYearlyPlan() {
|
|
|
|
return 'year' == period;
|
|
|
|
}
|
|
|
|
|
2022-09-21 08:55:00 +00:00
|
|
|
static fromMap(Map<String, dynamic>? map) {
|
|
|
|
if (map == null) return null;
|
2021-01-06 11:56:03 +00:00
|
|
|
return Subscription(
|
2021-01-29 11:07:58 +00:00
|
|
|
productID: map['productID'],
|
2021-02-01 10:38:07 +00:00
|
|
|
storage: map['storage'],
|
2021-01-29 11:07:58 +00:00
|
|
|
originalTransactionID: map['originalTransactionID'],
|
|
|
|
paymentProvider: map['paymentProvider'],
|
2021-01-18 17:02:44 +00:00
|
|
|
expiryTime: map['expiryTime'],
|
2021-07-26 16:08:23 +00:00
|
|
|
price: map['price'],
|
|
|
|
period: map['period'],
|
2021-08-19 11:23:48 +00:00
|
|
|
attributes: map["attributes"] != null
|
|
|
|
? Attributes.fromJson(map["attributes"])
|
|
|
|
: null,
|
2021-01-06 11:56:03 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2021-08-19 11:23:48 +00:00
|
|
|
|
|
|
|
class Attributes {
|
2022-09-19 06:26:31 +00:00
|
|
|
bool? isCancelled;
|
|
|
|
String? customerID;
|
2021-08-19 11:23:48 +00:00
|
|
|
|
|
|
|
Attributes({
|
|
|
|
this.isCancelled,
|
2022-06-11 08:23:52 +00:00
|
|
|
this.customerID,
|
|
|
|
});
|
2021-08-19 11:23:48 +00:00
|
|
|
|
|
|
|
Attributes.fromJson(dynamic json) {
|
|
|
|
isCancelled = json["isCancelled"];
|
|
|
|
customerID = json["customerID"];
|
|
|
|
}
|
2022-06-11 08:23:52 +00:00
|
|
|
}
|