export type CreateApiApiAuth2faVerificationSendArgs = {providerType: 'TOTP' | 'SMS' | 'EMAIL' | 'BACKUP_CODE'}; export type CreateApiApiAuth2faVerificationSendOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Request 2FA verification code (requestTwoFaVerificationCode) * * POST /api/auth/2fa/verification/send */ export const createApiApiAuth2faVerificationSend = async (args: CreateApiApiAuth2faVerificationSendArgs, options?: CreateApiApiAuth2faVerificationSendOptions) => { const {baseUrl = "https://demo.thingsboard.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.providerType != null) query.append("providerType", String(args.providerType)) const url = `${baseUrl.replace(/\/+$/, '')}/api/auth/2fa/verification/send${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };