export type ProductreqUpdateReq = {name: string, profile?: string | undefined}; export type UpdateApiV3ProductIdArgs = {id: number, body: ProductreqUpdateReq}; export type UpdateApiV3ProductIdOptions = {baseUrl: string, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * 编辑产品 * * PUT /v3/product/{id} */ export const updateApiV3ProductId = async (args: UpdateApiV3ProductIdArgs, options: UpdateApiV3ProductIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (BearerAuth !== undefined) headers.set("Authorization", BearerAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v3/product/${encodeURIComponent(String(args.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 };