//native
type Square = {
token: string;
};
/**
* RetrieveLoyaltyProgram
* Retrieves the loyalty program in a seller's account, specified by the program ID or the keyword `main`.
Loyalty programs define how buyers can earn points and redeem points for rewards. Square sellers can have only one loyalty program, which is created and managed from the Seller Dashboard. For more information, see [Loyalty Program Overview](https://developer.squareup.com/docs/loyalty/overview).
*/
export async function main(auth: Square, program_id: string) {
const url = new URL(
`https://connect.squareup.com/v2/loyalty/programs/${program_id}`,
);
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago