export type DateISO = string; export type UpdateOpportunityCloseDateDto = {target: DateISO | null}; export type IdDto = {id: string}; export type UpdateOpportunityDto = {companyId?: string | undefined, name?: string | undefined, description?: (string | null) | undefined, stageId?: string | undefined, ownerId?: (string | null) | undefined, closeDate?: (UpdateOpportunityCloseDateDto | null) | undefined, clientTeam?: Array | undefined}; export type PatchApiOpportunitiesIdArgs = {id: string, body: UpdateOpportunityDto}; export type PatchApiOpportunitiesIdOptions = {baseUrl: string, xApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update an opportunity * * PATCH /opportunities/{id} */ export const patchApiOpportunitiesId = async (args: PatchApiOpportunitiesIdArgs, options: PatchApiOpportunitiesIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, xApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (xApiKey !== undefined) headers.set("x-api-key", xApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/opportunities/${encodeURIComponent(String(args.id))}${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 };