listProducts method

Future<ProductCollection> listProducts({
  1. int? pageSize,
  2. int? page,
  3. bool? totalRequired,
})

Lists products.

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<ProductCollection> listProducts(
    {int? pageSize, int? page, bool? totalRequired}) async {
  var uri = _payPalHttpClient.getUrl(
    '/v1/catalogs/products',
    queryParameters: {
      'page_size': pageSize?.toString(),
      'page': page?.toString(),
      'total_required': totalRequired?.toString(),
    },
  );

  var response = await _payPalHttpClient.get(uri);
  return ProductCollection.fromJson(jsonDecode(response.body));
}