Documentation ¶
Index ¶
- Constants
- Variables
- func CheckResponseError(r *http.Response) error
- type APIError
- type APIKey
- type AssociationConfig
- type AssociationResult
- type AssociationType
- type Associations
- type AuthMethod
- type Authenticator
- type CRM
- type Client
- func (c *Client) CreateAndDo(method, relPath string, data, option, resource interface{}) error
- func (c *Client) Delete(path string) error
- func (c *Client) Get(path string, resource interface{}, option *RequestQueryOption) error
- func (c *Client) NewRequest(method, path string, body, option interface{}) (*http.Request, error)
- func (c *Client) Patch(path string, data, resource interface{}) error
- func (c *Client) Post(path string, data, resource interface{}) error
- func (c *Client) Put(path string, data, resource interface{}) error
- type Company
- type CompanyService
- type CompanyServiceOp
- func (s *CompanyServiceOp) Create(company interface{}) (*ResponseResource, error)
- func (s *CompanyServiceOp) Delete(companyID string) error
- func (s *CompanyServiceOp) Get(companyID string, company interface{}, option *RequestQueryOption) (*ResponseResource, error)
- func (s *CompanyServiceOp) GetAll(company interface{}, option *RequestQueryOption) (*ResponseResourceMulti, error)
- func (s *CompanyServiceOp) Search(company interface{}, option *RequestSearchOption) (*ResponseResourceMulti, error)
- func (s *CompanyServiceOp) Update(companyID string, company interface{}) (*ResponseResource, error)
- type Contact
- type ContactService
- type ContactServiceOp
- func (s *ContactServiceOp) AssociateAnotherObj(contactID string, conf *AssociationConfig) (*ResponseResource, error)
- func (s *ContactServiceOp) Create(contact interface{}) (*ResponseResource, error)
- func (s *ContactServiceOp) Delete(contactID string) error
- func (s *ContactServiceOp) Get(contactID string, contact interface{}, option *RequestQueryOption) (*ResponseResource, error)
- func (s *ContactServiceOp) Search(contact interface{}, option *RequestSearchOption) (*ResponseResourceMulti, error)
- func (s *ContactServiceOp) Update(contactID string, contact interface{}) (*ResponseResource, error)
- type Deal
- type DealService
- type DealServiceOp
- func (s *DealServiceOp) AssociateAnotherObj(dealID string, conf *AssociationConfig) (*ResponseResource, error)
- func (s *DealServiceOp) Create(deal interface{}) (*ResponseResource, error)
- func (s *DealServiceOp) Delete(dealID string) error
- func (s *DealServiceOp) Get(dealID string, deal interface{}, option *RequestQueryOption) (*ResponseResource, error)
- func (s *DealServiceOp) Update(dealID string, deal interface{}) (*ResponseResource, error)
- type ErrContext
- type ErrDetail
- type ErrLinks
- type Filter
- type FilterGroup
- type HsBool
- type HsStr
- type HsTime
- type Metadata
- type OAuth
- type OAuthConfig
- type OAuthToken
- type OAuthTokenManager
- type OAuthTokenRetriever
- type ObjectType
- type Option
- type Owner
- type OwnerService
- type OwnerServiceOp
- type Pipeline
- type PipelineService
- type PipelineServiceOp
- type RequestPayload
- type RequestQueryOption
- type RequestSearchOption
- type ResponseResource
- type ResponseResourceAll
- type ResponseResourceMulti
- type ResponseResourceNonObject
- type Stage
Examples ¶
Constants ¶
const ( // ValidationError is the APIError.Category. // This is returned by HubSpot when the HTTP Status is 400. // In this case, the verification details error will be included in Details ValidationError = "VALIDATION_ERROR" // InvalidEmailError is the value of ErrDetail.Error when an error occurs in the Email validation. InvalidEmailError = "INVALID_EMAIL" // UnknownDetailError is the value set by go-hubspot when extraction the error details failed. UnknownDetailError = "UNKNOWN_DETAIL" )
const (
FilterOperatorEqual = "EQ"
)
const (
GrantTypeRefreshToken = "refresh_token"
)
Variables ¶
var BlankStr = NewString("")
BlankStr should be used to include empty string in HubSpot fields. This is because fields set to `nil` will be ignored by omitempty.
Functions ¶
func CheckResponseError ¶
CheckResponseError checks the response, and in case of error, maps it to the error structure.
Types ¶
type APIError ¶
type APIError struct { HTTPStatusCode int `json:"-"` Status string `json:"status,omitempty"` Message string `json:"message,omitempty"` CorrelationID string `json:"correlationId,omitempty"` Context ErrContext `json:"context,omitempty"` Category string `json:"category,omitempty"` SubCategory string `json:"subCategory,omitempty"` Links ErrLinks `json:"links,omitempty"` Details []ErrDetail `json:"details,omitempty"` }
type AssociationConfig ¶
type AssociationConfig struct { ToObject ObjectType ToObjectID string Type AssociationType }
type AssociationResult ¶
type AssociationType ¶
type AssociationType string
AssociationType is the name of the key used to associate the objects together.
const ( AssociationTypeContactToCompany AssociationType = "contact_to_company" AssociationTypeContactToDeal AssociationType = "contact_to_deal" AssociationTypeContactToEngagement AssociationType = "contact_to_engagement" AssociationTypeContactToTicket AssociationType = "contact_to_ticket" AssociationTypeDealToContact AssociationType = "deal_to_contact" AssociationTypeDealToCompany AssociationType = "deal_to_company" AssociationTypeDealToEngagement AssociationType = "deal_to_engagement" AssociationTypeDealToLineItem AssociationType = "deal_to_line_item" AssociationTypeDealToTicket AssociationType = "deal_to_ticket" AssociationTypeCompanyToContact AssociationType = "company_to_contact" AssociationTypeCompanyToDeal AssociationType = "company_to_deal" )
Default association types Reference: https://legacydocs.hubspot.com/docs/methods/crm-associations/crm-associations-overview
type Associations ¶
type Associations struct { Companies struct { Results []AssociationResult `json:"results"` } `json:"companies"` Contacts struct { Results []AssociationResult `json:"results"` } `json:"contacts"` Deals struct { Results []AssociationResult `json:"results"` } `json:"deals"` }
type AuthMethod ¶
type AuthMethod func(c *Client)
func SetAPIKey ¶
func SetAPIKey(key string) AuthMethod
func SetOAuth ¶
func SetOAuth(config *OAuthConfig) AuthMethod
type Authenticator ¶
type CRM ¶
type CRM struct { Company CompanyService Contact ContactService Deal DealService Owner OwnerService Pipeline PipelineService }
type Client ¶
Client manages communication with the HubSpot API.
func NewClient ¶
func NewClient(setAuthMethod AuthMethod, opts ...Option) (*Client, error)
NewClient returns a new HubSpot API client with APIKey or OAuthConfig. HubSpot officially recommends authentication with OAuth. e.g. hubspot.NewClient(hubspot.SetAPIKey("key"))
func (*Client) CreateAndDo ¶
CreateAndDo performs a web request to HubSpot. The `data`, `options` and `resource` arguments are optional and only relevant in certain situations. If the data argument is non-nil, it will be used as the body of the request for POST and PUT requests. The options argument is used for specifying request options such as search parameters. The resource argument is marshalled data returned from HubSpot. If the resource contains a pointer to data, the data will be overwritten with the content of the response.
func (*Client) Get ¶
func (c *Client) Get(path string, resource interface{}, option *RequestQueryOption) error
Get performs a GET request for the given path and saves the result in the given resource.
func (*Client) NewRequest ¶
NewRequest creates an API request. After creating a request, add the authentication information according to the method specified in NewClient().
func (*Client) Patch ¶
Patch performs a PATCH request for the given path and saves the result in the given resource.
type Company ¶
type Company struct { ID *HsStr `json:"id,omitempty"` Name *HsStr `json:"name,omitempty"` Industry *HsStr `json:"industry,omitempty"` Domain *HsStr `json:"domain,omitempty"` Phone *HsStr `json:"phone,omitempty"` City *HsStr `json:"city,omitempty"` State *HsStr `json:"state,omitempty"` HsCreateDate *HsTime `json:"hs_createdate,omitempty"` HsLastModifiedDate *HsTime `json:"hs_lastmodifieddate,omitempty"` HsObjectID *HsStr `json:"hs_object_id,omitempty"` HubspotOwnerAssignedDate *HsTime `json:"hubspot_owner_assigneddate,omitempty"` HubspotOwnerID *HsStr `json:"hubspot_owner_id,omitempty"` // custom defined properties ProductNames *HsStr `json:"products,omitempty"` TrialStatus *HsStr `json:"trial_status,omitempty"` TrialEndDate *HsStr `json:"trial_end_date,omitempty"` }
func (*Company) AddProductName ¶
func (*Company) RemoveProductName ¶
type CompanyService ¶
type CompanyService interface { Get(companyID string, owner interface{}, option *RequestQueryOption) (*ResponseResource, error) GetAll(company interface{}, option *RequestQueryOption) (*ResponseResourceMulti, error) Search(company interface{}, option *RequestSearchOption) (*ResponseResourceMulti, error) Create(company interface{}) (*ResponseResource, error) Update(companyID string, company interface{}) (*ResponseResource, error) Delete(companyID string) error }
Company is an interface of company endpoints of the HubSpot API. HubSpot companies store information about company entities. Reference: https://developers.hubspot.com/docs/api/crm/companies
type CompanyServiceOp ¶
type CompanyServiceOp struct {
// contains filtered or unexported fields
}
OwnerServiceOp handles communication with the product related methods of the HubSpot API.
func (*CompanyServiceOp) Create ¶
func (s *CompanyServiceOp) Create(company interface{}) (*ResponseResource, error)
Create creates a new company. In order to bind the created content, a structure must be specified as an argument. When using custom fields, please embed hubspot.Contact in your own structure.
func (*CompanyServiceOp) Delete ¶
func (s *CompanyServiceOp) Delete(companyID string) error
Delete deletes a company. A HubSpot internal Company ID must be specified.
func (*CompanyServiceOp) Get ¶
func (s *CompanyServiceOp) Get(companyID string, company interface{}, option *RequestQueryOption) (*ResponseResource, error)
Get gets a company. In order to bind the get content, a structure must be specified as an argument. Also, if you want to gets a custom field, you need to specify the field name. If you specify a non-existent field, it will be ignored. e.g. &hubspot.RequestQueryOption{ Properties: []string{"custom_a", "custom_b"}}
func (*CompanyServiceOp) GetAll ¶
func (s *CompanyServiceOp) GetAll(company interface{}, option *RequestQueryOption) (*ResponseResourceMulti, error)
Get gets all companies. In order to bind the get content, a structure must be specified as an argument. Also, if you want to gets a custom field, you need to specify the field name. If you specify a non-existent field, it will be ignored. e.g. &hubspot.RequestQueryOption{ Properties: []string{"custom_a", "custom_b"}}
func (*CompanyServiceOp) Search ¶
func (s *CompanyServiceOp) Search(company interface{}, option *RequestSearchOption) (*ResponseResourceMulti, error)
Search finds a company. In order to bind the get content, a structure must be specified as an argument. Also, if you want to gets a custom field, you need to specify the field name. If you specify a non-existent field, it will be ignored. e.g. &hubspot.RequestQueryOption{ Properties: []string{"custom_a", "custom_b"}}
func (*CompanyServiceOp) Update ¶
func (s *CompanyServiceOp) Update(companyID string, company interface{}) (*ResponseResource, error)
Update updates a company. In order to bind the updated content, a structure must be specified as an argument. When using custom fields, please embed hubspot.Company in your own structure.
type Contact ¶
type Contact struct { Address *HsStr `json:"address,omitempty"` AnnualRevenue *HsStr `json:"annualrevenue,omitempty"` City *HsStr `json:"city,omitempty"` CloseDate *HsTime `json:"closedate,omitempty"` Company *HsStr `json:"company,omitempty"` CompanySize *HsStr `json:"company_size,omitempty"` Country *HsStr `json:"country,omitempty"` CreateDate *HsTime `json:"createdate,omitempty"` CurrentlyInWorkflow *HsStr `json:"currentlyinworkflow,omitempty"` DateOfBirth *HsStr `json:"date_of_birth,omitempty"` DaysToClose *HsStr `json:"days_to_close,omitempty"` Degree *HsStr `json:"degree,omitempty"` Email *HsStr `json:"email,omitempty"` EngagementsLastMeetingBooked *HsTime `json:"engagements_last_meeting_booked,omitempty"` EngagementsLastMeetingBookedCampaign *HsStr `json:"engagements_last_meeting_booked_campaign,omitempty"` EngagementsLastMeetingBookedMedium *HsStr `json:"engagements_last_meeting_booked_medium,omitempty"` EngagementsLastMeetingBookedSource *HsStr `json:"engagements_last_meeting_booked_source,omitempty"` Fax *HsStr `json:"fax,omitempty"` FieldOfStudy *HsStr `json:"field_of_study,omitempty"` FirstConversionDate *HsTime `json:"first_conversion_date,omitempty"` FirstConversionEventName *HsStr `json:"first_conversion_event_name,omitempty"` FirstDealCreatedDate *HsTime `json:"first_deal_created_date,omitempty"` FirstName *HsStr `json:"firstname,omitempty"` Gender *HsStr `json:"gender,omitempty"` GraduationDate *HsStr `json:"graduation_date,omitempty"` HsAnalyticsAveragePageViews *HsStr `json:"hs_analytics_average_page_views,omitempty"` HsAnalyticsFirstReferrer *HsStr `json:"hs_analytics_first_referrer,omitempty"` HsAnalyticsFirstTimestamp *HsTime `json:"hs_analytics_first_timestamp,omitempty"` HsAnalyticsFirstTouchConvertingCampaign *HsStr `json:"hs_analytics_first_touch_converting_campaign,omitempty"` HsAnalyticsFirstURL *HsStr `json:"hs_analytics_first_url,omitempty"` HsAnalyticsFirstVisitTimestamp *HsTime `json:"hs_analytics_first_visit_timestamp,omitempty"` HsAnalyticsLastReferrer *HsStr `json:"hs_analytics_last_referrer,omitempty"` HsAnalyticsLastTimestamp *HsTime `json:"hs_analytics_last_timestamp,omitempty"` HsAnalyticsLastTouchConvertingCampaign *HsStr `json:"hs_analytics_last_touch_converting_campaign,omitempty"` HsAnalyticsLastURL *HsStr `json:"hs_analytics_last_url,omitempty"` HsAnalyticsLastVisitTimestamp *HsTime `json:"hs_analytics_last_visit_timestamp,omitempty"` HsAnalyticsNumEventCompletions *HsStr `json:"hs_analytics_num_event_completions,omitempty"` HsAnalyticsNumPageViews *HsStr `json:"hs_analytics_num_page_views,omitempty"` HsAnalyticsNumVisits *HsStr `json:"hs_analytics_num_visits,omitempty"` HsAnalyticsRevenue *HsStr `json:"hs_analytics_revenue,omitempty"` HsAnalyticsSource *HsStr `json:"hs_analytics_source,omitempty"` HsAnalyticsSourceData1 *HsStr `json:"hs_analytics_source_data_1,omitempty"` HsAnalyticsSourceData2 *HsStr `json:"hs_analytics_source_data_2,omitempty"` HsBuyingRole *HsStr `json:"hs_buying_role,omitempty"` HsContentMembershipEmailConfirmed HsBool `json:"hs_content_membership_email_confirmed,omitempty"` HsContentMembershipNotes *HsStr `json:"hs_content_membership_notes,omitempty"` HsContentMembershipRegisteredAt *HsTime `json:"hs_content_membership_registered_at,omitempty"` HsContentMembershipRegistrationDomainSentTo *HsStr `json:"hs_content_membership_registration_domain_sent_to,omitempty"` HsContentMembershipRegistrationEmailSentAt *HsTime `json:"hs_content_membership_registration_email_sent_at,omitempty"` HsContentMembershipStatus *HsStr `json:"hs_content_membership_status,omitempty"` HsCreateDate *HsTime `json:"hs_createdate,omitempty"` HsEmailBadAddress HsBool `json:"hs_email_bad_address,omitempty"` HsEmailBounce *HsStr `json:"hs_email_bounce,omitempty"` HsEmailClick *HsStr `json:"hs_email_click,omitempty"` HsEmailClickDate *HsTime `json:"hs_email_first_click_date,omitempty"` HsEmailDelivered *HsStr `json:"hs_email_delivered,omitempty"` HsEmailDomain *HsStr `json:"hs_email_domain,omitempty"` HsEmailFirstOpenDate *HsTime `json:"hs_email_first_open_date,omitempty"` HsEmailFirstSendDate *HsTime `json:"hs_email_first_send_date,omitempty"` HsEmailHardBounceReasonEnum *HsStr `json:"hs_email_hard_bounce_reason_enum,omitempty"` HsEmailLastClickDate *HsTime `json:"hs_email_last_click_date,omitempty"` HsEmailLastEmailName *HsStr `json:"hs_email_last_email_name,omitempty"` HsEmailLastOpenDate *HsTime `json:"hs_email_last_open_date,omitempty"` HsEmailLastSendDate *HsTime `json:"hs_email_last_send_date,omitempty"` HsEmailOpen *HsStr `json:"hs_email_open,omitempty"` HsEmailOpenDate *HsTime `json:"hs_email_open_date,omitempty"` HsEmailOptOut HsBool `json:"hs_email_optout,omitempty"` HsEmailOptOut6766004 *HsStr `json:"hs_email_optout_6766004,omitempty"` HsEmailOptOut6766098 *HsStr `json:"hs_email_optout_6766098,omitempty"` HsEmailOptOut6766099 *HsStr `json:"hs_email_optout_6766099,omitempty"` HsEmailOptOut6766130 *HsStr `json:"hs_email_optout_6766130,omitempty"` HsEmailQuarantined HsBool `json:"hs_email_quarantined,omitempty"` HsEmailSendsSinceLastEngagement *HsStr `json:"hs_email_sends_since_last_engagement,omitempty"` HsEmailConfirmationStatus *HsStr `json:"hs_emailconfirmationstatus,omitempty"` HsFeedbackLastNpsFollowUp *HsStr `json:"hs_feedback_last_nps_follow_up,omitempty"` HsFeedbackLastNpsRating *HsStr `json:"hs_feedback_last_nps_rating,omitempty"` HsFeedbackLastSurveyDate *HsTime `json:"hs_feedback_last_survey_date,omitempty"` HsIPTimezone *HsStr `json:"hs_ip_timezone,omitempty"` HsIsUnworked *HsStr `json:"hs_is_unworked,omitempty"` HsLanguage *HsStr `json:"hs_language,omitempty"` HsLastSalesActivityTimestamp *HsTime `json:"hs_last_sales_activity_timestamp,omitempty"` HsLeadStatus *HsStr `json:"hs_lead_status,omitempty"` HsLifeCycleStageCustomerDate *HsTime `json:"hs_lifecyclestage_customer_date,omitempty"` HsLifeCycleStageEvangelistDate *HsTime `json:"hs_lifecyclestage_evangelist_date,omitempty"` HsLifeCycleStageLeadDate *HsTime `json:"hs_lifecyclestage_lead_date,omitempty"` HsLifeCycleStageMarketingQualifiedLeadDate *HsTime `json:"hs_lifecyclestage_marketingqualifiedlead_date,omitempty"` HsLifeCycleStageOpportunityDate *HsTime `json:"hs_lifecyclestage_opportunity_date,omitempty"` HsLifeCycleStageOtherDate *HsTime `json:"hs_lifecyclestage_other_date,omitempty"` HsLifeCycleStageSalesQualifiedLeadDate *HsTime `json:"hs_lifecyclestage_salesqualifiedlead_date,omitempty"` HsLifeCycleStageSubscriberDate *HsTime `json:"hs_lifecyclestage_subscriber_date,omitempty"` HsMarketableReasonID *HsStr `json:"hs_marketable_reason_id,omitempty"` HsMarketableReasonType *HsStr `json:"hs_marketable_reason_type,omitempty"` HsMarketableStatus *HsStr `json:"hs_marketable_status,omitempty"` HsMarketableUntilRenewal *HsStr `json:"hs_marketable_until_renewal,omitempty"` HsObjectID *HsStr `json:"hs_object_id,omitempty"` HsPersona *HsStr `json:"hs_persona,omitempty"` HsPredictiveContactScoreV2 *HsStr `json:"hs_predictivecontactscore_v2,omitempty"` HsPredictiveScoringTier *HsStr `json:"hs_predictivescoringtier,omitempty"` HsSalesEmailLastClicked *HsTime `json:"hs_sales_email_last_clicked,omitempty"` HsSalesEmailLastOpened *HsTime `json:"hs_sales_email_last_opened,omitempty"` HsSalesEmailLastReplied *HsTime `json:"hs_sales_email_last_replied,omitempty"` HsSequencesIsEnrolled HsBool `json:"hs_sequences_is_enrolled,omitempty"` HubspotOwnerAssignedDate *HsTime `json:"hubspot_owner_assigneddate,omitempty"` HubspotOwnerID *HsStr `json:"hubspot_owner_id,omitempty"` HubspotTeamID *HsStr `json:"hubspot_team_id,omitempty"` HubspotScore *HsStr `json:"hubspotscore,omitempty"` Industry *HsStr `json:"industry,omitempty"` IPCity *HsStr `json:"ip_city,omitempty"` IPCountry *HsStr `json:"ip_country,omitempty"` IPCountryCode *HsStr `json:"ip_country_code,omitempty"` IPState *HsStr `json:"ip_state,omitempty"` IPStateCode *HsStr `json:"ip_state_code,omitempty"` JobFunction *HsStr `json:"job_function,omitempty"` JobTitle *HsStr `json:"jobtitle,omitempty"` LastModifiedDate *HsTime `json:"lastmodifieddate,omitempty"` LastName *HsStr `json:"lastname,omitempty"` LifeCycleStage *HsStr `json:"lifecyclestage,omitempty"` MaritalStatus *HsStr `json:"marital_status,omitempty"` Message *HsStr `json:"message,omitempty"` MilitaryStatus *HsStr `json:"military_status,omitempty"` MobilePhone *HsStr `json:"mobilephone,omitempty"` NotesLastContacted *HsTime `json:"notes_last_contacted,omitempty"` NotesLastUpdated *HsTime `json:"notes_last_updated,omitempty"` NotesNextActivityDate *HsTime `json:"notes_next_activity_date,omitempty"` NumAssociatedDeals *HsStr `json:"num_associated_deals,omitempty"` NumContactedNotes *HsStr `json:"num_contacted_notes,omitempty"` NumNotes *HsStr `json:"num_notes,omitempty"` NumUniqueConversionEvents *HsStr `json:"num_unique_conversion_events,omitempty"` NumEmployees *HsStr `json:"numemployees,omitempty"` PhoneNumber *HsStr `json:"phone,omitempty"` RecentConversionDate *HsTime `json:"recent_conversion_date,omitempty"` RecentConversionEventName *HsStr `json:"recent_conversion_event_name,omitempty"` RecentDealAmount *HsStr `json:"recent_deal_amount,omitempty"` RecentDealCloseDate *HsTime `json:"recent_deal_close_date,omitempty"` RelationshipStatus *HsStr `json:"relationship_status,omitempty"` Salutation *HsStr `json:"salutation,omitempty"` School *HsStr `json:"school,omitempty"` Seniority *HsStr `json:"seniority,omitempty"` StartDate *HsStr `json:"start_date,omitempty"` State *HsStr `json:"state,omitempty"` TotalRevenue *HsStr `json:"total_revenue,omitempty"` Website *HsStr `json:"website,omitempty"` WorkEmail *HsStr `json:"work_email,omitempty"` Zip *HsStr `json:"zip,omitempty"` // custom defined properties ApiFreeTrial HsBool `json:"api_free_trial,omitempty"` DiscoveryChannel *HsStr `json:"discovery_channel,omitempty"` LeadSource *HsStr `json:"lead_source,omitempty"` UtmOriginalSource *HsStr `json:"utm_original_source,omitempty"` UtmOriginalSourceDrilldown1 *HsStr `json:"utm_original_source_drilldown_1,omitempty"` UtmOriginalSourceDrilldown2 *HsStr `json:"utm_original_source_drilldown_2,omitempty"` UtmOriginalSourceDrilldown3 *HsStr `json:"utm_original_source_drilldown_3,omitempty"` UserType *HsStr `json:"user_type,omitempty"` }
type ContactService ¶
type ContactService interface { Get(contactID string, contact interface{}, option *RequestQueryOption) (*ResponseResource, error) Create(contact interface{}) (*ResponseResource, error) Update(contactID string, contact interface{}) (*ResponseResource, error) Delete(contactID string) error Search(contact interface{}, option *RequestSearchOption) (*ResponseResourceMulti, error) AssociateAnotherObj(contactID string, conf *AssociationConfig) (*ResponseResource, error) }
ContactService is an interface of contact endpoints of the HubSpot API. HubSpot contacts store information about individuals. It can also be associated with other CRM objects such as deal and company. Reference: https://developers.hubspot.com/docs/api/crm/contacts
type ContactServiceOp ¶
type ContactServiceOp struct {
// contains filtered or unexported fields
}
ContactServiceOp handles communication with the product related methods of the HubSpot API.
func (*ContactServiceOp) AssociateAnotherObj ¶
func (s *ContactServiceOp) AssociateAnotherObj(contactID string, conf *AssociationConfig) (*ResponseResource, error)
AssociateAnotherObj associates Contact with another HubSpot objects. If you want to associate a custom object, please use a defined value in HubSpot.
Example ¶
cli, _ := hubspot.NewClient(hubspot.SetAPIKey("apikey")) res, err := cli.CRM.Contact.AssociateAnotherObj("contact001", &hubspot.AssociationConfig{ ToObject: hubspot.ObjectTypeDeal, ToObjectID: "deal001", Type: hubspot.AssociationTypeContactToDeal, }) if err != nil { log.Fatal(err) } r, ok := res.Properties.(*hubspot.Contact) if !ok { log.Fatal("unable to type assertion") } // use properties _ = r fmt.Println(res)
Output:
func (*ContactServiceOp) Create ¶
func (s *ContactServiceOp) Create(contact interface{}) (*ResponseResource, error)
Create creates a new contact. In order to bind the created content, a structure must be specified as an argument. When using custom fields, please embed hubspot.Contact in your own structure.
Example ¶
cli, _ := hubspot.NewClient(hubspot.SetAPIKey("apikey")) example := &ExampleContact{ email: "hubspot@example.com", firstName: "Bryan", lastName: "Cooper", phone: "(877) 929-0687", } contact := &hubspot.Contact{ Email: hubspot.NewString(example.email), FirstName: hubspot.NewString(example.firstName), LastName: hubspot.NewString(example.lastName), MobilePhone: hubspot.NewString(example.phone), Website: hubspot.NewString("example.com"), Zip: nil, } res, err := cli.CRM.Contact.Create(contact) if err != nil { log.Fatal(err) } r, ok := res.Properties.(*hubspot.Contact) if !ok { log.Fatal("unable to type assertion") } // use properties _ = r fmt.Println(res)
Output:
func (*ContactServiceOp) Delete ¶
func (s *ContactServiceOp) Delete(contactID string) error
Delete deletes a contact.
func (*ContactServiceOp) Get ¶
func (s *ContactServiceOp) Get(contactID string, contact interface{}, option *RequestQueryOption) (*ResponseResource, error)
Get gets a contact. In order to bind the get content, a structure must be specified as an argument. Also, if you want to gets a custom field, you need to specify the field name. If you specify a non-existent field, it will be ignored. e.g. &hubspot.RequestQueryOption{ Properties: []string{"custom_a", "custom_b"}}
Example ¶
cli, _ := hubspot.NewClient(hubspot.SetAPIKey("apikey")) res, err := cli.CRM.Contact.Get("contact001", &hubspot.Contact{}, nil) if err != nil { log.Fatal(err) } r, ok := res.Properties.(*hubspot.Contact) if !ok { log.Fatal("unable to type assertion") } // use properties _ = r fmt.Println(res)
Output:
func (*ContactServiceOp) Search ¶
func (s *ContactServiceOp) Search(contact interface{}, option *RequestSearchOption) (*ResponseResourceMulti, error)
Search finds a contact. In order to bind the get content, a structure must be specified as an argument. Also, if you want to gets a custom field, you need to specify the field name. If you specify a non-existent field, it will be ignored. e.g. &hubspot.RequestQueryOption{ Properties: []string{"custom_a", "custom_b"}}
func (*ContactServiceOp) Update ¶
func (s *ContactServiceOp) Update(contactID string, contact interface{}) (*ResponseResource, error)
Update updates a contact. In order to bind the updated content, a structure must be specified as an argument. When using custom fields, please embed hubspot.Contact in your own structure.
Example ¶
cli, _ := hubspot.NewClient(hubspot.SetAPIKey("apikey")) example := &ExampleContact{ email: "hubspot@example.com", firstName: "Bryan", lastName: "Cooper", phone: "(877) 929-0687", zip: "1000001", } contact := &hubspot.Contact{ Email: hubspot.NewString(example.email), FirstName: hubspot.NewString(example.firstName), LastName: hubspot.NewString(example.lastName), MobilePhone: hubspot.NewString(example.phone), Website: hubspot.NewString("example.com"), Zip: hubspot.NewString(example.zip), } res, err := cli.CRM.Contact.Update("contact001", contact) if err != nil { log.Fatal(err) } r, ok := res.Properties.(*hubspot.Contact) if !ok { log.Fatal("unable to type assertion") } // use properties _ = r fmt.Println(res)
Output:
type Deal ¶
type Deal struct { Amount *HsStr `json:"amount,omitempty"` AmountInCompanyCurrency *HsStr `json:"amount_in_home_currency,omitempty"` AnnualContractValue *HsStr `json:"hs_acv,omitempty"` AnnualRecurringRevenue *HsStr `json:"hs_arr,omitempty"` ClosedLostReason *HsStr `json:"closed_lost_reason,omitempty"` ClosedWonReason *HsStr `json:"closed_won_reason,omitempty"` DealDescription *HsStr `json:"description,omitempty"` DealName *HsStr `json:"dealname,omitempty"` DealOwnerID *HsStr `json:"hubspot_owner_id,omitempty"` DealStage *HsStr `json:"dealstage,omitempty"` DealType *HsStr `json:"dealtype,omitempty"` ForecastAmount *HsStr `json:"hs_forecast_amount,omitempty"` ForecastCategory *HsStr `json:"hs_forecast_category,omitempty"` ForecastProbability *HsStr `json:"hs_forecast_probability,omitempty"` MonthlyRecurringRevenue *HsStr `json:"hs_mrr,omitempty"` NextStep *HsStr `json:"hs_next_step,omitempty"` NumberOfContacts *HsStr `json:"num_associated_contacts,omitempty"` NumberOfSalesActivities *HsStr `json:"num_notes,omitempty"` NumberOfTimesContacted *HsStr `json:"num_contacted_notes,omitempty"` ObjectID *HsStr `json:"hs_object_id,omitempty"` PipeLine *HsStr `json:"pipeline,omitempty"` TeamID *HsStr `json:"hubspot_team_id,omitempty"` TotalContractValue *HsStr `json:"hs_tcv,omitempty"` CreateDate *HsTime `json:"createdate,omitempty"` CloseDate *HsTime `json:"closedate,omitempty"` LastActivityDate *HsTime `json:"notes_last_updated,omitempty"` LastContacted *HsTime `json:"notes_last_contacted,omitempty"` LastModifiedDate *HsTime `json:"hs_lastmodifieddate,omitempty"` NextActivityDate *HsTime `json:"notes_next_activity_date,omitempty"` OwnerAssignedDate *HsTime `json:"hubspot_owner_assigneddate,omitempty"` // custom defined properties NoOfLicenses *HsStr `json:"of_licenses,omitempty"` ProductName *HsStr `json:"product_name,omitempty"` PackageName *HsStr `json:"package_name,omitempty"` TrialEndDate *HsStr `json:"trial_end_date,omitempty"` Usage *HsStr `json:"usage,omitempty"` }
Deal represents a HubSpot deal.
type DealService ¶
type DealService interface { Get(dealID string, deal interface{}, option *RequestQueryOption) (*ResponseResource, error) Create(deal interface{}) (*ResponseResource, error) Update(dealID string, deal interface{}) (*ResponseResource, error) Delete(dealID string) error AssociateAnotherObj(dealID string, conf *AssociationConfig) (*ResponseResource, error) }
DealService is an interface of deal endpoints of the HubSpot API. HubSpot deal can be used to manage transactions. It can also be associated with other CRM objects such as contact and company. Reference: https://developers.hubspot.com/docs/api/crm/deals
type DealServiceOp ¶
type DealServiceOp struct {
// contains filtered or unexported fields
}
DealServiceOp handles communication with the product related methods of the HubSpot API.
func (*DealServiceOp) AssociateAnotherObj ¶
func (s *DealServiceOp) AssociateAnotherObj(dealID string, conf *AssociationConfig) (*ResponseResource, error)
AssociateAnotherObj associates Deal with another HubSpot objects. If you want to associate a custom object, please use a defined value in HubSpot.
Example ¶
cli, _ := hubspot.NewClient(hubspot.SetAPIKey("apikey")) res, err := cli.CRM.Deal.AssociateAnotherObj("deal001", &hubspot.AssociationConfig{ ToObject: hubspot.ObjectTypeContact, ToObjectID: "contact001", Type: hubspot.AssociationTypeDealToContact, }) if err != nil { log.Fatal(err) } r, ok := res.Properties.(*hubspot.Deal) if !ok { log.Fatal("unable to type assertion") } // use properties _ = r fmt.Println(res)
Output:
func (*DealServiceOp) Create ¶
func (s *DealServiceOp) Create(deal interface{}) (*ResponseResource, error)
Create creates a new deal. In order to bind the created content, a structure must be specified as an argument. When using custom fields, please embed hubspot.Deal in your own structure.
Example (Apikey) ¶
cli, _ := hubspot.NewClient(hubspot.SetAPIKey("apikey")) example := &ExampleDeal{ amount: "1500.00", name: "Custom data integrations", stage: "presentation scheduled", ownerID: "910901", } deal := &hubspot.Deal{ Amount: hubspot.NewString(example.amount), DealName: hubspot.NewString(example.name), DealStage: hubspot.NewString(example.stage), DealOwnerID: hubspot.NewString(example.ownerID), PipeLine: hubspot.NewString("default"), } res, err := cli.CRM.Deal.Create(deal) if err != nil { log.Fatal(err) } r, ok := res.Properties.(*hubspot.Deal) if !ok { log.Fatal("unable to type assertion") } // use properties _ = r fmt.Println(res)
Output:
Example (Custom) ¶
cli, _ := hubspot.NewClient(hubspot.SetAPIKey("apikey")) example := &ExampleDeal{ amount: "1500.00", name: "Custom data integrations", stage: "presentation scheduled", ownerID: "910901", } // Take advantage of structure embedding when using custom fields. deal := &CustomDeal{ Deal: hubspot.Deal{ Amount: hubspot.NewString(example.amount), DealName: hubspot.NewString(example.name), DealStage: hubspot.NewString(example.stage), DealOwnerID: hubspot.NewString(example.ownerID), PipeLine: hubspot.NewString("default"), }, CustomA: "custom field A", CustomB: "custom field B", } res, err := cli.CRM.Deal.Create(deal) if err != nil { log.Fatal(err) } r, ok := res.Properties.(*CustomDeal) if !ok { log.Fatal("unable to type assertion") } // use custom struct _ = r
Output:
Example (Oauth) ¶
cli, _ := hubspot.NewClient(hubspot.SetOAuth(&hubspot.OAuthConfig{ GrantType: hubspot.GrantTypeRefreshToken, ClientID: "hubspot-client-id", ClientSecret: "hubspot-client-secret", RefreshToken: "hubspot-refresh-token", })) example := &ExampleDeal{ amount: "1500.00", name: "Custom data integrations", stage: "presentation scheduled", ownerID: "910901", } deal := &hubspot.Deal{ Amount: hubspot.NewString(example.amount), DealName: hubspot.NewString(example.name), DealStage: hubspot.NewString(example.stage), DealOwnerID: hubspot.NewString(example.ownerID), PipeLine: hubspot.NewString("default"), } res, err := cli.CRM.Deal.Create(deal) if err != nil { log.Fatal(err) } r, ok := res.Properties.(*hubspot.Deal) if !ok { log.Fatal("unable to type assertion") } // use properties _ = r fmt.Println(res)
Output:
func (*DealServiceOp) Delete ¶
func (s *DealServiceOp) Delete(dealID string) error
Delete deletes a deal.
func (*DealServiceOp) Get ¶
func (s *DealServiceOp) Get(dealID string, deal interface{}, option *RequestQueryOption) (*ResponseResource, error)
Get gets a deal. In order to bind the get content, a structure must be specified as an argument. Also, if you want to gets a custom field, you need to specify the field name. If you specify a non-existent field, it will be ignored. e.g. &hubspot.RequestQueryOption{ Properties: []string{"custom_a", "custom_b"}}
Example ¶
cli, _ := hubspot.NewClient(hubspot.SetAPIKey("apikey")) res, err := cli.CRM.Deal.Get("deal001", &hubspot.Deal{}, nil) if err != nil { log.Fatal(err) } r, ok := res.Properties.(*hubspot.Deal) if !ok { log.Fatal("unable to type assertion") } // use properties _ = r fmt.Println(res)
Output:
Example (Custom) ¶
cli, _ := hubspot.NewClient(hubspot.SetAPIKey("apikey")) res, err := cli.CRM.Deal.Get("deal001", &CustomDeal{}, &hubspot.RequestQueryOption{ CustomProperties: []string{ "custom_a", "custom_b", }, }) if err != nil { log.Fatal(err) } r, ok := res.Properties.(*CustomDeal) if !ok { log.Fatal("unable to type assertion") } // use properties _ = r fmt.Println(res)
Output:
func (*DealServiceOp) Update ¶
func (s *DealServiceOp) Update(dealID string, deal interface{}) (*ResponseResource, error)
Update updates a deal. In order to bind the updated content, a structure must be specified as an argument. When using custom fields, please embed hubspot.Deal in your own structure.
Example ¶
cli, _ := hubspot.NewClient(hubspot.SetAPIKey("apikey")) example := &ExampleDeal{ amount: "1500.00", name: "Custom data integrations", stage: "presentation scheduled", ownerID: "910901", } deal := &hubspot.Deal{ Amount: hubspot.NewString(example.amount), DealName: hubspot.NewString(example.name), DealStage: hubspot.NewString(example.stage), DealOwnerID: hubspot.NewString(example.ownerID), PipeLine: hubspot.NewString("default"), } res, err := cli.CRM.Deal.Update("deal001", deal) if err != nil { log.Fatal(err) } r, ok := res.Properties.(*hubspot.Deal) if !ok { log.Fatal("unable to type assertion") } // use properties _ = r fmt.Println(res)
Output:
type ErrContext ¶
type FilterGroup ¶
type FilterGroup struct {
Filters []Filter `json:"filters,omitempty"`
}
type HsBool ¶
type HsBool bool
HsBool is defined to marshal the HubSpot boolean fields of `true`, `"true"`, and so on, into a bool type.
func (*HsBool) UnmarshalJSON ¶
UnmarshalJSON implemented json.Unmarshaler. This is because there are cases where the Time value returned by HubSpot is null or "true" / "false".
type HsStr ¶
type HsStr string
HsStr is defined to identify HubSpot's empty string from null. If you want to set a HubSpot's value, use NewString(), if null, use `nil` in the request field.
type HsTime ¶
HsTime is defined to identify HubSpot time fields with null and empty string. If you want to set a HubSpot's value, use NewTime(), if null, use `nil` in the request field.
func (*HsTime) ToTime ¶
ToTime convert HsTime to time.Time. If the value is zero, it will be return nil.
func (*HsTime) UnmarshalJSON ¶
UnmarshalJSON implemented json.Unmarshaler. This is because there are cases where the Time value returned by HubSpot is null or empty string. The time.Time does not support Parse with empty string.
type OAuthConfig ¶
type OAuthToken ¶
type OAuthTokenManager ¶
type OAuthTokenManager struct { HTTPClient *http.Client Config *OAuthConfig Token *OAuthToken // contains filtered or unexported fields }
func (*OAuthTokenManager) RetrieveToken ¶
func (otm *OAuthTokenManager) RetrieveToken() (*OAuthToken, error)
type OAuthTokenRetriever ¶
type OAuthTokenRetriever interface {
RetrieveToken() (*OAuthToken, error)
}
type ObjectType ¶
type ObjectType string
ObjectType is the name used in object association.
const ( ObjectTypeCompany ObjectType = "companies" ObjectTypeContact ObjectType = "contacts" ObjectTypeDeal ObjectType = "deals" )
Default Object types
type Option ¶
type Option func(c *Client)
func WithAPIVersion ¶
func WithBaseURL ¶
func WithHTTPClient ¶
type Owner ¶
type Owner struct { ID *HsStr `json:"id,omitempty"` Email *HsStr `json:"email,omitempty"` FirstName *HsStr `json:"firstName,omitempty"` LastName *HsStr `json:"lastName,omitempty"` UserID int `json:"userId,omitempty"` CreatedAt *HsTime `json:"createdAt,omitempty"` UpdatedAt *HsTime `json:"updatedAt,omitempty"` Archived bool `json:"archived,omitempty"` }
type OwnerService ¶
type OwnerService interface { Get(ownerID string, owner interface{}, option *RequestQueryOption) (ResponseResourceNonObject, error) GetAll(owner interface{}, option *RequestQueryOption) (*ResponseResourceAll, error) }
Owner is an interface of owner endpoints of the HubSpot API. HubSpot uses owners to assign specific users to contacts, companies, deals, tickets, or engagements. Reference: https://developers.hubspot.com/docs/api/crm/owners
type OwnerServiceOp ¶
type OwnerServiceOp struct {
// contains filtered or unexported fields
}
OwnerServiceOp handles communication with the product related methods of the HubSpot API.
func (*OwnerServiceOp) Get ¶
func (s *OwnerServiceOp) Get(ownerID string, owner interface{}, option *RequestQueryOption) (ResponseResourceNonObject, error)
Get gets an owner. In order to bind the get content, a structure must be specified as an argument. Also, if you want to gets a custom field, you need to specify the field name. If you specify a non-existent field, it will be ignored. e.g. &hubspot.RequestQueryOption{ Properties: []string{"custom_a", "custom_b"}}
func (*OwnerServiceOp) GetAll ¶
func (s *OwnerServiceOp) GetAll(owner interface{}, option *RequestQueryOption) (*ResponseResourceAll, error)
Get gets all owners. In order to bind the get content, a structure must be specified as an argument. Also, if you want to gets a custom field, you need to specify the field name. If you specify a non-existent field, it will be ignored. e.g. &hubspot.RequestQueryOption{ Properties: []string{"custom_a", "custom_b"}}
type PipelineService ¶
type PipelineService interface { Get(pipelineID string, pipeline interface{}, option *RequestQueryOption) (ResponseResourceNonObject, error) GetAll(pipeline interface{}, option *RequestQueryOption) (*ResponseResourceAll, error) }
Pipeline is an interface of pipeline endpoints of the HubSpot API. HubSpot uses owners to assign specific users to contacts, companies, deals, tickets, or engagements. Reference: https://developers.hubspot.com/docs/api/crm/pipeline
type PipelineServiceOp ¶
type PipelineServiceOp struct {
// contains filtered or unexported fields
}
PipelineServiceOp handles communication with the product related methods of the HubSpot API.
func (*PipelineServiceOp) Get ¶
func (s *PipelineServiceOp) Get(pipelineID string, pipeline interface{}, option *RequestQueryOption) (ResponseResourceNonObject, error)
Get gets a pipeline. In order to bind the get content, a structure must be specified as an argument. Also, if you want to gets a custom field, you need to specify the field name. If you specify a non-existent field, it will be ignored. e.g. &hubspot.RequestQueryOption{ Properties: []string{"custom_a", "custom_b"}}
func (*PipelineServiceOp) GetAll ¶
func (s *PipelineServiceOp) GetAll(pipeline interface{}, option *RequestQueryOption) (*ResponseResourceAll, error)
GetAll gets all pipelines. In order to bind the get content, a structure must be specified as an argument. Also, if you want to gets a custom field, you need to specify the field name. If you specify a non-existent field, it will be ignored. e.g. &hubspot.RequestQueryOption{ Properties: []string{"custom_a", "custom_b"}}
type RequestPayload ¶
type RequestPayload struct {
Properties interface{} `json:"properties,omitempty"`
}
RequestPayload is common request structure for HubSpot APIs.
type RequestQueryOption ¶
type RequestQueryOption struct { Properties []string `url:"properties,comma,omitempty"` CustomProperties []string `url:"-"` Associations []string `url:"associations,comma,omitempty"` PaginateAssociations bool `url:"paginateAssociations,omitempty"` // HubSpot defaults false Archived bool `url:"archived,omitempty"` // HubSpot defaults false IDProperty string `url:"idProperty,omitempty"` }
RequestQueryOption is a set of options to be specified in the query when making a Get request. RequestQueryOption.Properties will be overwritten internally, so do not specify it. If you want to get the custom fields as well, specify the field names in RequestQueryOption.CustomProperties. Items with no value set will be ignored.
type RequestSearchOption ¶
type RequestSearchOption struct {
FilterGroups []FilterGroup `json:"filterGroups,omitempty"`
}
type ResponseResource ¶
type ResponseResource struct { ID string `json:"id,omitempty"` Archived bool `json:"archived,omitempty"` Associations *Associations `json:"associations,omitempty"` Properties interface{} `json:"properties,omitempty"` CreatedAt *HsTime `json:"createdAt,omitempty"` UpdatedAt *HsTime `json:"updatedAt,omitempty"` ArchivedAt *HsTime `json:"archivedAt,omitempty"` AssociationResults []AssociationResult `json:"results,omitempty"` }
ResponseResource is common response structure for HubSpot APIs.
type ResponseResourceAll ¶
type ResponseResourceAll struct {
Results []interface{} `json:"results,omitempty"`
}
check if needed for get all in owners
type ResponseResourceMulti ¶
type ResponseResourceMulti struct {
Results []ResponseResource `json:"results,omitempty"`
}
type ResponseResourceNonObject ¶
type ResponseResourceNonObject interface{}