ordersGetById method

Future<Order?> ordersGetById(
  1. String id, {
  2. Future<void>? abortTrigger,
})

Get an order

Gets the current state of one order. Returns the same shape as order creation: id, referenceId, origin, status, total, payment, actions, items, timeline, createdAt, updatedAt and fulfillmentVersion. This is the source of truth for the order: webhooks are snapshots of an event, so read the order again after a missed or out-of-order delivery. Order status moves from paymentPending to paid once the wallet is charged, then to processing while items are delivered, and ends as completed (every item fulfilled), partiallyFulfilled (some items fulfilled, the rest rejected), fulfillmentFailed (no item fulfilled) or cancelled. Each item reports its own fulfillment.status: pending, fulfilled with a typed result, or rejected with a safe failure (11001, FULFILLMENT_REJECTED). actions and items[].actions say whether payment retry, fulfillment retry, amendment and cancellation are available now. An order of another partner, or an unknown id, returns 404 with code 10004.

Parameters:

  • String id (required): Order id (id from the order response).

Implementation

Future<Order?> ordersGetById(String id, { Future<void>? abortTrigger, }) async {
  final response = await ordersGetByIdWithHttpInfo(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), 'Order',) as Order;

  }
  return null;
}