putSeller method

Future<ApiCallback<void>> putSeller(
  1. {@required String sellerId,
  2. @required String cartId,
  3. bool updateLocalCart = true}
)

Implementation

Future<ApiCallback<void>> putSeller(
    {@required String sellerId,
    @required String cartId,
    bool updateLocalCart = true}) async {
  try {
    if (cartId == null) cartId = await _getDefaultCartId();

    var response = await _requester.put(PUT_SELLER
        .replaceAll(PARAMETER_CART_ID, cartId)
        .replaceAll(PARAMETER_SELLER_ID, sellerId));
    // Parse the new cart
    var parsedCart = Cart.fromJson(response.data);
    // Save it locally
    if (updateLocalCart) await CartDao().insertOrUpdate(parsedCart);

    return ApiCallback<void>(isSuccessful: true);
  } on DioError catch (e) {
    return ApiCallback<void>().defaultErrorCallback(e);
  }
}