export type SegmentRequest = {name: string, code?: string | undefined}; export type UpdateApiChannelV1SegmentsCompanySegmentIdArgs = {companySegmentId: string, body: SegmentRequest}; export type UpdateApiChannelV1SegmentsCompanySegmentIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update manual segments * * PUT /channel/v1/segments/{companySegmentId} */ export const updateApiChannelV1SegmentsCompanySegmentId = async (args: UpdateApiChannelV1SegmentsCompanySegmentIdArgs, options?: UpdateApiChannelV1SegmentsCompanySegmentIdOptions) => { 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))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };