ente/mobile/lib/models/billing_plan.dart

108 lines
2.1 KiB
Dart
Raw Normal View History

2021-01-05 09:41:32 +00:00
import 'dart:convert';
2021-03-02 06:35:10 +00:00
class BillingPlans {
final List<BillingPlan> plans;
final FreePlan freePlan;
BillingPlans({
required this.plans,
required this.freePlan,
2021-03-02 06:35:10 +00:00
});
Map<String, dynamic> toMap() {
return {
'plans': plans.map((x) => x.toMap()).toList(),
'freePlan': freePlan.toMap(),
2021-03-02 06:35:10 +00:00
};
}
static fromMap(Map<String, dynamic>? map) {
if (map == null) return null;
2021-03-02 06:35:10 +00:00
return BillingPlans(
plans: List<BillingPlan>.from(
2022-06-11 08:23:52 +00:00
map['plans']?.map((x) => BillingPlan.fromMap(x)),
),
2021-03-02 06:35:10 +00:00
freePlan: FreePlan.fromMap(map['freePlan']),
);
}
factory BillingPlans.fromJson(String source) =>
BillingPlans.fromMap(json.decode(source));
}
class FreePlan {
final int storage;
final int duration;
final String period;
FreePlan({
required this.storage,
required this.duration,
required this.period,
2021-03-02 06:35:10 +00:00
});
Map<String, dynamic> toMap() {
return {
'storage': storage,
'duration': duration,
'period': period,
};
}
static fromMap(Map<String, dynamic>? map) {
if (map == null) return null;
2021-03-02 06:35:10 +00:00
return FreePlan(
storage: map['storage'],
duration: map['duration'],
period: map['period'],
);
}
}
2021-01-05 09:41:32 +00:00
class BillingPlan {
final String id;
2021-01-06 08:47:18 +00:00
final String androidID;
final String iosID;
2021-05-19 15:47:16 +00:00
final String stripeID;
2021-02-01 10:20:39 +00:00
final int storage;
2021-01-05 09:41:32 +00:00
final String price;
2021-01-06 08:47:18 +00:00
final String period;
2021-01-05 09:41:32 +00:00
BillingPlan({
required this.id,
required this.androidID,
required this.iosID,
required this.stripeID,
required this.storage,
required this.price,
required this.period,
2021-01-05 09:41:32 +00:00
});
Map<String, dynamic> toMap() {
return {
'id': id,
2021-01-06 08:47:18 +00:00
'androidID': androidID,
'iosID': iosID,
2021-05-19 15:47:16 +00:00
'stripeID': stripeID,
2021-02-01 10:20:39 +00:00
'storage': storage,
2021-01-05 09:41:32 +00:00
'price': price,
2021-01-06 08:47:18 +00:00
'period': period,
2021-01-05 09:41:32 +00:00
};
}
static fromMap(Map<String, dynamic>? map) {
if (map == null) return null;
2021-01-05 09:41:32 +00:00
return BillingPlan(
id: map['id'],
2021-01-06 08:47:18 +00:00
androidID: map['androidID'],
iosID: map['iosID'],
2021-05-19 15:47:16 +00:00
stripeID: map['stripeID'],
2021-02-01 10:20:39 +00:00
storage: map['storage'],
2021-01-05 09:41:32 +00:00
price: map['price'],
2021-01-06 08:47:18 +00:00
period: map['period'],
2021-01-05 09:41:32 +00:00
);
}
}