getProductShippingClasses method

Future<List<WooProductShippingClass>> getProductShippingClasses({
  1. int? page,
  2. int? perPage,
  3. String? search,
  4. List<int>? exclude,
  5. List<int>? include,
  6. int? offset,
  7. String? order,
  8. String? orderBy,
  9. bool? hideEmpty,
  10. int? product,
  11. String? slug,
})

Implementation

Future<List<WooProductShippingClass>> getProductShippingClasses(
    {int? page,
    int? perPage,
    String? search,
    List<int>? exclude,
    List<int>? include,
    int? offset,
    String? order,
    String? orderBy,
    bool? hideEmpty,
    int? product,
    String? slug}) async {
  Map<String, dynamic> payload = {};
  ({
    'page': page,
    'per_page': perPage,
    'search': search,
    'exclude': exclude,
    'include': include,
    'offset': offset,
    'order': order,
    'orderby': orderBy,
    'hide_empty': hideEmpty,
    'product': product,
    'slug': slug,
  }).forEach((k, v) {
    if (v != null) payload[k] = v.toString();
  });
  List<WooProductShippingClass> productShippingClasses = [];
  _setApiResourceUrl(
    path: 'products/shipping_classes',
  );
  final response = await get(queryUri.toString());
  _printToLog('response gotten : ' + response.toString());
  for (var c in response) {
    var sClass = WooProductShippingClass.fromJson(c);
    _printToLog('prod gotten here : ' + sClass.toString());
    productShippingClasses.add(sClass);
  }
  return productShippingClasses;
}