Links

Update deal

Tags: #hubspot #crm #sales #deal #naas_drivers #snippet
Author: Florent Ravenel​
Description: This notebook allows users to update deals in HubSpot.

Input

Import libraries

from naas_drivers import hubspot

Setup HubSpot

👉 Starting November 30, 2022, HubSpot API keys no longer enable access to HubSpot APIs, so in Naas version 2.8.3 and above, you need create a private app and use the access token.
Enter Your Access Token
HS_ACCESS_TOKEN = naas.secret.get("HS_ACCESS_TOKEN") or "YOUR_HS_ACCESS_TOKEN"
Enter deal parameters to update
deal_id = "3501002068"
dealname = "TEST"
dealstage = "5102584"
closedate = "2021-12-31" # date format must be %Y-%m-%d
amount = "100.50"
hubspot_owner_id = None

Model

Update deal using patch method

This method will allow you to update any deal properties available in your HubSpot.
update_deal = {
"properties": {
"dealstage": dealstage,
"dealname": dealname,
"amount": amount,
"closedate": closedate,
"hubspot_owner_id": hubspot_owner_id,
}
}
​
deal1 = hubspot.connect(HS_ACCESS_TOKEN).deals.patch(deal_id, update_deal)

Update deal using update method

deal2 = hubspot.connect(HS_ACCESS_TOKEN).deals.update(
deal_id, dealname, dealstage, closedate, amount, hubspot_owner_id
)

Output

Display results

deal1
deal2