//native
type Pipedrive = {
apiToken: string;
};
/**
* Update a product variation
* Updates product variation data.
*/
export async function main(
auth: Pipedrive,
id: string,
product_variation_id: string,
body: { name?: string; prices?: {}[] },
) {
const url = new URL(
`https://api.pipedrive.com/api/v2/products/${id}/variations/${product_variation_id}`,
);
const response = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
"x-api-token": auth.apiToken,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago