export type EmailsCreateUnsubscribeRequestBody = {email: string}; export type CreateApiV2LoyaltyEmailsUnsubscribesArgs = {body: EmailsCreateUnsubscribeRequestBody}; export type CreateApiV2LoyaltyEmailsUnsubscribesOptions = {baseUrl?: string | undefined, ProgramApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * POST /v2/loyalty_emails/unsubscribes * * Also accepts auth: SiteTokenSecret */ export const createApiV2LoyaltyEmailsUnsubscribes = async (args: CreateApiV2LoyaltyEmailsUnsubscribesArgs, options?: CreateApiV2LoyaltyEmailsUnsubscribesOptions) => { const {baseUrl = "https://api.loyaltylion.com", fetch: fetchFn = fetch, ProgramApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ProgramApiKey !== undefined) headers.set('authorization', `Bearer ${ProgramApiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/loyalty_emails/unsubscribes${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };