export type ConsoleViewRequest = {envelopeId?: string | undefined, returnUrl?: string | undefined}; export type CreateApiV21AccountsAccountIdViewsConsoleArgs = {accountId: string, body: ConsoleViewRequest}; export type CreateApiV21AccountsAccountIdViewsConsoleOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Returns a URL to the Docusign eSignature web application. * * POST /v2.1/accounts/{accountId}/views/console */ export const createApiV21AccountsAccountIdViewsConsole = async (args: CreateApiV21AccountsAccountIdViewsConsoleArgs, options?: CreateApiV21AccountsAccountIdViewsConsoleOptions) => { const {baseUrl = "https://www.docusign.net/restapi", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") const url = `${baseUrl.replace(/\/+$/, '')}/v2.1/accounts/${encodeURIComponent(String(args.accountId))}/views/console${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() };