export type IdempotencyKeyULID = unknown; export type AllocationTemplateExchangeSupplier = {type: 'exchange', percentage_max: number, percentage_min: number | null}; export type AllocationTemplateSupplier = {supplier_id: number}; export type AllocationTemplateGroupSupplier = {type: 'group', name: string, percentage_max: number, percentage_min: number | null, suppliers: Array}; export type AllocationTemplateBlockedSupplier = {type: 'blocked', suppliers: Array}; export type AllocationTemplateCreateRequest = {name: string, supply_allocations: Array}; export type CreateApiDemandAccountsAccountIdAllocationTemplatesArgs = {'idempotency-key': IdempotencyKeyULID, body: AllocationTemplateCreateRequest}; export type CreateApiDemandAccountsAccountIdAllocationTemplatesOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create an allocation template * * POST /demand/accounts/{account_id}/allocation-templates */ export const createApiDemandAccountsAccountIdAllocationTemplates = async (args: CreateApiDemandAccountsAccountIdAllocationTemplatesArgs, options?: CreateApiDemandAccountsAccountIdAllocationTemplatesOptions) => { const {baseUrl = "https://api.cint.com/v1", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['idempotency-key'] != null) headers.set("idempotency-key", String(args['idempotency-key'])) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/demand/accounts/${encodeURIComponent(String(args.account_id))}/allocation-templates${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 undefined };