HubSpot API in Go.
go get github.com/Fyb3roptik/hubspot
import(
"github.com/Fyb3roptik/hubspot"
)
api_key := os.Getenv("HUBSPOT_API_KEY")
a := hubspot.NewContact(api_key, "[email protected]")
a.Add("firstname", "Abhi")
a.Add("lastname", "Yerra")
a.Add("company", "Acksin")
a.Add("lifecyclestage", "opportunity")
a.Add("acksinsoftware", "opsZero")
resp := a.Publish()
if resp.Vid != 901 {
t.Errorf("Failed to update contact")
}
d := hubspot.NewDeal(api_key)
d.Associations.AssociatedVids = []int{resp.Vid}
d.Add("dealname", "Tim's Newer Deal")
d.Add("dealstage", "closedwon")
d.Add("closedate", Timestamp())
d.Add("amount", "60000")
d.Add("dealtype", "newbusiness")
d.Publish()
// Single Send Email has 2 property types. Contact and Custom, so we need to specify using the first param. The To, From and ReplyTo are required.
message := hubspot.Message{
To: "[email protected]",
From: "[email protected]",
ReplyTo: "[email protected]",
}
e := hubspot.NewEmail(api_key, email_id, message)
// Adding a contact property
e.Add("contact", "firstname", "Jack")
// Adding a custom property
e.Add("custom", "some_custom_key", "some_custom_value")
e.Publish()
e := hubspot.NewForm(api_key, portal_id, form_guid)
e.Add("firstname", "Tester")
e.Add("lastname", "McTest")
e.Add("email", "[email protected]")
e.Publish()
This is based on the original library written by acksin