Documentation
¶
Overview ¶
Package hubspot is a SDK client library for HubSpot's API
Example usage:
package main
import "github.com/leonelquinteros/hubspot"
func main() {
// Create client object with config from environment variables (HUBSPOT_API_HOST, HUBSPOT_API_KEY, HUBSPOT_OAUTH_TOKEN)
c := hubspot.NewClient(hubspot.NewClientConfig())
// Create new contact
data := hubspot.ContactsRequest{
hubspot.Properties: []hubspot.Property{
hubspot.Property{
Property: "email",
Value: "contact@example.com",
},
hubspot.Property{
Property: "firstname",
Value: "Contact",
},
hubspot.Property{
Property: "lastname",
Value: "Example",
},
},
}
r, err := c.Contacts().Create(data)
if err != nil {
log.Fatal(err)
}
// Get contact by email
contact, err = c.Contacts().GetByEmail("contact@example.com")
if err != nil {
log.Fatal(err)
}
// Print contact object
fmt.Printf("%+v", contact)
}
Configuration ¶
Package can be configured using environment variables for default initialization. When calling
hubspot.NewClientConfig()
the configuration object will be populated with information from environment variables as follow:
HUBSPOT_API_HOST
The HubSpot's API endpoint host (including schema and host), defaults to "https://api.hubapi.com" when omitted.
HUBSPOT_API_KEY
HubSpot's API secret key used to authenticate further requests. It will be preferred if both auth methods (API key and OAuth token) are present.
HUBSPOT_OAUTH_TOKEN
If HUBSPOT_API_KEY isn't present, further requests will be authenticated using this token.
Manual/eventual configuration can be set by creating a configuration object directly and pass it to the NewClient() method:
hubspot.NewClient(hubspot.ClientConfig{
APIHost: "https://api.hubspot.local"
APIKey: "vroho487hfo48hfo48y3bai38gi2"
})
Index ¶
- Constants
- type AssociatedCompany
- type Association
- type AssociationCreateFailure
- type Associations
- type CRMAssociations
- type CRMAssociationsRequest
- type Client
- type ClientConfig
- type Companies
- type CompaniesRequest
- type CompaniesResponse
- type CompanyProperties
- type ContactProperty
- type Contacts
- func (c Contacts) Create(data ContactsRequest) (ContactsResponse, error)
- func (c Contacts) CreateOrUpdate(email string, data ContactsRequest) (CreateOrUpdateContactResponse, error)
- func (c Contacts) Delete(contactID int) error
- func (c Contacts) Get(contactID int) (ContactsResponse, error)
- func (c Contacts) GetByEmail(email string) (ContactsResponse, error)
- func (c Contacts) Update(contactID int, data ContactsRequest) error
- func (c Contacts) UpdateByEmail(email string, data ContactsRequest) error
- type ContactsRequest
- type ContactsResponse
- type CreateOrUpdateContactResponse
- type DealProperties
- type Deals
- type DealsRequest
- type DealsResponse
- type DeleteContactResponse
- type ErrorResponse
- type IdentityProfile
- type Property
- type ResponseProperty
Constants ¶
const ( // CRMAssociationContactToCompany ... CRMAssociationContactToCompany = 1 // CRMAssociationCompanyToContact ... CRMAssociationCompanyToContact = 2 // CRMAssociationDealToContact ... CRMAssociationDealToContact = 3 // CRMAssociationContactToDeal ... CRMAssociationContactToDeal = 4 // CRMAssociationDealToCompany ... CRMAssociationDealToCompany = 5 // CRMAssociationCompanyToDeal ... CRMAssociationCompanyToDeal = 6 // CRMAssociationCompanyToEngagement ... CRMAssociationCompanyToEngagement = 7 // CRMAssociationEngagementToCompany ... CRMAssociationEngagementToCompany = 8 // CRMAssociationContactToEngagement ... CRMAssociationContactToEngagement = 9 // CRMAssociationEngagementToContact ... CRMAssociationEngagementToContact = 10 // CRMAssociationDealToEngagement ... CRMAssociationDealToEngagement = 11 // CRMAssociationEngagementToDeal ... CRMAssociationEngagementToDeal = 12 // CRMAssociationParentCompanyToChildCompany ... CRMAssociationParentCompanyToChildCompany = 13 // CRMAssociationChildCompanyToParentCompany ... CRMAssociationChildCompanyToParentCompany = 14 // CRMAssociationContactToTicket ... CRMAssociationContactToTicket = 15 // CRMAssociationTicketToContact ... CRMAssociationTicketToContact = 16 // CRMAssociationTicketToEngagement ... CRMAssociationTicketToEngagement = 17 // CRMAssociationEngagementToTicket ... CRMAssociationEngagementToTicket = 18 // CRMAssociationDealToLineItem ... CRMAssociationDealToLineItem = 19 // CRMAssociationLineItemToDeal ... CRMAssociationLineItemToDeal = 20 // CRMAssociationCompanyToTicket ... CRMAssociationCompanyToTicket = 25 // CRMAssociationTicketToCompany ... CRMAssociationTicketToCompany = 26 // CRMAssociationDealToTicket ... CRMAssociationDealToTicket = 27 // CRMAssociationTicketToDeal ... CRMAssociationTicketToDeal = 28 // CRMAssociationAdvisorToCompany ... CRMAssociationAdvisorToCompany = 33 // CRMAssociationCompanyToAdvisor ... CRMAssociationCompanyToAdvisor = 34 // CRMAssociationBoardMemberToCompany ... CRMAssociationBoardMemberToCompany = 35 // CRMAssociationCompanyToBoardMember ... CRMAssociationCompanyToBoardMember = 36 // CRMAssociationContractorToCompany ... CRMAssociationContractorToCompany = 37 // CRMAssociationCompanyToContractor ... CRMAssociationCompanyToContractor = 38 // CRMAssociationManagerToCompany ... CRMAssociationManagerToCompany = 39 // CRMAssociationCompanyToManager ... CRMAssociationCompanyToManager = 40 // CRMAssociationBusinessOwnerToCompany ... CRMAssociationBusinessOwnerToCompany = 41 // CRMAssociationCompanyToBusinessOwner ... CRMAssociationCompanyToBusinessOwner = 42 // CRMAssociationPartnerToCompany ... CRMAssociationPartnerToCompany = 43 // CRMAssociationCompanyToPartner ... CRMAssociationCompanyToPartner = 44 // CRMAssociationResellerToCompany ... CRMAssociationResellerToCompany = 45 // CRMAssociationCompanyToReseller ... CRMAssociationCompanyToReseller = 46 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssociatedCompany ¶
type AssociatedCompany struct {
CompanyID int `json:"company-id"`
PortalID int `json:"portal-id"`
Properties []Property `json:"properties"`
}
AssociatedCompany object
type Association ¶
type Association struct {
FromObjectID int `json:"fromObjectId"`
AssociationType string `json:"associationType"`
ToObjectID int `json:"toObjectId"`
Timestamp int64 `json:"timestamp"`
}
Association object
type AssociationCreateFailure ¶
type AssociationCreateFailure struct {
Association Association `json:"association"`
FailReason string `json:"failReason"`
Message string `json:"message"`
}
AssociationCreateFailure object
type Associations ¶
type Associations struct {
AssociatedCompanyIds []int `json:"associatedCompanyIds,omitempty"`
AssociatedVids []int `json:"associatedVids,omitempty"`
AssociatedDealIds []int `json:"associatedDealIds,omitempty"`
}
Associations object
type CRMAssociations ¶
type CRMAssociations struct {
Client
}
CRMAssociations API client
func (CRMAssociations) Create ¶
func (ca CRMAssociations) Create(data CRMAssociationsRequest) error
Create new CRM Association
func (CRMAssociations) Delete ¶
func (ca CRMAssociations) Delete(data CRMAssociationsRequest) error
Delete CRM Association
type CRMAssociationsRequest ¶
type CRMAssociationsRequest struct {
FromObjectID int `json:"fromObjectId"`
ToObjectID int `json:"toObjectId"`
Category string `json:"category"`
DefinitionID int `json:"definitionId"`
}
CRMAssociationsRequest object
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client object
func (Client) CRMAssociations ¶
func (c Client) CRMAssociations() CRMAssociations
CRMAssociations constructor (from Client)
type ClientConfig ¶
type ClientConfig struct {
APIHost string
APIKey string
OAuthToken string
HTTPTimeout time.Duration
DialTimeout time.Duration
TLSTimeout time.Duration
}
ClientConfig object used for client creation
func NewClientConfig ¶
func NewClientConfig() ClientConfig
NewClientConfig constructs a ClientConfig object with the environment variables set as default
type Companies ¶
type Companies struct {
Client
}
Companies client
func (Companies) Create ¶
func (c Companies) Create(data CompaniesRequest) (CompaniesResponse, error)
Create new Company
func (Companies) Update ¶
func (c Companies) Update(companyID int, data CompaniesRequest) (CompaniesResponse, error)
Update Deal
type CompaniesRequest ¶
type CompaniesRequest struct {
Properties []Property `json:"properties"`
}
CompaniesRequest object
type CompaniesResponse ¶
type CompaniesResponse struct {
ErrorResponse
CompanyID int `json:"companyId"`
PortalID int `json:"portalId"`
Properties CompanyProperties `json:"properties"`
IsDeleted bool `json:"isDeleted"`
}
CompaniesResponse object
type CompanyProperties ¶
type CompanyProperties struct {
CreateDate ResponseProperty `json:"createdate"`
Name ResponseProperty `json:"name"`
Description ResponseProperty `json:"description"`
}
CompanyProperties response object
type ContactProperty ¶
type ContactProperty struct {
Value string `json:"value"`
Versions []struct {
Value string `json:"value"`
Timestamp int64 `json:"timestamp"`
SourceType string `json:"source-type"`
SourceID interface{} `json:"source-id"`
SourceLabel interface{} `json:"source-label"`
Selected bool `json:"selected"`
} `json:"versions"`
}
ContactProperty response object
type Contacts ¶
type Contacts struct {
Client
}
Contacts client
func (Contacts) Create ¶
func (c Contacts) Create(data ContactsRequest) (ContactsResponse, error)
Create new Contact
func (Contacts) CreateOrUpdate ¶
func (c Contacts) CreateOrUpdate(email string, data ContactsRequest) (CreateOrUpdateContactResponse, error)
CreateOrUpdate a Contact
func (Contacts) GetByEmail ¶
func (c Contacts) GetByEmail(email string) (ContactsResponse, error)
GetByEmail a Contact
func (Contacts) Update ¶
func (c Contacts) Update(contactID int, data ContactsRequest) error
Update Contact
func (Contacts) UpdateByEmail ¶
func (c Contacts) UpdateByEmail(email string, data ContactsRequest) error
UpdateByEmail a Contact
type ContactsRequest ¶
type ContactsRequest struct {
Properties []Property `json:"properties"`
}
ContactsRequest object
type ContactsResponse ¶
type ContactsResponse struct {
ErrorResponse
PortalID int `json:"portal-id"`
Vid int `json:"vid"`
CanonicalVid int `json:"canonical-vid"`
MergeVids []int `json:"merge-vids"`
IsContact bool `json:"is-contact"`
ProfileToken string `json:"profile-token"`
ProfileURL string `json:"profile-url"`
IdentityProfiles []IdentityProfile `json:"identity-profiles"`
Properties map[string]ContactProperty `json:"properties"`
FormSubmissions []interface{} `json:"form-submissions"`
}
ContactsResponse object
type CreateOrUpdateContactResponse ¶
type CreateOrUpdateContactResponse struct {
ErrorResponse
Vid int `json:"vid"`
IsNew bool `json:"isNew"`
}
CreateOrUpdateContactResponse object
type DealProperties ¶
type DealProperties struct {
Amount ResponseProperty `json:"amount"`
Dealstage ResponseProperty `json:"dealstage"`
Pipeline ResponseProperty `json:"pipeline"`
Closedate ResponseProperty `json:"closedate"`
Createdate ResponseProperty `json:"createdate"`
HubspotOwnerID ResponseProperty `json:"hubspot_owner_id"`
HsCreatedate ResponseProperty `json:"hs_createdate"`
Dealtype ResponseProperty `json:"dealtype"`
Dealname ResponseProperty `json:"dealname"`
}
DealProperties object
type Deals ¶
type Deals struct {
Client
}
Deals client
func (Deals) Create ¶
func (d Deals) Create(data DealsRequest) (DealsResponse, error)
Create new Deal
func (Deals) Update ¶
func (d Deals) Update(dealID int, data DealsRequest) (DealsResponse, error)
Update Deal
type DealsRequest ¶
type DealsRequest struct {
Associations Associations `json:"associations,omitempty"`
Properties []Property `json:"properties"`
}
DealsRequest object
type DealsResponse ¶
type DealsResponse struct {
ErrorResponse
PortalID int `json:"portalId"`
DealID int `json:"dealId"`
IsDeleted bool `json:"isDeleted"`
Associations Associations `json:"associations"`
AssociationCreateFailures []AssociationCreateFailure `json:"associationCreateFailures"`
Properties DealProperties `json:"properties"`
}
DealsResponse object
type DeleteContactResponse ¶
type DeleteContactResponse struct {
ErrorResponse
Vid int `json:"vid"`
Deleted bool `json:"deleted"`
Reason string `json:"reason"`
}
DeleteContactResponse object
type ErrorResponse ¶
type ErrorResponse struct {
Status string `json:"status,omitempty"`
Message string `json:"message,omitempty"`
}
ErrorResponse object
type IdentityProfile ¶
type IdentityProfile struct {
Identities []struct {
Timestamp int64 `json:"timestamp"`
Type string `json:"type"`
Value string `json:"value"`
} `json:"identities"`
Vid int `json:"vid"`
}
IdentityProfile response object
type Property ¶
type Property struct {
Name string `json:"name,omitempty"`
Property string `json:"property,omitempty"`
Value interface{} `json:"value"`
}
Property object is a general property definition. To handle inconsistencies in the API, it will take Name or Property to indicate the Property Name and a Value.
type ResponseProperty ¶
type ResponseProperty struct {
Name string `json:"name"`
Value string `json:"value"`
Timestamp int64 `json:"timestamp"`
Source string `json:"source"`
SourceID string `json:"sourceId"`
SourceVid []int `json:"sourceVid"`
Versions []ResponseProperty `json:"versions"`
}
ResponseProperty object is the format on which response objects format their property information.