export type PatchProductRequest = {price_amount?: string | undefined, discount_price?: string | undefined, auto_send_offer_price?: string | undefined, auto_negotiate_offer_price?: string | undefined, quantity?: number | undefined}; export type PatchApiApiV1ProductsBySkuSkuArgs = {sku: string, body: PatchProductRequest}; export type PatchApiApiV1ProductsBySkuSkuOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Patch an existing product on Depop * * PATCH /api/v1/products/by-sku/{sku}/ */ export const patchApiApiV1ProductsBySkuSku = async (args: PatchApiApiV1ProductsBySkuSkuArgs, options?: PatchApiApiV1ProductsBySkuSkuOptions) => { const {baseUrl = "https://partnerapi-staging.depop.com", 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', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/products/by-sku/${encodeURIComponent(String(args.sku))}/${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 };