import type { Square } from "square" import { defineSquareOperation } from "../lib" /** * Creates a DeviceCode that can be used to login to a Square Terminal device to * enter the connected terminal mode. */ export const createSquareDeviceCode = defineSquareOperation< Square.devices.CreateDeviceCodeRequest, Square.CreateDeviceCodeResponse >({ allowedKeys: ["idempotencyKey", "deviceCode"], description: "Creates a DeviceCode that can be used to login to a Square Terminal device to enter the connected terminal mode.", execute: (api, input) => api.devices.codes.create(input), name: "Create Square Device Code", replaySafety: "safe", requiredKeys: ["idempotencyKey", "deviceCode"], scopes: ["DEVICE_CREDENTIAL_MANAGEMENT"], }) /** Retrieves Device with the associated `device_id`. */ export const getSquareDevice = defineSquareOperation< Square.GetDevicesRequest, Square.GetDeviceResponse >({ allowedKeys: ["deviceId"], description: "Retrieves Device with the associated `device_id`.", execute: (api, input) => api.devices.get(input), name: "Get Square Device", replaySafety: "safe", requiredKeys: ["deviceId"], scopes: ["DEVICES_READ"], }) /** Retrieves DeviceCode with the associated ID. */ export const getSquareDeviceCode = defineSquareOperation< Square.devices.GetCodesRequest, Square.GetDeviceCodeResponse >({ allowedKeys: ["id"], description: "Retrieves DeviceCode with the associated ID.", execute: (api, input) => api.devices.codes.get(input), name: "Get Square Device Code", replaySafety: "safe", requiredKeys: ["id"], scopes: ["DEVICE_CREDENTIAL_MANAGEMENT"], }) /** Lists all DeviceCodes associated with the merchant. */ export const listSquareDeviceCodes = defineSquareOperation< Square.devices.ListCodesRequest, Square.ListDeviceCodesResponse >({ allowedKeys: ["cursor", "locationId", "productType", "status"], description: "Lists all DeviceCodes associated with the merchant.", execute: (api, input) => api.devices.codes.list(input), name: "List Square Device Codes", replaySafety: "safe", requiredKeys: [], scopes: ["DEVICE_CREDENTIAL_MANAGEMENT"], }) /** List devices associated with the merchant. */ export const listSquareDevices = defineSquareOperation< Square.ListDevicesRequest, Square.ListDevicesResponse >({ allowedKeys: ["cursor", "sortOrder", "limit", "locationId"], description: "List devices associated with the merchant.", execute: (api, input) => api.devices.list(input), name: "List Square Devices", replaySafety: "safe", requiredKeys: [], scopes: ["DEVICES_READ"], })