export type ProjectMerge = {approveAllChanges?: boolean | undefined}; export type CreateApiProjectIdMergeArgs = {project_id: string, body: ProjectMerge}; export type CreateApiProjectIdMergeOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Merge a developer project * * POST /{project_id}:merge */ export const createApiProjectIdMerge = async (args: CreateApiProjectIdMergeArgs, options?: CreateApiProjectIdMergeOptions) => { const {baseUrl = "https://developers.bloomreach.io/delivery/site/v2/documents", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/${encodeURIComponent(String(args.project_id))}:merge${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 };