import type { Square } from "square" import { defineSquareOperation } from "../lib" /** Retrieves a set of [orders](entity:Order) by their IDs. */ export const batchRetrieveSquareOrders = defineSquareOperation< Square.BatchGetOrdersRequest, Square.BatchGetOrdersResponse >({ allowedKeys: ["locationId", "orderIds"], description: "Retrieves a set of [orders](entity:Order) by their IDs.", execute: (api, input) => api.orders.batchGet(input), name: "Batch Square Retrieve Orders", replaySafety: "safe", requiredKeys: ["orderIds"], scopes: ["ORDERS_READ"], }) /** Enables applications to preview order pricing without creating an order. */ export const calculateSquareOrder = defineSquareOperation< Square.CalculateOrderRequest, Square.CalculateOrderResponse >({ allowedKeys: ["order", "proposedRewards"], description: "Enables applications to preview order pricing without creating an order.", execute: (api, input) => api.orders.calculate(input), name: "Calculate Square Order", replaySafety: "safe", requiredKeys: ["order"], scopes: [], }) /** Creates a new order, in the `DRAFT` state, by duplicating an existing order. */ export const cloneSquareOrder = defineSquareOperation< Square.CloneOrderRequest, Square.CloneOrderResponse >({ allowedKeys: ["orderId", "version", "idempotencyKey"], description: "Creates a new order, in the `DRAFT` state, by duplicating an existing order.", execute: (api, input) => api.orders.clone(input), name: "Clone Square Order", replaySafety: "unsafe", requiredKeys: ["orderId"], scopes: ["ORDERS_WRITE"], }) /** * Creates a new [order](entity:Order) that can include information about * products for purchase and settings to apply to the purchase. */ export const createSquareOrder = defineSquareOperation< Square.CreateOrderRequest, Square.CreateOrderResponse >({ allowedKeys: ["order", "idempotencyKey"], description: "Creates a new [order](entity:Order) that can include information about products for purchase and settings to apply to the purchase.", execute: (api, input) => api.orders.create(input), name: "Create Square Order", replaySafety: "unsafe", requiredKeys: [], scopes: ["ORDERS_WRITE"], }) /** * Pay for an [order](entity:Order) using one or more approved * [payments](entity:Payment) or settle an order with a total of `0`. */ export const paySquareOrder = defineSquareOperation< Square.PayOrderRequest, Square.PayOrderResponse >({ allowedKeys: ["orderId", "idempotencyKey", "orderVersion", "paymentIds"], description: "Pay for an [order](entity:Order) using one or more approved [payments](entity:Payment) or settle an order with a total of `0`.", execute: (api, input) => api.orders.pay(input), name: "Pay Square Order", replaySafety: "safe", requiredKeys: ["orderId", "idempotencyKey"], scopes: ["ORDERS_WRITE", "PAYMENTS_WRITE"], }) /** Retrieves an [Order](entity:Order) by ID. */ export const retrieveSquareOrder = defineSquareOperation< Square.GetOrdersRequest, Square.GetOrderResponse >({ allowedKeys: ["orderId"], description: "Retrieves an [Order](entity:Order) by ID.", execute: (api, input) => api.orders.get(input), name: "Retrieve Square Order", replaySafety: "safe", requiredKeys: ["orderId"], scopes: ["ORDERS_READ"], }) /** Search all orders for one or more locations. */ export const searchSquareOrders = defineSquareOperation< Square.SearchOrdersRequest, Square.SearchOrdersResponse >({ allowedKeys: ["locationIds", "cursor", "query", "limit", "returnEntries"], description: "Search all orders for one or more locations.", execute: (api, input) => api.orders.search(input), name: "Search Square Orders", replaySafety: "safe", requiredKeys: [], scopes: ["ORDERS_READ"], }) /** * Updates an open [order](entity:Order) by adding, replacing, or deleting * fields. */ export const updateSquareOrder = defineSquareOperation< Square.UpdateOrderRequest, Square.UpdateOrderResponse >({ allowedKeys: ["orderId", "order", "fieldsToClear", "idempotencyKey"], description: "Updates an open [order](entity:Order) by adding, replacing, or deleting fields.", execute: (api, input) => api.orders.update(input), name: "Update Square Order", replaySafety: "safe", requiredKeys: ["orderId"], scopes: ["ORDERS_WRITE"], })