Skip to content

Commit 0ab29e7

Browse files
author
serverpod_cloud
committed
feat: 8131ffd0e73a049b0820df006ea4dcf2e7738126
1 parent d843ab1 commit 0ab29e7

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

ground_control_client/lib/src/protocol/client.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ class EndpointAdminProcurement extends _i1.EndpointRef {
105105

106106
/// Procures a plan for a user.
107107
/// If [planProductVersion] is not provided, the latest version is used.
108-
/// If [trialPeriodOverride] is provided, it will override the trial period (number of days).
108+
/// If [trialPeriodOverride] is provided, it will override the trial period (number of days)
109+
/// in billing. The owner's trial end is synced from the new subscription afterward.
109110
/// If [overrideChecks] is true, the product availability checks are overridden.
110111
///
111112
/// Returns the subscription ID of the created subscription.

ground_control_client/lib/src/protocol/domains/billing/models/owner.dart

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ abstract class Owner implements _i1.SerializableModel {
2929
this.user,
3030
this.billingInfo,
3131
this.projects,
32+
this.trialEndingAt,
33+
this.trialSubscriptionId,
3234
}) : id = id ?? const _i1.Uuid().v4obj(),
3335
createdAt = createdAt ?? DateTime.now(),
3436
updatedAt = updatedAt ?? DateTime.now();
@@ -45,6 +47,8 @@ abstract class Owner implements _i1.SerializableModel {
4547
_i2.User? user,
4648
_i3.BillingInfo? billingInfo,
4749
List<_i4.Project>? projects,
50+
DateTime? trialEndingAt,
51+
String? trialSubscriptionId,
4852
}) = _OwnerImpl;
4953

5054
factory Owner.fromJson(Map<String, dynamic> jsonSerialization) {
@@ -82,6 +86,12 @@ abstract class Owner implements _i1.SerializableModel {
8286
: _i5.Protocol().deserialize<List<_i4.Project>>(
8387
jsonSerialization['projects'],
8488
),
89+
trialEndingAt: jsonSerialization['trialEndingAt'] == null
90+
? null
91+
: _i1.DateTimeJsonExtension.fromJson(
92+
jsonSerialization['trialEndingAt'],
93+
),
94+
trialSubscriptionId: jsonSerialization['trialSubscriptionId'] as String?,
8595
);
8696
}
8797

@@ -109,6 +119,12 @@ abstract class Owner implements _i1.SerializableModel {
109119

110120
List<_i4.Project>? projects;
111121

122+
/// When non-null, the owner's subscription trial ends at this instant (UTC).
123+
DateTime? trialEndingAt;
124+
125+
/// Subscription designated for this owner's trial
126+
String? trialSubscriptionId;
127+
112128
/// Returns a shallow copy of this [Owner]
113129
/// with some or all fields replaced by the given arguments.
114130
@_i1.useResult
@@ -124,6 +140,8 @@ abstract class Owner implements _i1.SerializableModel {
124140
_i2.User? user,
125141
_i3.BillingInfo? billingInfo,
126142
List<_i4.Project>? projects,
143+
DateTime? trialEndingAt,
144+
String? trialSubscriptionId,
127145
});
128146
@override
129147
Map<String, dynamic> toJson() {
@@ -141,6 +159,9 @@ abstract class Owner implements _i1.SerializableModel {
141159
if (billingInfo != null) 'billingInfo': billingInfo?.toJson(),
142160
if (projects != null)
143161
'projects': projects?.toJson(valueToJson: (v) => v.toJson()),
162+
if (trialEndingAt != null) 'trialEndingAt': trialEndingAt?.toJson(),
163+
if (trialSubscriptionId != null)
164+
'trialSubscriptionId': trialSubscriptionId,
144165
};
145166
}
146167

@@ -165,6 +186,8 @@ class _OwnerImpl extends Owner {
165186
_i2.User? user,
166187
_i3.BillingInfo? billingInfo,
167188
List<_i4.Project>? projects,
189+
DateTime? trialEndingAt,
190+
String? trialSubscriptionId,
168191
}) : super._(
169192
id: id,
170193
createdAt: createdAt,
@@ -177,6 +200,8 @@ class _OwnerImpl extends Owner {
177200
user: user,
178201
billingInfo: billingInfo,
179202
projects: projects,
203+
trialEndingAt: trialEndingAt,
204+
trialSubscriptionId: trialSubscriptionId,
180205
);
181206

182207
/// Returns a shallow copy of this [Owner]
@@ -195,6 +220,8 @@ class _OwnerImpl extends Owner {
195220
Object? user = _Undefined,
196221
Object? billingInfo = _Undefined,
197222
Object? projects = _Undefined,
223+
Object? trialEndingAt = _Undefined,
224+
Object? trialSubscriptionId = _Undefined,
198225
}) {
199226
return Owner(
200227
id: id ?? this.id,
@@ -213,6 +240,12 @@ class _OwnerImpl extends Owner {
213240
projects: projects is List<_i4.Project>?
214241
? projects
215242
: this.projects?.map((e0) => e0.copyWith()).toList(),
243+
trialEndingAt: trialEndingAt is DateTime?
244+
? trialEndingAt
245+
: this.trialEndingAt,
246+
trialSubscriptionId: trialSubscriptionId is String?
247+
? trialSubscriptionId
248+
: this.trialSubscriptionId,
216249
);
217250
}
218251
}

0 commit comments

Comments
 (0)