export type CreateApiTargetingSegmentsTaxonomyUploadArgs = {body: BodyInit}; export type CreateApiTargetingSegmentsTaxonomyUploadOptions = {baseUrl?: string | undefined, Auth0?: string | undefined, fetch?: typeof fetch | undefined}; /** * Dry-run Taxonomy Upload * * POST /targeting_segments/taxonomy_upload */ export const createApiTargetingSegmentsTaxonomyUpload = async (args: CreateApiTargetingSegmentsTaxonomyUploadArgs, options?: CreateApiTargetingSegmentsTaxonomyUploadOptions) => { const {baseUrl = "https://api.mediamath.com/api/v3.0", fetch: fetchFn = fetch, Auth0} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (Auth0 !== undefined) headers.set('authorization', `Bearer ${Auth0}`) const url = `${baseUrl.replace(/\/+$/, '')}/targeting_segments/taxonomy_upload${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: 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() };