export type CreateApiV0EmailSendPaymentArgs = {body: {email?: string | undefined, amount?: string | undefined, comment?: string | undefined}}; export type CreateApiV0EmailSendPaymentOptions = {baseUrl: string, apikeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Pay to Email * * POST /v0/email/send-payment */ export const createApiV0EmailSendPayment = async (args: CreateApiV0EmailSendPaymentArgs, options: CreateApiV0EmailSendPaymentOptions) => { const {baseUrl, fetch: fetchFn = fetch, apikeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (apikeyAuth !== undefined) headers.set("apikey", apikeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v0/email/send-payment${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 (await res.json()) as unknown };