gohubspot

package module
v0.0.0-...-641620c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2020 License: MIT Imports: 11 Imported by: 0

README

gohubspot

A Golang hubspot API client

Documentation

Index

Constants

View Source
const (
	// Contact Operators:
	IsNotEmpty ContactOperator = "IS_NOT_EMPTY"
	IsEmpty    ContactOperator = "IS_EMPTY"
	Eq         ContactOperator = "EQ"
	NotEq      ContactOperator = "NEQ"
	Conatains  ContactOperator = "CONTAINS"
	Lt         ContactOperator = "LT"
	Lte        ContactOperator = "LTE"
	Gt         ContactOperator = "GT"
	SetAny     ContactOperator = "SET_ANY"
	SetNotAny  ContactOperator = "SET_NOT_ANY"
	SetEq      ContactOperator = "SET_EQ"
	SetNotEq   ContactOperator = "SET_NEQ"
	SetAll     ContactOperator = "SET_ALL"

	// ComputedProperty
	DateOfLastFormSubmission ComputedProperty = "DATE_OF_LAST_FORM_SUBMISSION"
	NumberOfFormsFilledOut   ComputedProperty = "NUMBER_OF_FORMS_FILLED_OUT"

	// ListMembership operator
	InList    ListMembershipOperator = "IN_LIST"
	NotInList ListMembershipOperator = "NOT_IN_LIST"

	// Form Submission
	HasFilledOutForm    FormSubmissionOperator = "HAS_FILLED_OUT_FORM"
	HasNotFilledOutForm FormSubmissionOperator = "HAS_NOT_FILLED_OUT_FORM"

	// Events
	HasEvent    EventsOpeerator = "HAS_EVENT"
	NotHasEvent EventsOpeerator = "NOT_HAS_EVENT"

	PageviewEq              PageviewsOperator = "HAS_PAGEVIEW_EQ"
	PageviewContains        PageviewsOperator = "HAS_PAGEVIEW_CONTAINS"
	PageviewMatchesRegexp   PageviewsOperator = "HAS_PAGEVIEW_MATCHES_REGEX"
	PageviewNotEq           PageviewsOperator = "NOT_HAS_PAGEVIEW_EQ"
	PageviewNotContains     PageviewsOperator = "NOT_HAS_PAGEVIEW_CONTAINS"
	PageviewNotMatchRegexpt PageviewsOperator = "NOT_HAS_PAGEVIEW_MATCHES_REGEX"
)

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

func DumpRequest

func DumpRequest(req *http.Request, showBody bool)

DumpRequest shows the request at console

func NewContactListOptions

func NewContactListOptions(listCount, offset int) *contactListsOptions

Types

type APIKeyAuth

type APIKeyAuth struct {
	// contains filtered or unexported fields
}

func NewAPIKeyAuth

func NewAPIKeyAuth(apikey string) APIKeyAuth

NewAPIKeyAuth create new API KEY Authenticator

func (APIKeyAuth) Authenticate

func (auth APIKeyAuth) Authenticate(request *http.Request) error

Authenticate set auth

type Authenticator

type Authenticator interface {
	Authenticate(request *http.Request) error
}

Authenticator interface for auth

type CompaniesService

type CompaniesService service

type Company

type Company struct {
	PortalId   int               `json:"portalId"`
	CompanyId  int               `json:"companyId"`
	IsDeleted  bool              `json:"isDeleted"`
	Properties CompanyProperties `json:"properties"`
}

type CompanyProperties

type CompanyProperties struct {
}

type CompanyPropertiesService

type CompanyPropertiesService service

CompanyPropertiesService Company Properties Service definition

func (*CompanyPropertiesService) Create

func (s *CompanyPropertiesService) Create(property ItemProperty) (*ItemProperty, error)

Create create a contact property

func (*CompanyPropertiesService) CreateGroup

CreateGroup creates a contact property group

func (*CompanyPropertiesService) Delete

func (s *CompanyPropertiesService) Delete(name string) error

Delete deletes a contact property by name

func (*CompanyPropertiesService) DeleteGroup

