export type CreateApiV2SubjectsSendCodeSmsArgs = {'content-type': 'application/json', body: {phone: string}}; export type CreateApiV2SubjectsSendCodeSmsOptions = {baseUrl?: string | undefined, ucApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Send a verification text to a subject * * POST /v2/subjects/send-code/sms */ export const createApiV2SubjectsSendCodeSms = async (args: CreateApiV2SubjectsSendCodeSmsArgs, options?: CreateApiV2SubjectsSendCodeSmsOptions) => { const {baseUrl = "https://uc.api.osano.com", fetch: fetchFn = fetch, ucApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['content-type'] != null) headers.set("content-type", String(args['content-type'])) if (ucApiKey !== undefined) headers.set("x-uc-api-key", ucApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v2/subjects/send-code/sms${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 };