userSubscriptions static method
Implementation
static Future<List<PLYSubscription>> userSubscriptions() async {
final List<dynamic> result =
await _channel.invokeMethod('userSubscriptions');
final List<PLYSubscription> subscriptions = new List.empty(growable: true);
result.forEach((element) {
final List<PLYPlan?> plans = new List.empty(growable: true);
var product = null;
if (element['product'] != null) {
element['product']['plans']
?.forEach((k, plan) => plans.add(transformToPLYPlan(plan)));
product = PLYProduct(element['product']['name'],
element['product']['vendorId'], plans.whereNotNull().toList());
}
subscriptions.add(PLYSubscription(
element['purchaseToken'],
PLYSubscriptionSource.values[element['subscriptionSource']],
element['nextRenewalDate'],
element['cancelledDate'],
transformToPLYPlan(element['plan']),
product));
});
return subscriptions;
}