func (s *CompanyPropertiesService) DeleteGroup(name string) error

DeleteGroup deletes a contact property group

func (*CompanyPropertiesService) GetAll

GetAll gets all company properties

func (*CompanyPropertiesService) GetByName

func (s *CompanyPropertiesService) GetByName(name string) (*ItemProperty, error)

GetByName gets company property by name

func (*CompanyPropertiesService) GetGroups

GetGroups gets all contacts property groups

func (*CompanyPropertiesService) Update

func (s *CompanyPropertiesService) Update(name string, update ItemProperty) (*ItemProperty, error)

Update updates an existing property by it name

func (*CompanyPropertiesService) UpdateGroup

func (s *CompanyPropertiesService) UpdateGroup(name string, update ItemPropertyGroup) (*ItemPropertyGroup, error)

UpdateGroup updates contact property group

type ComputedProperty

type ComputedProperty string

type Contact

type Contact struct {
	Vid          int        `json:"vid"`
	CanonicalVid int        `json:"canonical-vid"`
	MergedVids   []int      `json:"merged-vids"`
	PortalID     int        `json:"portal-id"`
	IsContact    bool       `json:"is-contact"`
	ProfileToken string     `json:"profile-token"`
	ProfileURL   string     `json:"profile-url"`
	Properties   Properties `json:"properties"`
}

type ContactDeleteResult

type ContactDeleteResult struct {
	VID     int    `json:"vid"`
	Deleted bool   `json:"deleted"`
	Reason  string `json:"reason"`
}

type ContactFilterItem

type ContactFilterItem struct {
	Operator         ContactOperator  `json:"operator"`
	Property         string           `json:"property"`
	ComputedProperty ComputedProperty `json:"computed_property"`
	Value            interface{}      `json:"value"`
	Type             string           `json:"type"`
}

type ContactList

type ContactList struct {
	ParentID       int      `json:"parentId"` // Integer, read-only; The ID of the folder that the list belongs to.  Currently folders can only be managed in the HubSpot app
	Dynamic        bool     `json:"dynamic"`
	Name           string   `json:"name"`
	Filters        Filters  `json:"filters"`
	PortalID       int      `json:"portalId"`
	CreatedAt      UnixTime `json:"createdAt"`
	ListID         int      `json:"listId"`
	UpdatedAt      UnixTime `json:"updatedAt"`
	InternalListID int      `json:"internalListId"`
	Deleteable     bool     `json:"deleteable"`
	Metadata       Metadata `json:"metaData"`
}

type ContactLists

type ContactLists struct {
	Lists []ContactList `json:"lists"`
	Page
}

type ContactListsService

type ContactListsService service

func (*ContactListsService) CreateContactList

func (s *ContactListsService) CreateContactList(name string) (*ContactList, error)

func (*ContactListsService) GetContactList

func (s *ContactListsService) GetContactList(listId int) (*ContactList, error)

func (*ContactListsService) GetContactLists

func (s *ContactListsService) GetContactLists() (*ContactLists, error)

type ContactOperator

type ContactOperator FilterOperator

type ContactPropertiesService

type ContactPropertiesService service

ContactPropertiesService - Contact properties are used to store specific information for each of your contact records

func (*ContactPropertiesService) Create

func (s *ContactPropertiesService) Create(property ItemProperty) (*ItemProperty, error)

Create create a contact property

func (*ContactPropertiesService) CreateGroup

CreateGroup creates a contact property group

func (*ContactPropertiesService) Delete

func (s *ContactPropertiesService) Delete(name string) error

Delete deletes a contact property by name

func (*ContactPropertiesService) DeleteGroup

func (s *ContactPropertiesService) DeleteGroup(name string) error

DeleteGroup deletes a contact property group

func (*ContactPropertiesService) GetAll

GetAll gets all contacts properties

func (*ContactPropertiesService) GetByName

func (s *ContactPropertiesService) GetByName(name string) (*ItemProperty, error)

GetByName gets property by name

func (*ContactPropertiesService) GetGroups

GetGroups gets all contacts property groups

func (*ContactPropertiesService) Update

