//native
type Pipedrive = {
apiToken: string;
};
/**
* Update an installment added to a deal
* Edits an installment added to a deal.
Only available in Advanced and above plans.
*/
export async function main(
auth: Pipedrive,
id: string,
installment_id: string,
body: { description?: string; amount?: number; billing_date?: string },
) {
const url = new URL(
`https://api.pipedrive.com/api/v2/deals/${id}/installments/${installment_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