import type { Square } from "square" import { defineSquareOperation } from "../lib" /** Creates a digital gift card or registers a physical (plastic) gift card. */ export const createSquareGiftCard = defineSquareOperation< Square.CreateGiftCardRequest, Square.CreateGiftCardResponse >({ allowedKeys: ["idempotencyKey", "locationId", "giftCard"], description: "Creates a digital gift card or registers a physical (plastic) gift card.", execute: (api, input) => api.giftCards.create(input), name: "Create Square Gift Card", replaySafety: "safe", requiredKeys: ["idempotencyKey", "locationId", "giftCard"], scopes: ["GIFTCARDS_WRITE"], }) /** * Links a customer to a gift card, which is also referred to as adding a card * on file. */ export const linkSquareCustomerToGiftCard = defineSquareOperation< Square.LinkCustomerToGiftCardRequest, Square.LinkCustomerToGiftCardResponse >({ allowedKeys: ["giftCardId", "customerId"], description: "Links a customer to a gift card, which is also referred to as adding a card on file.", execute: (api, input) => api.giftCards.linkCustomer(input), name: "Link Square Customer To Gift Card", replaySafety: "unsafe", requiredKeys: ["giftCardId", "customerId"], scopes: ["GIFTCARDS_WRITE"], }) /** Lists all gift cards. */ export const listSquareGiftCards = defineSquareOperation< Square.ListGiftCardsRequest, Square.ListGiftCardsResponse >({ allowedKeys: ["type", "state", "limit", "cursor", "customerId"], description: "Lists all gift cards.", execute: (api, input) => api.giftCards.list(input), name: "List Square Gift Cards", replaySafety: "safe", requiredKeys: [], scopes: ["GIFTCARDS_READ"], }) /** Retrieves a gift card using the gift card ID. */ export const retrieveSquareGiftCard = defineSquareOperation< Square.GetGiftCardsRequest, Square.GetGiftCardResponse >({ allowedKeys: ["id"], description: "Retrieves a gift card using the gift card ID.", execute: (api, input) => api.giftCards.get(input), name: "Retrieve Square Gift Card", replaySafety: "safe", requiredKeys: ["id"], scopes: ["GIFTCARDS_READ"], }) /** Retrieves a gift card using the gift card account number (GAN). */ export const retrieveSquareGiftCardFromGAN = defineSquareOperation< Square.GetGiftCardFromGanRequest, Square.GetGiftCardFromGanResponse >({ allowedKeys: ["gan"], description: "Retrieves a gift card using the gift card account number (GAN).", execute: (api, input) => api.giftCards.getFromGan(input), name: "Retrieve Square Gift Card From GAN", replaySafety: "safe", requiredKeys: ["gan"], scopes: ["GIFTCARDS_READ"], }) /** * Retrieves a gift card using a secure payment token that represents the gift * card. */ export const retrieveSquareGiftCardFromNonce = defineSquareOperation< Square.GetGiftCardFromNonceRequest, Square.GetGiftCardFromNonceResponse >({ allowedKeys: ["nonce"], description: "Retrieves a gift card using a secure payment token that represents the gift card.", execute: (api, input) => api.giftCards.getFromNonce(input), name: "Retrieve Square Gift Card From Nonce", replaySafety: "safe", requiredKeys: ["nonce"], scopes: ["GIFTCARDS_READ"], }) /** * Unlinks a customer from a gift card, which is also referred to as removing a * card on file. */ export const unlinkSquareCustomerFromGiftCard = defineSquareOperation< Square.UnlinkCustomerFromGiftCardRequest, Square.UnlinkCustomerFromGiftCardResponse >({ allowedKeys: ["giftCardId", "customerId"], description: "Unlinks a customer from a gift card, which is also referred to as removing a card on file.", execute: (api, input) => api.giftCards.unlinkCustomer(input), name: "Unlink Square Customer From Gift Card", replaySafety: "unsafe", requiredKeys: ["giftCardId", "customerId"], scopes: ["GIFTCARDS_WRITE"], })