getCategories method

Future<ApiCallback<List<Category>>> getCategories(
  1. {bool perSeller = false}
)

region Category API endpoints

Implementation

Future<ApiCallback<List<Category>>> getCategories({bool perSeller = false}) async {
  try {
    var response = await _requester.get(await _catalogEndpoint(API_CATEGORIES, includeSeller: perSeller), options: Options(responseType: ResponseType.json));
    var responseData = response.data as List;
    var categories = responseData.map((e) => Category.fromJson(e)).toList();

    return ApiCallback<List<Category>>(isSuccessful: true, resultData: categories);
  } on DioError catch (e) {
    return ApiCallback<List<Category>>().defaultErrorCallback(e);
  }
}