export type CreateApiKybCompaniesIdAutomationArgs = {id: string}; export type CreateApiKybCompaniesIdAutomationOptions = {baseUrl?: string | undefined, apiKeyPair?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Re-run company automation * * POST /kyb/companies/{id}/automation/ */ export const createApiKybCompaniesIdAutomation = async (args: CreateApiKybCompaniesIdAutomationArgs, options?: CreateApiKybCompaniesIdAutomationOptions) => { const {baseUrl = "https://ivs.idenfy.com", fetch: fetchFn = fetch, apiKeyPair} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (apiKeyPair !== undefined) headers.set('authorization', `Basic ${btoa(`${apiKeyPair.username}:${apiKeyPair.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/kyb/companies/${encodeURIComponent(String(args.id))}/automation/${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 };