export type EnrichmentTableUrlRequest = {replace_failed?: boolean | undefined, url: string}; export type CreateApiApiOrgIdEnrichmentTablesTableNameUrlArgs = {org_id: string, table_name: string, append?: boolean | undefined, body: EnrichmentTableUrlRequest}; export type CreateApiApiOrgIdEnrichmentTablesTableNameUrlOptions = {baseUrl: string, Authorization?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create enrichment table from URL * * POST /api/{org_id}/enrichment_tables/{table_name}/url */ export const createApiApiOrgIdEnrichmentTablesTableNameUrl = async (args: CreateApiApiOrgIdEnrichmentTablesTableNameUrlArgs, options: CreateApiApiOrgIdEnrichmentTablesTableNameUrlOptions) => { const {baseUrl, fetch: fetchFn = fetch, Authorization} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "text/plain") if (args.append != null) query.append("append", String(args.append)) if (Authorization !== undefined) headers.set("Authorization", Authorization) const url = `${baseUrl.replace(/\/+$/, '')}/api/${encodeURIComponent(String(args.org_id))}/enrichment_tables/${encodeURIComponent(String(args.table_name))}/url${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.text() };