export type SignView = {email?: string | undefined, password?: string | undefined}; export type CreateApiV2AuthPartnerArgs = {'client-id'?: string | undefined, 'client-secret'?: string | undefined, body: SignView}; export type CreateApiV2AuthPartnerOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Authorize to the partner portal * * POST /v2/auth/partner */ export const createApiV2AuthPartner = async (args: CreateApiV2AuthPartnerArgs, options?: CreateApiV2AuthPartnerOptions) => { const {baseUrl = "https://api.cloudally.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (args['client-id'] != null) headers.set("client-id", String(args['client-id'])) if (args['client-secret'] != null) headers.set("client-secret", String(args['client-secret'])) const url = `${baseUrl.replace(/\/+$/, '')}/v2/auth/partner${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 res.blob() };