billing_plan.dart 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import 'dart:convert';
  2. class BillingPlans {
  3. final List<BillingPlan> plans;
  4. final FreePlan freePlan;
  5. BillingPlans({
  6. required this.plans,
  7. required this.freePlan,
  8. });
  9. Map<String, dynamic> toMap() {
  10. return {
  11. 'plans': plans.map((x) => x.toMap()).toList(),
  12. 'freePlan': freePlan.toMap(),
  13. };
  14. }
  15. static fromMap(Map<String, dynamic>? map) {
  16. if (map == null) return null;
  17. return BillingPlans(
  18. plans: List<BillingPlan>.from(
  19. map['plans']?.map((x) => BillingPlan.fromMap(x)),
  20. ),
  21. freePlan: FreePlan.fromMap(map['freePlan']),
  22. );
  23. }
  24. factory BillingPlans.fromJson(String source) =>
  25. BillingPlans.fromMap(json.decode(source));
  26. }
  27. class FreePlan {
  28. final int storage;
  29. final int duration;
  30. final String period;
  31. FreePlan({
  32. required this.storage,
  33. required this.duration,
  34. required this.period,
  35. });
  36. Map<String, dynamic> toMap() {
  37. return {
  38. 'storage': storage,
  39. 'duration': duration,
  40. 'period': period,
  41. };
  42. }
  43. static fromMap(Map<String, dynamic>? map) {
  44. if (map == null) return null;
  45. return FreePlan(
  46. storage: map['storage'],
  47. duration: map['duration'],
  48. period: map['period'],
  49. );
  50. }
  51. }
  52. class BillingPlan {
  53. final String id;
  54. final String androidID;
  55. final String iosID;
  56. final String stripeID;
  57. final int storage;
  58. final String price;
  59. final String period;
  60. BillingPlan({
  61. required this.id,
  62. required this.androidID,
  63. required this.iosID,
  64. required this.stripeID,
  65. required this.storage,
  66. required this.price,
  67. required this.period,
  68. });
  69. Map<String, dynamic> toMap() {
  70. return {
  71. 'id': id,
  72. 'androidID': androidID,
  73. 'iosID': iosID,
  74. 'stripeID': stripeID,
  75. 'storage': storage,
  76. 'price': price,
  77. 'period': period,
  78. };
  79. }
  80. static fromMap(Map<String, dynamic>? map) {
  81. if (map == null) return null;
  82. return BillingPlan(
  83. id: map['id'],
  84. androidID: map['androidID'],
  85. iosID: map['iosID'],
  86. stripeID: map['stripeID'],
  87. storage: map['storage'],
  88. price: map['price'],
  89. period: map['period'],
  90. );
  91. }
  92. }