export type GetApi10KbAdminQueuesArgs = {accountId?: string | undefined, queueName?: string | undefined, serviceName?: string | undefined, withHistory?: boolean | undefined, minDate?: string | undefined, maxDate?: string | undefined, withInProcessing?: boolean | undefined, withBusEvents?: boolean | undefined, withNotifications?: boolean | undefined}; export type GetApi10KbAdminQueuesOptions = {baseUrl: string, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Get queues entries * * GET /1.0/kb/admin/queues * * Also accepts auth: Killbill_Api_Key, Killbill_Api_Secret */ export const getApi10KbAdminQueues = async (args: GetApi10KbAdminQueuesArgs, options: GetApi10KbAdminQueuesOptions) => { const {baseUrl, fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.accountId != null) query.append("accountId", String(args.accountId)) if (args.queueName != null) query.append("queueName", String(args.queueName)) if (args.serviceName != null) query.append("serviceName", String(args.serviceName)) if (args.withHistory != null) query.append("withHistory", String(args.withHistory)) if (args.minDate != null) query.append("minDate", String(args.minDate)) if (args.maxDate != null) query.append("maxDate", String(args.maxDate)) if (args.withInProcessing != null) query.append("withInProcessing", String(args.withInProcessing)) if (args.withBusEvents != null) query.append("withBusEvents", String(args.withBusEvents)) if (args.withNotifications != null) query.append("withNotifications", String(args.withNotifications)) if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/1.0/kb/admin/queues${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 undefined };