pub struct OrdersApi { /* private fields */ }
Expand description
Get sales data for a Square seller, itemize payments, push orders to POS, and more.
Implementations§
Source§impl OrdersApi
impl OrdersApi
Sourcepub fn new(config: Configuration, client: HttpClient) -> Self
pub fn new(config: Configuration, client: HttpClient) -> Self
Instantiates a new OrdersApi
Sourcepub async fn create_order(
&self,
body: &CreateOrderRequest,
) -> Result<CreateOrderResponse, ApiError>
pub async fn create_order( &self, body: &CreateOrderRequest, ) -> Result<CreateOrderResponse, ApiError>
Creates a new order that can include information about products for purchase and settings to apply to the purchase.
To pay for a created order, see Pay for Orders.
You can modify open orders using the UpdateOrder endpoint.
Sourcepub async fn batch_retrieve_orders(
&self,
body: &BatchRetrieveOrdersRequest,
) -> Result<BatchRetrieveOrdersResponse, ApiError>
pub async fn batch_retrieve_orders( &self, body: &BatchRetrieveOrdersRequest, ) -> Result<BatchRetrieveOrdersResponse, ApiError>
Retrieves a set of orders by their IDs.
If a given order ID does not exist, the ID is ignored instead of generating an error.
Sourcepub async fn calculate_order(
&self,
body: &CalculateOrderRequest,
) -> Result<CalculateOrderResponse, ApiError>
pub async fn calculate_order( &self, body: &CalculateOrderRequest, ) -> Result<CalculateOrderResponse, ApiError>
Enables applications to preview order pricing without creating an order.
Sourcepub async fn clone_order(
&self,
body: &CloneOrderRequest,
) -> Result<CloneOrderResponse, ApiError>
pub async fn clone_order( &self, body: &CloneOrderRequest, ) -> Result<CloneOrderResponse, ApiError>
Creates a new order, in the DRAFT
state, by duplicating an existing order.
The newly created order has only the core fields (such as line items, taxes, and discounts) copied from the original order.
Sourcepub async fn search_orders(
&self,
body: &SearchOrdersRequest,
) -> Result<SearchOrdersResponse, ApiError>
pub async fn search_orders( &self, body: &SearchOrdersRequest, ) -> Result<SearchOrdersResponse, ApiError>
Search all orders for one or more locations.
Orders include all sales, returns, and exchanges regardless of how or when they entered the Square ecosystem (such as Point of Sale, Invoices, and Connect APIs).
SearchOrders
requests need to specify which locations to search and define a
[SearchOrdersQuery] object that controls how to sort or filter the results. Your
SearchOrdersQuery
can:
Set filter criteria. Set the sort order. Determine whether to return results as complete [Order] objects or as [OrderEntry] objects.
Note that details for orders processed with Square Point of Sale while in offline mode might
not be transmitted to Square for up to 72 hours. Offline orders have a created_at
value
that reflects the time the order was created, not the time it was subsequently transmitted
to Square.
Sourcepub async fn retrieve_order(
&self,
order_id: &str,
) -> Result<RetrieveOrderResponse, ApiError>
pub async fn retrieve_order( &self, order_id: &str, ) -> Result<RetrieveOrderResponse, ApiError>
Retrieves an [Order] by ID.
Sourcepub async fn update_order(
&self,
order_id: &str,
body: &UpdateOrderRequest,
) -> Result<UpdateOrderResponse, ApiError>
pub async fn update_order( &self, order_id: &str, body: &UpdateOrderRequest, ) -> Result<UpdateOrderResponse, ApiError>
Updates an open [Order] by adding, replacing, or deleting fields.
Orders with a COMPLETED
or CANCELED
state cannot be updated.
An UpdateOrder
request requires the following:
- The
order_id
in the endpoint path, identifying the order to update. - The latest
version
of the order to update. - The sparse order containing only the fields to update and the version to which the update is being applied.
- If deleting fields, the dot notation paths identifying the fields to clear.
To pay for an order, see Pay for Orders.
Sourcepub async fn pay_order(
&self,
order_id: &str,
body: &PayOrderRequest,
) -> Result<PayOrderResponse, ApiError>
pub async fn pay_order( &self, order_id: &str, body: &PayOrderRequest, ) -> Result<PayOrderResponse, ApiError>
Pay for an [Order] using one or more approved [Payment]s or settle an order with a total of
0
.
The total of the payment_ids
listed in the request must be equal to the order total.
Orders with a total amount of 0
can be marked as paid by specifying an empty array of
payment_ids
in the request.
To be used with PayOrder
, a payment must:
- Reference the order by specifying the
order_id
when creating the payment. Any approved payments that reference the sameorder_id
not specified in thepayment_ids
is canceled. - Be approved with delayed
capture.
Using a delayed capture payment with
PayOrder
completes the approved payment.