getFreights method

Future<ApiCallback<List<Freight>>> getFreights(
  1. {String cartId}
)

Implementation

Future<ApiCallback<List<Freight>>> getFreights({String cartId}) async {
  try {
    if (cartId == null) cartId = await _getDefaultCartId();

    var response = await _requester
        .get(GET_FREIGHTS.replaceAll(PARAMETER_CART_ID, cartId));
    // Parse result
    var responseData = response.data as List;
    var freights = List<Freight>();
    for (var row in responseData) {
      freights.add(Freight.fromJson(row));
    }

    // Callback invocation
    return ApiCallback<List<Freight>>(
        isSuccessful: true, resultData: freights);
  } on DioError catch (e) {
    return ApiCallback<List<Freight>>().defaultErrorCallback(e);
  }
}