Edits history of script submission #17966 for ' Delete an installment from a deal (pipedrive)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Pipedrive = {
      apiToken: string;
    };
    /**
     * Delete an installment from a deal
     * Removes an installment from a deal.
    
    Only available in Advanced and above plans.
    
     */
    export async function main(
      auth: Pipedrive,
      id: string,
      installment_id: string,
    ) {
      const url = new URL(
        `https://api.pipedrive.com/api/v2/deals/${id}/installments/${installment_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