func (s *ContactPropertiesService) Update(name string, update ItemProperty) (*ItemProperty, error)

Update updates an existing property by it name

func (*ContactPropertiesService) UpdateGroup

func (s *ContactPropertiesService) UpdateGroup(name string, update ItemPropertyGroup) (*ItemPropertyGroup, error)

UpdateGroup updates contact property group

type ContactsService

type ContactsService service

func (*ContactsService) Create

func (s *ContactsService) Create(properties Properties) (*IdentityProfile, error)

func (*ContactsService) CreateOrUpdateByEmail

func (s *ContactsService) CreateOrUpdateByEmail(email string, properties Properties) (*Vid, error)

func (*ContactsService) DeleteByEmail

func (s *ContactsService) DeleteByEmail(email string) (*ContactDeleteResult, error)

func (*ContactsService) DeleteById

func (s *ContactsService) DeleteById(id int) (*ContactDeleteResult, error)

func (*ContactsService) GetByToken

func (s *ContactsService) GetByToken(token string) (*Contact, error)

func (*ContactsService) Merge

func (s *ContactsService) Merge(primaryID, secondaryID int) error

func (*ContactsService) Update

func (s *ContactsService) Update(contactID int, properties Properties) error

func (*ContactsService) UpdateByEmail

func (s *ContactsService) UpdateByEmail(email string, properties Properties) error

type EventsFilterItem

type EventsFilterItem struct {
	Operator             EventsOpeerator `json:"operator"`
	EventID              int             `json:"value"`
	FirstOccurenceAfter  UnixTime        `json:"firstOccurrenceAfterTimestamp"`
	FirstOccurenceBefore UnixTime        `json:"firstOccurrenceBeforeTimestamp"`
	LastOccurenceAfter   UnixTime        `json:"lastOccurrenceAfterTimestamp"`
	LastOccurenceBefore  UnixTime        `json:"lastOccurrenceBeforeTimestamp"`
	MinOccurence         int             `json:"minOccurrences"`
	MaxOccurence         int             `json:"maxOccurrences"`
}

type EventsOpeerator

type EventsOpeerator FilterOperator

type Filter

type Filter struct {
}

type FilterItem

type FilterItem struct {
	Operator FilterOperator
}

type FilterOperator

type FilterOperator string

type Filters

type Filters struct {
}

type FormService

type FormService struct {
	// contains filtered or unexported fields
}

FormService The Forms API's principle method is the submit form method, which allows you to pass any information captured on your website or application to HubSpot, including any custom data. This endpoint doesn't require authentication, so you can make the call from a form to our API from the client without needing to worry about insecurity.

func (*FormService) AddOption

func (s *FormService) AddOption(key, value string) *FormService

func (*FormService) AddOptions

func (s *FormService) AddOptions(data url.Values) *FormService

func (*FormService) SetHsContext

func (s *FormService) SetHsContext(context HsContext) *FormService

func (*FormService) SetHubspotCookie

func (s *FormService) SetHubspotCookie(cookie string) *FormService

func (*FormService) SetPageName

func (s *FormService) SetPageName(name string) *FormService

func (*FormService) SetPageUrl

func (s *FormService) SetPageUrl(url string) *FormService

func (*FormService) SetRemoteIpAddress

func (s *FormService) SetRemoteIpAddress(url string) *FormService

func (*FormService) SetReturnUrl

func (s *FormService) SetReturnUrl(url string) *FormService

func (*FormService) SubmitForm

func (s *FormService) SubmitForm(portalID int, formID string) error

type FormSubmissionFilterItem

type FormSubmissionFilterItem struct {
	Operator        FormSubmissionOperator `json:"operator"`
	FormID          int                    `json:"form"`
	PageID          int                    `json:"page"`
	AfterTimestamp  UnixTime               `json:"afterTimestamp"`
	Beforetimestamp UnixTime               `json:"beforeTimestamp"`
}

type FormSubmissionOperator

type FormSubmissionOperator FilterOperator

type HsContext

