Skip to content

Commit 45b956e

Browse files
author
serverpod_cloud
committed
feat(gc): 04bb91c8e60b1cac80df6ba36fff91cb2ef52086
1 parent 86e50f3 commit 45b956e

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

ground_control_client/lib/src/protocol/domains/products/models/subscription_info.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ abstract class SubscriptionInfo implements _i1.SerializableModel {
1919
required this.createdAt,
2020
required this.startDate,
2121
this.trialEndDate,
22+
this.endDate,
23+
required this.cancelled,
2224
required this.subscriptionId,
2325
required this.planProductId,
2426
required this.planName,
@@ -31,6 +33,8 @@ abstract class SubscriptionInfo implements _i1.SerializableModel {
3133
required DateTime createdAt,
3234
required DateTime startDate,
3335
DateTime? trialEndDate,
36+
DateTime? endDate,
37+
required bool cancelled,
3438
required String subscriptionId,
3539
required String planProductId,
3640
required String planName,
@@ -52,6 +56,10 @@ abstract class SubscriptionInfo implements _i1.SerializableModel {
5256
: _i1.DateTimeJsonExtension.fromJson(
5357
jsonSerialization['trialEndDate'],
5458
),
59+
endDate: jsonSerialization['endDate'] == null
60+
? null
61+
: _i1.DateTimeJsonExtension.fromJson(jsonSerialization['endDate']),
62+
cancelled: jsonSerialization['cancelled'] as bool,
5563
subscriptionId: jsonSerialization['subscriptionId'] as String,
5664
planProductId: jsonSerialization['planProductId'] as String,
5765
planName: jsonSerialization['planName'] as String,
@@ -70,6 +78,12 @@ abstract class SubscriptionInfo implements _i1.SerializableModel {
7078
/// Trial end date, if currently ongoing.
7179
DateTime? trialEndDate;
7280

81+
/// The date the subscription ended / will end, if cancelled or otherwise terminated.
82+
DateTime? endDate;
83+
84+
/// Whether this subscription has been cancelled.
85+
bool cancelled;
86+
7387
/// The id of the subscription.
7488
String subscriptionId;
7589

@@ -95,6 +109,8 @@ abstract class SubscriptionInfo implements _i1.SerializableModel {
95109
DateTime? createdAt,
96110
DateTime? startDate,
97111
DateTime? trialEndDate,
112+
DateTime? endDate,
113+
bool? cancelled,
98114
String? subscriptionId,
99115
String? planProductId,
100116
String? planName,
@@ -109,6 +125,8 @@ abstract class SubscriptionInfo implements _i1.SerializableModel {
109125
'createdAt': createdAt.toJson(),
110126
'startDate': startDate.toJson(),
111127
if (trialEndDate != null) 'trialEndDate': trialEndDate?.toJson(),
128+
if (endDate != null) 'endDate': endDate?.toJson(),
129+
'cancelled': cancelled,
112130
'subscriptionId': subscriptionId,
113131
'planProductId': planProductId,
114132
'planName': planName,
@@ -131,6 +149,8 @@ class _SubscriptionInfoImpl extends SubscriptionInfo {
131149
required DateTime createdAt,
132150
required DateTime startDate,
133151
DateTime? trialEndDate,
152+
DateTime? endDate,
153+
required bool cancelled,
134154
required String subscriptionId,
135155
required String planProductId,
136156
required String planName,
@@ -141,6 +161,8 @@ class _SubscriptionInfoImpl extends SubscriptionInfo {
141161
createdAt: createdAt,
142162
startDate: startDate,
143163
trialEndDate: trialEndDate,
164+
endDate: endDate,
165+
cancelled: cancelled,
144166
subscriptionId: subscriptionId,
145167
planProductId: planProductId,
146168
planName: planName,
@@ -157,6 +179,8 @@ class _SubscriptionInfoImpl extends SubscriptionInfo {
157179
DateTime? createdAt,
158180
DateTime? startDate,
159181
Object? trialEndDate = _Undefined,
182+
Object? endDate = _Undefined,
183+
bool? cancelled,
160184
String? subscriptionId,
161185
String? planProductId,
162186
String? planName,
@@ -170,6 +194,8 @@ class _SubscriptionInfoImpl extends SubscriptionInfo {
170194
trialEndDate: trialEndDate is DateTime?
171195
? trialEndDate
172196
: this.trialEndDate,
197+
endDate: endDate is DateTime? ? endDate : this.endDate,
198+
cancelled: cancelled ?? this.cancelled,
173199
subscriptionId: subscriptionId ?? this.subscriptionId,
174200
planProductId: planProductId ?? this.planProductId,
175201
planName: planName ?? this.planName,

ground_control_client/lib/src/test_tools/builders/subscription_info_builder.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ class SubscriptionInfoBuilder {
44
DateTime _createdAt;
55
DateTime _startDate;
66
DateTime? _trialEndDate;
7+
DateTime? _endDate;
8+
bool _cancelled;
79
String _subscriptionId;
810
String _planProductId;
911
String _planDisplayName;
@@ -14,6 +16,8 @@ class SubscriptionInfoBuilder {
1416
: _createdAt = DateTime.now(),
1517
_startDate = DateTime.now(),
1618
_trialEndDate = DateTime.now().add(Duration(days: 7)),
19+
_endDate = null,
20+
_cancelled = false,
1721
_subscriptionId = 'test-subscription-id',
1822
_planProductId = 'early-access:0',
1923
_planDisplayName = 'Early Access',
@@ -35,6 +39,16 @@ class SubscriptionInfoBuilder {
3539
return this;
3640
}
3741

42+
SubscriptionInfoBuilder withEndDate(final DateTime? endDate) {
43+
_endDate = endDate;
44+
return this;
45+
}
46+
47+
SubscriptionInfoBuilder withCancelled(final bool cancelled) {
48+
_cancelled = cancelled;
49+
return this;
50+
}
51+
3852
SubscriptionInfoBuilder withSubscriptionId(final String subscriptionId) {
3953
_subscriptionId = subscriptionId;
4054
return this;
@@ -66,6 +80,8 @@ class SubscriptionInfoBuilder {
6680
createdAt: _createdAt,
6781
startDate: _startDate,
6882
trialEndDate: _trialEndDate,
83+
endDate: _endDate,
84+
cancelled: _cancelled,
6985
subscriptionId: _subscriptionId,
7086
planProductId: _planProductId,
7187
planName: _planDisplayName,

0 commit comments

Comments
 (0)