export type CompanySegmentAssociationsBatchUpdateRequest = {deleteAll: boolean, companyIdsToAdd: Array, companyIdsToRemove: Array}; export type CreateApiChannelV1SegmentsCompanySegmentIdAssociationsBatchUpdateArgs = {companySegmentId: string, body: CompanySegmentAssociationsBatchUpdateRequest}; export type CreateApiChannelV1SegmentsCompanySegmentIdAssociationsBatchUpdateOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create or remove segment-company associations * * POST /channel/v1/segments/{companySegmentId}/associationsBatchUpdate */ export const createApiChannelV1SegmentsCompanySegmentIdAssociationsBatchUpdate = async (args: CreateApiChannelV1SegmentsCompanySegmentIdAssociationsBatchUpdateArgs, options?: CreateApiChannelV1SegmentsCompanySegmentIdAssociationsBatchUpdateOptions) => { const {baseUrl = "https://marketplace.appdirect.com/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/channel/v1/segments/${encodeURIComponent(String(args.companySegmentId))}/associationsBatchUpdate${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 };