export type CreateApiApiV2UsersArgs = {Authorization?: string | undefined, body: Record}; export type CreateApiApiV2UsersOptions = {baseUrl?: string | undefined, noauthAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Cadastrar Usuário * * POST /api/v2/users */ export const createApiApiV2Users = async (args: CreateApiApiV2UsersArgs, options?: CreateApiApiV2UsersOptions) => { const {baseUrl = "https://cloud-hom.bry.com.br", fetch: fetchFn = fetch, noauthAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (noauthAuth !== undefined) headers.set('authorization', `noauth ${noauthAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/users${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 };