listPlans method

Future<PlanCollection> listPlans({
  1. String? productId,
  2. String? planIds,
  3. int? pageSize,
  4. int? page,
  5. bool? totalRequired,
})

Lists billing plans.

Parameter productId: Filters the response by a Product ID.

Parameter plans_ids: Filters the response by list of plan IDs. Filter supports upto 10 plan IDs.

Parameter page_size: The number of items to return in the response.

Parameter page: A non-zero integer which is the start index of the entire list of items to return in the response. The combination of page=1 and page_size=20 returns the first 20 items. The combination of page=2 and page_size=20 returns the next 20 items.

Parameter total_required: Indicates whether to show the total count in the response.

Implementation

Future<PlanCollection> listPlans(
    {String? productId,
    String? planIds,
    int? pageSize,
    int? page,
    bool? totalRequired}) async {
  var url = _payPalHttpClient.getUrl(
    '/v1/billing/plans',
    queryParameters: {
      'product_id': productId,
      'plan_ids': planIds,
      'page_size': pageSize?.toString(),
      'page': page?.toString(),
      'total_required': totalRequired?.toString(),
    },
  );

  var response = await _payPalHttpClient.get(url);
  return PlanCollection.fromJson(jsonDecode(response.body));
}