export type GiftCheckout = {use_credit?: boolean | undefined, plan?: ('supporter' | 'vip') | undefined, duration?: (1 | 3 | 6 | 12) | undefined, recipient_user_id?: (number | null) | undefined, message?: string | undefined, anonymous?: boolean | undefined}; export type CreateApiApiSubscriptionsGiftCheckoutArgs = {body: GiftCheckout}; export type CreateApiApiSubscriptionsGiftCheckoutOptions = {baseUrl?: string | undefined, Basic?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Offrir un abonnement (checkout CryptoGate) * * POST /api/subscriptions/gift/checkout/ */ export const createApiApiSubscriptionsGiftCheckout = async (args: CreateApiApiSubscriptionsGiftCheckoutArgs, options?: CreateApiApiSubscriptionsGiftCheckoutOptions) => { const {baseUrl = "https://api.jeuxcracks.fr", fetch: fetchFn = fetch, Basic} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (Basic !== undefined) headers.set('authorization', `Basic ${btoa(`${Basic.username}:${Basic.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/subscriptions/gift/checkout/${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 };