//native
type Pipedrive = {
apiToken: string;
};
/**
* Delete an attached product from a deal
* Deletes a product attachment from a deal, using the `product_attachment_id`.
*/
export async function main(
auth: Pipedrive,
id: string,
product_attachment_id: string,
) {
const url = new URL(
`https://api.pipedrive.com/api/v2/deals/${id}/products/${product_attachment_id}`,
);
const response = await fetch(url, {
method: "DELETE",
headers: {
"x-api-token": auth.apiToken,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago