export type UpdateApiCompaniesDepartmentsDepartmentIdArgs = {department_id: number, body: {name: string}}; export type UpdateApiCompaniesDepartmentsDepartmentIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update department * * PUT /companies/departments/{department_id} */ export const updateApiCompaniesDepartmentsDepartmentId = async (args: UpdateApiCompaniesDepartmentsDepartmentIdArgs, options?: UpdateApiCompaniesDepartmentsDepartmentIdOptions) => { const {baseUrl = "https://api.catsone.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/companies/departments/${encodeURIComponent(String(args.department_id))}${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 };