type HsContext struct {
	Hutk        string `json:"hutk"`
	IPAddress   string `json:"ipAddress"`
	PageURL     string `json:"pageUrl"`
	PageName    string `json:"pageName"`
	RedirectURL string `json:"redirectUrl"`
}

type HubspotClient

type HubspotClient struct {
	BaseURL   *url.URL
	UserAgent string
	// Services used for talking to different parts of the API
	ContactLists      *ContactListsService
	Contacts          *ContactsService
	ContactProperties *ContactPropertiesService
	CompanyProperties *CompanyPropertiesService
	Companies         *CompaniesService
	Forms             *FormService
	// contains filtered or unexported fields
}

func NewHubspotApiClient

func NewHubspotApiClient(apikey string) *HubspotClient

func NewHubspotClient

func NewHubspotClient(auth Authenticator) *HubspotClient

func NewHubspotOAuthClient

func NewHubspotOAuthClient(token string) *HubspotClient

func (*HubspotClient) Do

func (c *HubspotClient) Do(req *http.Request, v interface{}) error

Do sends an API request and returns the API response

func (*HubspotClient) Get

func (c *HubspotClient) Get(url string) (*http.Request, error)

Get creates a new GET API request

func (*HubspotClient) NewRequest

func (c *HubspotClient) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates a new API request.

func (*HubspotClient) Post

func (c *HubspotClient) Post(url string, body interface{}) (*http.Request, error)

Post creates a new POST request

func (*HubspotClient) RunDelete

func (c *HubspotClient) RunDelete(url string, res interface{}) error

func (*HubspotClient) RunGet

func (c *HubspotClient) RunGet(url string, res interface{}) error

func (*HubspotClient) RunPost

func (c *HubspotClient) RunPost(url string, body, res interface{}) error

func (*HubspotClient) RunPut

func (c *HubspotClient) RunPut(url string, body, res interface{}) error

type IdentityProfile

type IdentityProfile struct {
}

type ItemDataType

type ItemDataType string
const (
	String      ItemDataType = "string"
	Number      ItemDataType = "number"
	Date        ItemDataType = "date"
	DateTime    ItemDataType = "datetime"
	Enumeration ItemDataType = "enumeration"
)

type ItemFieldType

type ItemFieldType string
const (
	TextAreaField        ItemFieldType = "textarea"
	TextField            ItemFieldType = "text"
	DateField            ItemFieldType = "date"
	FileField            ItemFieldType = "file"
	NumberField          ItemFieldType = "number"
	SelectField          ItemFieldType = "select"
	RadioField           ItemFieldType = "radio"
	CheckboxField        ItemFieldType = "checkbox"
	BooleanCheckboxField ItemFieldType = "booleancheckbox"
)

type ItemProperties

type ItemProperties []ItemProperty

ItemProperties list of ItemProperty type

type ItemProperty

type ItemProperty struct {
	Name                          string               `json:"name"`
	Label                         string               `json:"label,omitempty"`
	Description                   string               `json:"description,omitempty"`
	DataType                      ItemDataType         `json:"type,omitempty"`
	FieldType                     ItemFieldType        `json:"fieldType,omitempty"`
	GroupName                     string               `json:"groupName,omitempty"`
	Options                       []ItemPropertyOption `json:"options"`
	Deleted                       bool                 `json:"deleted"`
	FormField                     bool                 `json:"formField"`
	DisplayOrder                  int                  `json:"displayOrder"`
	ReadOnlyValue                 bool                 `json:"readOnlyValue,omitempty"`
	ReadOnlyDefinition            bool                 `json:"readOnlyDefinition,omitempty"`
	Hidden                        bool                 `json:"hidden,omitempty"`
	MutableDefinitionNotDeletable bool                 `json:"mutableDefinitionNotDeletable,omitempty"`
	SearchableInGlobalSearch      bool                 `json:"searchableInGlobalSearch,omitempty"`
	Calculated                    bool                 `json:"calculated"`
	ExternalOptions               bool                 `json:"externalOptions"`
}

ItemProperty definition

type ItemPropertyGroup

