|
@@ -1,7 +1,5 @@
|
|
|
// @dart=2.9
|
|
|
|
|
|
-import 'dart:convert';
|
|
|
-
|
|
|
const freeProductID = "free";
|
|
|
const stripe = "stripe";
|
|
|
const appStore = "appstore";
|
|
@@ -38,44 +36,6 @@ class Subscription {
|
|
|
return 'year' == period;
|
|
|
}
|
|
|
|
|
|
- Subscription copyWith({
|
|
|
- int id,
|
|
|
- String productID,
|
|
|
- int storage,
|
|
|
- String originalTransactionID,
|
|
|
- String paymentProvider,
|
|
|
- int expiryTime,
|
|
|
- String price,
|
|
|
- String period,
|
|
|
- }) {
|
|
|
- return Subscription(
|
|
|
- id: id ?? this.id,
|
|
|
- productID: productID ?? this.productID,
|
|
|
- storage: storage ?? this.storage,
|
|
|
- originalTransactionID:
|
|
|
- originalTransactionID ?? this.originalTransactionID,
|
|
|
- paymentProvider: paymentProvider ?? this.paymentProvider,
|
|
|
- expiryTime: expiryTime ?? this.expiryTime,
|
|
|
- price: price ?? this.price,
|
|
|
- period: period ?? this.period,
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, dynamic> toMap() {
|
|
|
- final map = <String, dynamic>{
|
|
|
- 'id': id,
|
|
|
- 'productID': productID,
|
|
|
- 'storage': storage,
|
|
|
- 'originalTransactionID': originalTransactionID,
|
|
|
- 'paymentProvider': paymentProvider,
|
|
|
- 'expiryTime': expiryTime,
|
|
|
- 'price': price,
|
|
|
- 'period': period,
|
|
|
- 'attributes': attributes?.toJson()
|
|
|
- };
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
factory Subscription.fromMap(Map<String, dynamic> map) {
|
|
|
if (map == null) return null;
|
|
|
return Subscription(
|
|
@@ -92,43 +52,6 @@ class Subscription {
|
|
|
: null,
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
- String toJson() => json.encode(toMap());
|
|
|
-
|
|
|
- factory Subscription.fromJson(String source) =>
|
|
|
- Subscription.fromMap(json.decode(source));
|
|
|
-
|
|
|
- @override
|
|
|
- String toString() {
|
|
|
- return 'Subscription{id: $id, productID: $productID, storage: $storage, originalTransactionID: $originalTransactionID, paymentProvider: $paymentProvider, expiryTime: $expiryTime, price: $price, period: $period, attributes: $attributes}';
|
|
|
- }
|
|
|
-
|
|
|
- @override
|
|
|
- bool operator ==(Object o) {
|
|
|
- if (identical(this, o)) return true;
|
|
|
-
|
|
|
- return o is Subscription &&
|
|
|
- o.id == id &&
|
|
|
- o.productID == productID &&
|
|
|
- o.storage == storage &&
|
|
|
- o.originalTransactionID == originalTransactionID &&
|
|
|
- o.paymentProvider == paymentProvider &&
|
|
|
- o.expiryTime == expiryTime &&
|
|
|
- o.price == price &&
|
|
|
- o.period == period;
|
|
|
- }
|
|
|
-
|
|
|
- @override
|
|
|
- int get hashCode {
|
|
|
- return id.hashCode ^
|
|
|
- productID.hashCode ^
|
|
|
- storage.hashCode ^
|
|
|
- originalTransactionID.hashCode ^
|
|
|
- paymentProvider.hashCode ^
|
|
|
- expiryTime.hashCode ^
|
|
|
- price.hashCode ^
|
|
|
- period.hashCode;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
class Attributes {
|
|
@@ -144,16 +67,4 @@ class Attributes {
|
|
|
isCancelled = json["isCancelled"];
|
|
|
customerID = json["customerID"];
|
|
|
}
|
|
|
-
|
|
|
- Map<String, dynamic> toJson() {
|
|
|
- final map = <String, dynamic>{};
|
|
|
- map["isCancelled"] = isCancelled;
|
|
|
- map["customerID"] = customerID;
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- @override
|
|
|
- String toString() {
|
|
|
- return 'Attributes{isCancelled: $isCancelled, customerID: $customerID}';
|
|
|
- }
|
|
|
}
|