giftCardsCreateOrder method
- String idempotencyKey, {
- GiftCardOrderRequest? giftCardOrderRequest,
- Future<
void> ? abortTrigger,
Order gift cards
Places a gift card order and returns the accepted order. Takes the same body as quote and needs the manage order permission (403 / 10003 without it). An Idempotency-Key header with a new UUID is required for every purchase: a retry with the same key and body returns the order already accepted, 202 / 12002 with Retry-After while it is still being accepted, and a changed body gives 409 / 12001. Order with the publicId a quote returned. Every price is recalculated: a current price above inputs.maxPrice gives 409 / 11002 at items[i].inputs.maxPrice before anything is charged. Each card of an item's quantity becomes its own order item; read the codes from the order routes or the order.fulfillment.updated webhook.
Parameters:
-
String idempotencyKey (required): UUID idempotency key for safe retries of this operation.
-
GiftCardOrderRequest giftCardOrderRequest:
Implementation
Future<GiftCardOrder?> giftCardsCreateOrder(String idempotencyKey, { GiftCardOrderRequest? giftCardOrderRequest, Future<void>? abortTrigger, }) async {
final response = await giftCardsCreateOrderWithHttpInfo(idempotencyKey, giftCardOrderRequest: giftCardOrderRequest, 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), 'GiftCardOrder',) as GiftCardOrder;
}
return null;
}