orderItemsQuoteAmendment method
- String id,
- String idempotencyKey, {
- AmendmentQuoteRequest? amendmentQuoteRequest,
- Future<
void> ? abortTrigger,
Quote an amendment
Quotes a change to a delivered order item. Available only when the item's actions.amendment is available: the item must be fulfilled, not refunded, and its product must support automatic changes. Items whose changes need manual review show manualReview and use the manual amendment routes instead. A kind of item that can never be amended returns 422 with code 18002 (AMENDMENT_NOT_SUPPORTED); otherwise an amendment that is not allowed now returns 409 with code 18003 (AMENDMENT_NOT_AVAILABLE), and details[0].reason repeats actions.amendment.availability (MANUAL_REVIEW or NOT_AVAILABLE). An item of another partner, or an unknown id, returns 404 with code 10004. Send the requested change in attributes, in the shape the item's product defines; top-level names that start with _ are reserved for OpenRoam and ignored. The response has an amendmentRequestId, the time the quote was made (processedAt), the time it expires (expiresAt) and one or more options, each with an id, an amountToPay and an amountToRefund in the API key's currency, and an amendmentFee: a fee for the change, already included in those amounts, or null when none applies. Nothing changes and nothing is charged until you confirm the quote with POST /order-items/{id}/amendments/confirm, before expiresAt. Requires an Idempotency-Key header (a UUID). Repeating a completed request with the same key returns 409 with code 12000 (IDEMPOTENCY_KEY_ALREADY_USED); one still running returns 409 with code 12002 (IDEMPOTENCY_KEY_IN_PROGRESS), and a different body with the same key 409 with code 12001. A request that ended in an error can be sent again with the same key and body.
Parameters:
-
String id (required): Order item id (
items[].idfrom the order response). -
String idempotencyKey (required): UUID idempotency key for safe retries of this operation.
-
AmendmentQuoteRequest amendmentQuoteRequest: The requested change.
Implementation
Future<AmendmentQuote?> orderItemsQuoteAmendment(String id, String idempotencyKey, { AmendmentQuoteRequest? amendmentQuoteRequest, Future<void>? abortTrigger, }) async {
final response = await orderItemsQuoteAmendmentWithHttpInfo(id, idempotencyKey, amendmentQuoteRequest: amendmentQuoteRequest, 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), 'AmendmentQuote',) as AmendmentQuote;
}
return null;
}