Skip to content

Commit 3034724

Browse files
author
serverpod_cloud
committed
feat(console): ad7716ca98fda8c8f6fe81b1c041f06a15efe00b
1 parent 9f530d7 commit 3034724

3 files changed

Lines changed: 102 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import 'package:ground_control_client/ground_control_client.dart';
2+
import 'package:ground_control_client/ground_control_client_test_tools.dart';
3+
4+
class PaymentMethodBuilder {
5+
String _id;
6+
String _type;
7+
PaymentMethodCard? _card;
8+
9+
PaymentMethodBuilder()
10+
: _id = 'pm_test_1234567890',
11+
_type = 'card',
12+
_card = PaymentMethodCardBuilder().build();
13+
14+
PaymentMethodBuilder withId(String id) {
15+
_id = id;
16+
return this;
17+
}
18+
19+
PaymentMethodBuilder withType(String type) {
20+
_type = type;
21+
return this;
22+
}
23+
24+
PaymentMethodBuilder withCard(PaymentMethodCard? card) {
25+
_card = card;
26+
return this;
27+
}
28+
29+
PaymentMethodBuilder withCardBuilder(PaymentMethodCardBuilder cardBuilder) {
30+
_card = cardBuilder.build();
31+
return this;
32+
}
33+
34+
PaymentMethod build() {
35+
return PaymentMethod(
36+
id: _id,
37+
type: _type,
38+
card: _card,
39+
);
40+
}
41+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import 'package:ground_control_client/ground_control_client.dart';
2+
3+
class PaymentMethodCardBuilder {
4+
String _brand;
5+
String _last4;
6+
int _expMonth;
7+
int _expYear;
8+
String? _funding;
9+
String? _country;
10+
11+
PaymentMethodCardBuilder()
12+
: _brand = 'visa',
13+
_last4 = '4242',
14+
_expMonth = 12,
15+
_expYear = 2025,
16+
_funding = 'credit',
17+
_country = 'US';
18+
19+
PaymentMethodCardBuilder withBrand(String brand) {
20+
_brand = brand;
21+
return this;
22+
}
23+
24+
PaymentMethodCardBuilder withLast4(String last4) {
25+
_last4 = last4;
26+
return this;
27+
}
28+
29+
PaymentMethodCardBuilder withExpMonth(int expMonth) {
30+
_expMonth = expMonth;
31+
return this;
32+
}
33+
34+
PaymentMethodCardBuilder withExpYear(int expYear) {
35+
_expYear = expYear;
36+
return this;
37+
}
38+
39+
PaymentMethodCardBuilder withFunding(String? funding) {
40+
_funding = funding;
41+
return this;
42+
}
43+
44+
PaymentMethodCardBuilder withCountry(String? country) {
45+
_country = country;
46+
return this;
47+
}
48+
49+
PaymentMethodCard build() {
50+
return PaymentMethodCard(
51+
brand: _brand,
52+
last4: _last4,
53+
expMonth: _expMonth,
54+
expYear: _expYear,
55+
funding: _funding,
56+
country: _country,
57+
);
58+
}
59+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
export 'billing/owner_builder.dart';
22
export 'billing/billing_info_builder.dart';
3+
export 'billing/payment_method_builder.dart';
4+
export 'billing/payment_method_card_builder.dart';
35
export 'role_builder.dart';
46
export 'project_builder.dart';
57
export 'user_builder.dart';

0 commit comments

Comments
 (0)