orderItemsGetCancellationPreview method
Preview an item cancellation
Previews the cancellation penalty and expected refund for an order item. Requires the read order permission. Returns penaltyAmount, the cancellationFee kept in addition to it (null when none applies) and the expected refundAmount, all in the order currency, isRefundable, the cancellation band in effect, priced at the penalty (appliedPenalties: at most one { from, penaltyAmount }), effectiveCancellationDate and checkInDate, calculated with the same rules as the partner portal. The fee comes out of what the penalty leaves, so the refund is never negative. isRefundable: false means the penalty alone keeps the whole price, so the item cannot be cancelled; it is not an error. A fee that takes what the penalty leaves does not make it false: the item can still be cancelled, with a refund of 0. The preview does not cancel the item or change its state, and it does not lock the penalty: the cancel call recalculates it, so a later cancellation band may apply. A kind of item that can never be cancelled returns 422 with code 18000 (CANCELLATION_NOT_SUPPORTED); an item of another partner, or an unknown id, returns 404 with code 10004.
Parameters:
- String id (required):
Order item id (
items[].idfrom the order response).
Implementation
Future<OrderItemCancellationPreview?> orderItemsGetCancellationPreview(String id, { Future<void>? abortTrigger, }) async {
final response = await orderItemsGetCancellationPreviewWithHttpInfo(id, abortTrigger: abortTrigger,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'OrderItemCancellationPreview',) as OrderItemCancellationPreview;
}
return null;
}