export type GetApiApiV1PromocodesCountArgs = {type?: string | undefined, activeDueDays?: number | undefined, discount?: number | undefined}; export type GetApiApiV1PromocodesCountOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Get the number of available promotional codes * * GET /api/v1/promocodes/count */ export const getApiApiV1PromocodesCount = async (args: GetApiApiV1PromocodesCountArgs, options?: GetApiApiV1PromocodesCountOptions) => { const {baseUrl = "https://api.reteno.com", fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.type != null) query.append("type", String(args.type)) if (args.activeDueDays != null) query.append("activeDueDays", String(args.activeDueDays)) if (args.discount != null) query.append("discount", String(args.discount)) if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/promocodes/count${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };