getChildrenCategories method

Future<ApiCallback<List<Category>>> getChildrenCategories(
  1. {@required String parentCategoryId,
  2. bool perSeller = false}
)

Implementation

Future<ApiCallback<List<Category>>> getChildrenCategories({@required String parentCategoryId, bool perSeller = false}) async {
  try {
    var response = await _requester.get(await _catalogEndpoint(API_CATEGORIES_CHILDREN.replaceAll('%', parentCategoryId), includeSeller: perSeller),
        options: Options(responseType: ResponseType.json));
    var responseData = response.data as List;
    var categories = List<Category>();
    for (var row in responseData) {
      categories.add(Category.fromJson(row));
    }
    return ApiCallback<List<Category>>(isSuccessful: true, resultData: categories);
  } on DioError catch (e) {
    return ApiCallback<List<Category>>().defaultErrorCallback(e);
  }
}