export type CreateApiProductsIdentityAccountIdTokenArgs = {account_id: string}; export type CreateApiProductsIdentityAccountIdTokenOptions = {baseUrl?: string | undefined, OidcClientSecretBasic?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * POST /products/identity/{account_id}/token */ export const createApiProductsIdentityAccountIdToken = async (args: CreateApiProductsIdentityAccountIdTokenArgs, options?: CreateApiProductsIdentityAccountIdTokenOptions) => { const {baseUrl = "https://api.sparkvault.com/v1", fetch: fetchFn = fetch, OidcClientSecretBasic} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (OidcClientSecretBasic !== undefined) headers.set('authorization', `Basic ${btoa(`${OidcClientSecretBasic.username}:${OidcClientSecretBasic.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/products/identity/${encodeURIComponent(String(args.account_id))}/token${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 };