putModality method

Future<ApiCallback<void>> putModality(
  1. {@required String modalityId,
  2. String cartId}
)

Implementation

Future<ApiCallback<void>> putModality(
    {@required String modalityId, String cartId}) async {
  try {
    if (cartId == null) cartId = await _getDefaultCartId();

    var response = await _requester.put(PUT_MODALITY
        .replaceAll(PARAMETER_CART_ID, cartId)
        .replaceAll(PARAMETER_MODALITY_ID, modalityId));
    // Parse the new cart
    var parsedCart = Cart.fromJson(response.data);
    // Save it locally
    await CartDao().insertOrUpdate(parsedCart);

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