export type AudienceUpdateOperationType = 'UPDATE' | 'REMOVE'; export type CustomerSegmentUpdateRequestUpdateWithRequiredBody = {audience_ids?: Array | undefined, id: string, operation_type: AudienceUpdateOperationType}; export type PatchApiAdAccountsAdAccountIdCustomerSegmentsArgs = {ad_account_id: string, body: CustomerSegmentUpdateRequestUpdateWithRequiredBody}; export type PatchApiAdAccountsAdAccountIdCustomerSegmentsOptions = {baseUrl?: string | undefined, pinterestOauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update customer segments * * PATCH /ad_accounts/{ad_account_id}/customer_segments */ export const patchApiAdAccountsAdAccountIdCustomerSegments = async (args: PatchApiAdAccountsAdAccountIdCustomerSegmentsArgs, options?: PatchApiAdAccountsAdAccountIdCustomerSegmentsOptions) => { const {baseUrl = "https://api.pinterest.com/v5", fetch: fetchFn = fetch, pinterestOauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (pinterestOauth2 !== undefined) headers.set('authorization', `Bearer ${pinterestOauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/ad_accounts/${encodeURIComponent(String(args.ad_account_id))}/customer_segments${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 };