11import 'package:stripe/messages.dart' ;
22import 'package:stripe/src/expanded.dart' ;
3+ import 'package:stripe/src/utils/expandable_fields/customer_expandable_field.dart' ;
34import 'package:stripe/src/utils/expandable_fields/discounts_expandable_field.dart' ;
45import 'package:stripe/src/utils/expandable_fields/latest_invoice_expanded_expandable_field.dart' ;
56
67class SubscriptionExpanded {
78 final Subscription subscription;
89 final List <Discount >? discounts;
910 final InvoiceExpanded ? latestInvoice;
11+ final Customer ? customer;
1012
1113 SubscriptionExpanded ({
1214 required this .subscription,
1315 this .discounts,
1416 this .latestInvoice,
17+ this .customer,
1518 });
1619
1720 factory SubscriptionExpanded .fromJson (
@@ -20,20 +23,26 @@ class SubscriptionExpanded {
2023 ) {
2124 List <Discount >? discounts;
2225 if (expand.contains (SubscriptionExpandableField .discounts)) {
23- discounts = DiscountsExpandableField ().extract (json);
26+ discounts = const DiscountsExpandableField ().extract (json);
2427 }
2528
2629 InvoiceExpanded ? latestInvoice;
2730 if (expand.contains (SubscriptionExpandableField .latestInvoice)) {
28- latestInvoice = LatestInvoiceExpandedExpandableField (
31+ latestInvoice = const LatestInvoiceExpandedExpandableField (
2932 expand: {InvoiceExpandableField .paymentIntent},
3033 ).extract (json);
3134 }
3235
36+ Customer ? customer;
37+ if (expand.contains (SubscriptionExpandableField .customer)) {
38+ customer = const CustomerExpandableField ().extract (json);
39+ }
40+
3341 return SubscriptionExpanded (
3442 subscription: Subscription .fromJson (json),
3543 discounts: discounts,
3644 latestInvoice: latestInvoice,
45+ customer: customer,
3746 );
3847 }
3948}
0 commit comments