export type SignView = {email?: string | undefined, password?: string | undefined}; export type CreateApiAuthPartnerArgs = {'client-id'?: string | undefined, 'client-secret'?: string | undefined, body: SignView}; export type CreateApiAuthPartnerOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Authorize to the partner portal * * POST /auth/partner */ export const createApiAuthPartner = async (args: CreateApiAuthPartnerArgs, options?: CreateApiAuthPartnerOptions) => { 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(/\/+$/, '')}/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() };