type ItemPropertyGroup struct {
	Name           string `json:"name"`
	DisplayName    string `json:"displayName"`
	DisplayOrder   int    `json:"displayOrder"`
	HubspotDefined bool   `json:"hubspotDefined"`
}

ItemPropertyGroup item property group definition

type ItemPropertyGroups

type ItemPropertyGroups []ItemPropertyGroup

ItemPropertyGroups ItemPropertyGroup list type

type ItemPropertyOption

type ItemPropertyOption struct {
	Description  string      `json:"description"`
	Label        string      `json:"label"`
	DisplayOrder int         `json:"displayOrder"`
	Hidden       bool        `json:"hidden"`
	Value        interface{} `json:"value"`
}

ItemPropertyOption definition

type ListMembershipFilterItem

type ListMembershipFilterItem struct {
	Operator ListMembershipOperator `json:"operator"`
	ListID   int                    `json:"list"`
}

type ListMembershipOperator

type ListMembershipOperator FilterOperator

type Metadata

type Metadata struct {
	Processing ProcessingType `json:"processing"`

	Size int `json:"size"`

	Error string `json:"error"`

	LastProcessingStateChangeAt UnixTime `json:"lastProcessingStateChangeAt"`

	LastSizeChangeAt UnixTime `json:"lastSizeChangeAt"`
}

type OAuth2

type OAuth2 struct {
	// contains filtered or unexported fields
}

OAuth2 OAuth 2 hubspot authenticator

func NewOAuth2

func NewOAuth2(token string) OAuth2

NewOAuth2 Create new instance of OAuth2

func (OAuth2) Authenticate

func (auth OAuth2) Authenticate(request *http.Request) error

Authenticate auth with OAuth2

type Page

type Page struct {
	Offset  int  `json:"offset"`
	HasMore bool `json:"has-more"`
}

type PageViewFilterItem

type PageViewFilterItem struct {
	Operator             PageviewsOperator `json:"operator"`
	Value                string            `json:"value"`
	FirstOccurenceAfter  UnixTime          `json:"firstOccurrenceAfterTimestamp"`
	FirstOccurenceBefore UnixTime          `json:"firstOccurrenceBeforeTimestamp"`
	LastOccurenceAfter   UnixTime          `json:"lastOccurrenceAfterTimestamp"`
	LastOccurenceBefore  UnixTime          `json:"lastOccurrenceBeforeTimestamp"`
	MinOccurence         int               `json:"minOccurrences"`
	MaxOccurence         int               `json:"maxOccurrences"`
}

type PageviewsOperator

type PageviewsOperator FilterOperator

type ProcessingType

type ProcessingType string
const (
	DONE         ProcessingType = "DONE"
	REFRESHING   ProcessingType = "REFRESHING"
	INITIALIZING ProcessingType = "INITIALIZING"
	PROCESSING   ProcessingType = "PROCESSING"
)

type Properties

type Properties struct {
	Properties []Property `json:"properties"`
}

func (*Properties) AddProperty

func (p *Properties) AddProperty(prop string, value interface{})

AddProperty addes a new property to list

type Property

type Property struct {
	Property string      `json:"property"`
	Value    interface{} `json:"value"`
	Versions Versions    `json:"versions,omitempty"`
}

type UnixTime

type UnixTime struct {
	time.Time
}

func (*UnixTime) MarshalJSON

func (t *UnixTime) MarshalJSON() ([]byte, error)

func (*UnixTime) String

func (t *UnixTime) String() string

func (*UnixTime) ToDate

func (t *UnixTime) ToDate()

func (*UnixTime) UnmarshalJSON

func (t *UnixTime) UnmarshalJSON(data []byte) error

type Version

type Version struct {
	Value       interface{} `json:"value"`
	SourceType  string      `json:"source-type"`
	SourceID    string      `json:"source-id"`
	SourceLabel string      `json:"source-label"`
	Timestamp   UnixTime    `json:"timestamp"`
	Selected    bool        `json:"selected"`
}

type Versions

type Versions []Version

type Vid

type Vid struct {
	VID   int  `json:"vid"`
	IsNew bool `json:"isNew"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL