getSellerItems method

Future<ApiCallback<List<CartItem>>> getSellerItems(
  1. {String cartId,
  2. String sellerId}
)

Implementation

Future<ApiCallback<List<CartItem>>> getSellerItems(
    {String cartId, String sellerId}) async {
  try {
    if (cartId == null) cartId = await _getDefaultCartId();

    var response = await _requester.get(GET_SELLERS_ITEMS
        .replaceAll(PARAMETER_CART_ID, cartId)
        .replaceAll(PARAMETER_SELLER_ID, sellerId));
    // Parse result
    var responseData = response.data as List;
    var cartItems = List<CartItem>();
    for (var row in responseData) {
      cartItems.add(CartItem.fromJson(row));
    }
    // Callback invocation
    return ApiCallback<List<CartItem>>(
        isSuccessful: true, resultData: cartItems);
  } on DioError catch (e) {
    return ApiCallback<List<CartItem>>().defaultErrorCallback(e);
  }
}