import type { Square } from "square" import { defineSquareOperation } from "../lib" /** Cancels an invoice. */ export const cancelSquareInvoice = defineSquareOperation< Square.CancelInvoiceRequest, Square.CancelInvoiceResponse >({ allowedKeys: ["invoiceId", "version"], description: "Cancels an invoice.", execute: (api, input) => api.invoices.cancel(input), name: "Cancel Square Invoice", replaySafety: "unsafe", requiredKeys: ["invoiceId", "version"], scopes: ["INVOICES_WRITE", "ORDERS_WRITE"], }) /** * Creates a draft [invoice](entity:Invoice) for an order created using the * Orders API. */ export const createSquareInvoice = defineSquareOperation< Square.CreateInvoiceRequest, Square.CreateInvoiceResponse >({ allowedKeys: ["invoice", "idempotencyKey"], description: "Creates a draft [invoice](entity:Invoice) for an order created using the Orders API.", execute: (api, input) => api.invoices.create(input), name: "Create Square Invoice", replaySafety: "unsafe", requiredKeys: ["invoice"], scopes: ["INVOICES_WRITE", "ORDERS_WRITE"], }) /** Uploads a file and attaches it to an invoice. */ export const createSquareInvoiceAttachment = defineSquareOperation< Square.CreateInvoiceAttachmentRequest, Square.CreateInvoiceAttachmentResponse >({ allowedKeys: ["invoiceId", "request", "imageFile"], description: "Uploads a file and attaches it to an invoice.", execute: (api, input) => api.invoices.createInvoiceAttachment(input), name: "Create Square Invoice Attachment", replaySafety: "unsafe", requiredKeys: ["invoiceId"], scopes: ["INVOICES_WRITE"], }) /** Deletes the specified invoice. */ export const deleteSquareInvoice = defineSquareOperation< Square.DeleteInvoicesRequest, Square.DeleteInvoiceResponse >({ allowedKeys: ["invoiceId", "version"], description: "Deletes the specified invoice.", execute: (api, input) => api.invoices.delete(input), name: "Delete Square Invoice", replaySafety: "safe", requiredKeys: ["invoiceId"], scopes: ["INVOICES_WRITE", "ORDERS_WRITE"], }) /** Removes an attachment from an invoice and permanently deletes the file. */ export const deleteSquareInvoiceAttachment = defineSquareOperation< Square.DeleteInvoiceAttachmentRequest, Square.DeleteInvoiceAttachmentResponse >({ allowedKeys: ["invoiceId", "attachmentId"], description: "Removes an attachment from an invoice and permanently deletes the file.", execute: (api, input) => api.invoices.deleteInvoiceAttachment(input), name: "Delete Square Invoice Attachment", replaySafety: "safe", requiredKeys: ["invoiceId", "attachmentId"], scopes: ["INVOICES_WRITE"], }) /** Retrieves an invoice by invoice ID. */ export const getSquareInvoice = defineSquareOperation< Square.GetInvoicesRequest, Square.GetInvoiceResponse >({ allowedKeys: ["invoiceId"], description: "Retrieves an invoice by invoice ID.", execute: (api, input) => api.invoices.get(input), name: "Get Square Invoice", replaySafety: "safe", requiredKeys: ["invoiceId"], scopes: ["INVOICES_READ"], }) /** Returns a list of invoices for a given location. */ export const listSquareInvoices = defineSquareOperation< Square.ListInvoicesRequest, Square.ListInvoicesResponse >({ allowedKeys: ["locationId", "cursor", "limit"], description: "Returns a list of invoices for a given location.", execute: (api, input) => api.invoices.list(input), name: "List Square Invoices", replaySafety: "safe", requiredKeys: ["locationId"], scopes: ["INVOICES_READ"], }) /** Publishes the specified draft invoice. */ export const publishSquareInvoice = defineSquareOperation< Square.PublishInvoiceRequest, Square.PublishInvoiceResponse >({ allowedKeys: ["invoiceId", "version", "idempotencyKey"], description: "Publishes the specified draft invoice.", execute: (api, input) => api.invoices.publish(input), name: "Publish Square Invoice", replaySafety: "unsafe", requiredKeys: ["invoiceId", "version"], scopes: ["INVOICES_WRITE", "ORDERS_WRITE"], }) /** Searches for invoices from a location specified in the filter. */ export const searchSquareInvoices = defineSquareOperation< Square.SearchInvoicesRequest, Square.SearchInvoicesResponse >({ allowedKeys: ["query", "limit", "cursor"], description: "Searches for invoices from a location specified in the filter.", execute: (api, input) => api.invoices.search(input), name: "Search Square Invoices", replaySafety: "safe", requiredKeys: ["query"], scopes: ["INVOICES_READ"], }) /** Updates an invoice. */ export const updateSquareInvoice = defineSquareOperation< Square.UpdateInvoiceRequest, Square.UpdateInvoiceResponse >({ allowedKeys: ["invoiceId", "invoice", "idempotencyKey", "fieldsToClear"], description: "Updates an invoice.", execute: (api, input) => api.invoices.update(input), name: "Update Square Invoice", replaySafety: "safe", requiredKeys: ["invoiceId", "invoice"], scopes: ["INVOICES_WRITE", "ORDERS_WRITE"], })