getCustomerDownloads method

Future<List<WooCustomerDownload>> getCustomerDownloads({
  1. required int customerId,
})

Returns a list of all WooCustomerDownload, with filter options.

Related endpoint: https://woocommerce.github.io/woocommerce-rest-api-docs/#customers

Implementation

Future<List<WooCustomerDownload>> getCustomerDownloads(
    {required int customerId}) async {
  List<WooCustomerDownload> customerDownloads = [];
  _setApiResourceUrl(
      path: 'customers/' + customerId.toString() + '/downloads');

  final response = await get(queryUri.toString());
  _printToLog('getting customer downloads : ' + response.toString());
  for (var d in response) {
    var download = WooCustomerDownload.fromJson(d);
    _printToLog('download gotten here : ' + download.toString());
    customerDownloads.add(download);
  }
  return customerDownloads;
}