Struct OrdersApi

Source
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

Source

pub fn new(config: Configuration, client: HttpClient) -> Self

Instantiates a new OrdersApi

Source

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.

Source

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.

Source

pub async fn calculate_order( &self, body: &CalculateOrderRequest, ) -> Result<CalculateOrderResponse, ApiError>

Enables applications to preview order pricing without creating an order.

Source

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.

Source

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.

Source

pub async fn retrieve_order( &self, order_id: &str, ) -> Result<RetrieveOrderResponse, ApiError>

Retrieves an [Order] by ID.

Source

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.

Source

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 same order_id not specified in the payment_ids is canceled.
  • Be approved with delayed capture. Using a delayed capture payment with PayOrder completes the approved payment.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,