import type { Square } from "square" import { defineSquareOperation } from "../lib" /** * Adds points earned from a purchase to a [loyalty * account](entity:LoyaltyAccount). */ export const accumulateSquareLoyaltyPoints = defineSquareOperation< Square.loyalty.AccumulateLoyaltyPointsRequest, Square.AccumulateLoyaltyPointsResponse >({ allowedKeys: [ "accountId", "accumulatePoints", "idempotencyKey", "locationId", ], description: "Adds points earned from a purchase to a [loyalty account](entity:LoyaltyAccount).", execute: (api, input) => api.loyalty.accounts.accumulatePoints(input), name: "Accumulate Square Loyalty Points", replaySafety: "safe", requiredKeys: [ "accountId", "accumulatePoints", "idempotencyKey", "locationId", ], scopes: ["LOYALTY_WRITE"], }) /** Adds points to or subtracts points from a buyer's account. */ export const adjustSquareLoyaltyPoints = defineSquareOperation< Square.loyalty.AdjustLoyaltyPointsRequest, Square.AdjustLoyaltyPointsResponse >({ allowedKeys: [ "accountId", "idempotencyKey", "adjustPoints", "allowNegativeBalance", ], description: "Adds points to or subtracts points from a buyer's account.", execute: (api, input) => api.loyalty.accounts.adjust(input), name: "Adjust Square Loyalty Points", replaySafety: "safe", requiredKeys: ["accountId", "idempotencyKey", "adjustPoints"], scopes: ["LOYALTY_WRITE"], }) /** Calculates the number of points a buyer can earn from a purchase. */ export const calculateSquareLoyaltyPoints = defineSquareOperation< Square.loyalty.CalculateLoyaltyPointsRequest, Square.CalculateLoyaltyPointsResponse >({ allowedKeys: [ "programId", "orderId", "transactionAmountMoney", "loyaltyAccountId", ], description: "Calculates the number of points a buyer can earn from a purchase.", execute: (api, input) => api.loyalty.programs.calculate(input), name: "Calculate Square Loyalty Points", replaySafety: "safe", requiredKeys: ["programId"], scopes: ["LOYALTY_READ"], }) /** Cancels a loyalty promotion. */ export const cancelSquareLoyaltyPromotion = defineSquareOperation< Square.loyalty.programs.CancelPromotionsRequest, Square.CancelLoyaltyPromotionResponse >({ allowedKeys: ["programId", "promotionId"], description: "Cancels a loyalty promotion.", execute: (api, input) => api.loyalty.programs.promotions.cancel(input), name: "Cancel Square Loyalty Promotion", replaySafety: "unsafe", requiredKeys: ["programId", "promotionId"], scopes: ["LOYALTY_WRITE"], }) /** Creates a loyalty account. */ export const createSquareLoyaltyAccount = defineSquareOperation< Square.loyalty.CreateLoyaltyAccountRequest, Square.CreateLoyaltyAccountResponse >({ allowedKeys: ["loyaltyAccount", "idempotencyKey"], description: "Creates a loyalty account.", execute: (api, input) => api.loyalty.accounts.create(input), name: "Create Square Loyalty Account", replaySafety: "safe", requiredKeys: ["loyaltyAccount", "idempotencyKey"], scopes: ["LOYALTY_WRITE"], }) /** Creates a loyalty promotion for a [loyalty program](entity:LoyaltyProgram). */ export const createSquareLoyaltyPromotion = defineSquareOperation< Square.loyalty.programs.CreateLoyaltyPromotionRequest, Square.CreateLoyaltyPromotionResponse >({ allowedKeys: ["programId", "loyaltyPromotion", "idempotencyKey"], description: "Creates a loyalty promotion for a [loyalty program](entity:LoyaltyProgram).", execute: (api, input) => api.loyalty.programs.promotions.create(input), name: "Create Square Loyalty Promotion", replaySafety: "safe", requiredKeys: ["programId", "loyaltyPromotion", "idempotencyKey"], scopes: ["LOYALTY_WRITE"], }) /** Creates a loyalty reward. */ export const createSquareLoyaltyReward = defineSquareOperation< Square.loyalty.CreateLoyaltyRewardRequest, Square.CreateLoyaltyRewardResponse >({ allowedKeys: ["reward", "idempotencyKey"], description: "Creates a loyalty reward.", execute: (api, input) => api.loyalty.rewards.create(input), name: "Create Square Loyalty Reward", replaySafety: "safe", requiredKeys: ["reward", "idempotencyKey"], scopes: ["LOYALTY_WRITE"], }) /** * Deletes a loyalty reward by doing the following: - Returns the loyalty points * back to the loyalty account. */ export const deleteSquareLoyaltyReward = defineSquareOperation< Square.loyalty.DeleteRewardsRequest, Square.DeleteLoyaltyRewardResponse >({ allowedKeys: ["rewardId"], description: "Deletes a loyalty reward by doing the following: - Returns the loyalty points back to the loyalty account.", execute: (api, input) => api.loyalty.rewards.delete(input), name: "Delete Square Loyalty Reward", replaySafety: "safe", requiredKeys: ["rewardId"], scopes: ["LOYALTY_WRITE"], }) /** * Lists the loyalty promotions associated with a [loyalty * program](entity:LoyaltyProgram). */ export const listSquareLoyaltyPromotions = defineSquareOperation< Square.loyalty.programs.ListPromotionsRequest, Square.ListLoyaltyPromotionsResponse >({ allowedKeys: ["programId", "status", "cursor", "limit"], description: "Lists the loyalty promotions associated with a [loyalty program](entity:LoyaltyProgram).", execute: (api, input) => api.loyalty.programs.promotions.list(input), name: "List Square Loyalty Promotions", replaySafety: "safe", requiredKeys: ["programId"], scopes: ["LOYALTY_READ"], }) /** Redeems a loyalty reward. */ export const redeemSquareLoyaltyReward = defineSquareOperation< Square.loyalty.RedeemLoyaltyRewardRequest, Square.RedeemLoyaltyRewardResponse >({ allowedKeys: ["rewardId", "idempotencyKey", "locationId"], description: "Redeems a loyalty reward.", execute: (api, input) => api.loyalty.rewards.redeem(input), name: "Redeem Square Loyalty Reward", replaySafety: "safe", requiredKeys: ["rewardId", "idempotencyKey", "locationId"], scopes: ["LOYALTY_WRITE"], }) /** Retrieves a loyalty account. */ export const retrieveSquareLoyaltyAccount = defineSquareOperation< Square.loyalty.GetAccountsRequest, Square.GetLoyaltyAccountResponse >({ allowedKeys: ["accountId"], description: "Retrieves a loyalty account.", execute: (api, input) => api.loyalty.accounts.get(input), name: "Retrieve Square Loyalty Account", replaySafety: "safe", requiredKeys: ["accountId"], scopes: ["LOYALTY_READ"], }) /** * Retrieves the loyalty program in a seller's account, specified by the program * ID or the keyword `main`. */ export const retrieveSquareLoyaltyProgram = defineSquareOperation< Square.loyalty.GetProgramsRequest, Square.GetLoyaltyProgramResponse >({ allowedKeys: ["programId"], description: "Retrieves the loyalty program in a seller's account, specified by the program ID or the keyword `main`.", execute: (api, input) => api.loyalty.programs.get(input), name: "Retrieve Square Loyalty Program", replaySafety: "safe", requiredKeys: ["programId"], scopes: ["LOYALTY_READ"], }) /** Retrieves a loyalty promotion. */ export const retrieveSquareLoyaltyPromotion = defineSquareOperation< Square.loyalty.programs.GetPromotionsRequest, Square.GetLoyaltyPromotionResponse >({ allowedKeys: ["programId", "promotionId"], description: "Retrieves a loyalty promotion.", execute: (api, input) => api.loyalty.programs.promotions.get(input), name: "Retrieve Square Loyalty Promotion", replaySafety: "safe", requiredKeys: ["programId", "promotionId"], scopes: ["LOYALTY_READ"], }) /** Retrieves a loyalty reward. */ export const retrieveSquareLoyaltyReward = defineSquareOperation< Square.loyalty.GetRewardsRequest, Square.GetLoyaltyRewardResponse >({ allowedKeys: ["rewardId"], description: "Retrieves a loyalty reward.", execute: (api, input) => api.loyalty.rewards.get(input), name: "Retrieve Square Loyalty Reward", replaySafety: "safe", requiredKeys: ["rewardId"], scopes: ["LOYALTY_READ"], }) /** Searches for loyalty accounts in a loyalty program. */ export const searchSquareLoyaltyAccounts = defineSquareOperation< Square.loyalty.SearchLoyaltyAccountsRequest, Square.SearchLoyaltyAccountsResponse >({ allowedKeys: ["query", "limit", "cursor"], description: "Searches for loyalty accounts in a loyalty program.", execute: (api, input) => api.loyalty.accounts.search(input), name: "Search Square Loyalty Accounts", replaySafety: "safe", requiredKeys: [], scopes: ["LOYALTY_READ"], }) /** Searches for loyalty events. */ export const searchSquareLoyaltyEvents = defineSquareOperation< Square.SearchLoyaltyEventsRequest, Square.SearchLoyaltyEventsResponse >({ allowedKeys: ["query", "limit", "cursor"], description: "Searches for loyalty events.", execute: (api, input) => api.loyalty.searchEvents(input), name: "Search Square Loyalty Events", replaySafety: "safe", requiredKeys: [], scopes: ["LOYALTY_READ"], }) /** Searches for loyalty rewards. */ export const searchSquareLoyaltyRewards = defineSquareOperation< Square.loyalty.SearchLoyaltyRewardsRequest, Square.SearchLoyaltyRewardsResponse >({ allowedKeys: ["query", "limit", "cursor"], description: "Searches for loyalty rewards.", execute: (api, input) => api.loyalty.rewards.search(input), name: "Search Square Loyalty Rewards", replaySafety: "safe", requiredKeys: [], scopes: ["LOYALTY_READ"], })