export type GetApiOfficeTokensArgs = {paymentId?: number | undefined, sourceType?: ('ZENDESK' | 'ZENDESK_CHAT' | 'INTERCOM' | 'HELP_SCOUT' | 'FRESHDESK' | 'KUSTOMER' | 'MANUAL_IMPORT' | 'BROWSER_EXTENSION' | 'AIRCALL' | 'SALESFORCE' | 'HELPSHIFT' | 'DIXA' | 'FRONT' | 'GORGIAS' | 'TALKDESK' | 'FRESHCHAT' | 'GENESYS') | undefined, name?: string | undefined, ownerId?: number | undefined, disabled?: boolean | undefined, sort?: Array | undefined, offset?: number | undefined, limit?: number | undefined, 'X-Zendesk-Doorman-Auth-Response': string}; export type GetApiOfficeTokensOptions = {baseUrl?: string | undefined, zendeskAuthn?: string | undefined, fetch?: typeof fetch | undefined}; /** * GET /office/tokens */ export const getApiOfficeTokens = async (args: GetApiOfficeTokensArgs, options?: GetApiOfficeTokensOptions) => { const {baseUrl = "http://api.klausapp.com", fetch: fetchFn = fetch, zendeskAuthn} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.paymentId != null) query.append("paymentId", String(args.paymentId)) if (args.sourceType != null) query.append("sourceType", String(args.sourceType)) if (args.name != null) query.append("name", String(args.name)) if (args.ownerId != null) query.append("ownerId", String(args.ownerId)) if (args.disabled != null) query.append("disabled", String(args.disabled)) for (const item of args.sort ?? []) query.append("sort", String(item)) if (args.offset != null) query.append("offset", String(args.offset)) if (args.limit != null) query.append("limit", String(args.limit)) if (args['X-Zendesk-Doorman-Auth-Response'] != null) headers.set("X-Zendesk-Doorman-Auth-Response", String(args['X-Zendesk-Doorman-Auth-Response'])) if (zendeskAuthn !== undefined) headers.set("X-Zendesk-Authn", zendeskAuthn) const url = `${baseUrl.replace(/\/+$/, '')}/office/tokens${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };