//native
type Pipedrive = {
apiToken: string;
};
/**
* Delete a discount from a deal
* Removes a discount from a deal, changing the deal value if the deal has one-time products attached.
*/
export async function main(auth: Pipedrive, id: string, discount_id: string) {
const url = new URL(
`https://api.pipedrive.com/api/v2/deals/${id}/discounts/${discount_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