export type UpdateApiApiCustomersCustomerIdDataArgs = {customer_id: number, body: {version?: (string | null) | undefined, data: unknown}}; export type UpdateApiApiCustomersCustomerIdDataOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Set customer data * * PUT /api/customers/{customer_id}/data */ export const updateApiApiCustomersCustomerIdData = async (args: UpdateApiApiCustomersCustomerIdDataArgs, options?: UpdateApiApiCustomersCustomerIdDataOptions) => { const {baseUrl = "https://your-domain.gorgias.com", fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/customers/${encodeURIComponent(String(args.customer_id))}/data${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 };