hubspot

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindInPages added in v0.2.6

func FindInPages(pager func(*Page) (*PageResponse, error), predicate func(data interface{}) (bool, error)) (interface{}, error)

FindInPages - finds an item in results of a paging mechanism

Types

type Association

type Association struct {
	From int64
	To   int64
	Type AssociationType
}

Association - association of objects in hubspot

type AssociationType

type AssociationType int8

AssociationType - type of data association

const (
	AssociationContactToCompany            AssociationType = 1
	AssociationCompanyToContact            AssociationType = 2
	AssociationDealToContact               AssociationType = 3
	AssociationContactToDeal               AssociationType = 4
	AssociationDealToCompany               AssociationType = 5
	AssociationCompanyToDeal               AssociationType = 6
	AssociationCompanyToEngagement         AssociationType = 7
	AssociationEngagementToCompany         AssociationType = 8
	AssociationContactToEngagement         AssociationType = 9
	AssociationEngagementToContact         AssociationType = 10
	AssociationDealToEngagement            AssociationType = 11
	AssociationEngagementToDeal            AssociationType = 12
	AssociationParentCompanyToChildCompany AssociationType = 13
	AssociationChildCompanyToParentCompany AssociationType = 14
	AssociationContactToTicket             AssociationType = 15
	AssociationTicketToContact             AssociationType = 16
	AssociationTicketToEngagement          AssociationType = 17
	AssociationEngagementToTicket          AssociationType = 18
	AssociationDealToLineItem              AssociationType = 19
	AssociationLineItemToDeal              AssociationType = 20
	AssociationCompanyToTicket             AssociationType = 25
	AssociationTicketToCompany             AssociationType = 26
	AssociationDealToTicket                AssociationType = 27
	AssociationTicketToDeal                AssociationType = 28
	AssociationAdvisorToCompany            AssociationType = 33
	AssociationCompanyToAdvisor            AssociationType = 34
	AssociationBoardMemberToCompany        AssociationType = 35
	AssociationCompanyToBoardMember        AssociationType = 36
	AssociationContractorToCompany         AssociationType = 37
	AssociationCompanyToContractor         AssociationType = 38
	AssociationManagerToCompany            AssociationType = 39
	AssociationCompanyToManager            AssociationType = 40
	AssociationBusinessOwnerToCompany      AssociationType = 41
	AssociationCompanyToBusinessOwner      AssociationType = 42
	AssociationPartnerToCompany            AssociationType = 43
	AssociationCompanyToPartner            AssociationType = 44
	AssociationResellerToCompany           AssociationType = 45
	AssociationCompanyToReseller           AssociationType = 46
)

type Associations

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

Associations - hubspot associations api using rest

func NewAssociations added in v0.2.0

func NewAssociations(rest IRestClient) *Associations

NewAssociations - creates a new associations api

func (*Associations) Create

func (api *Associations) Create(fromid int64, toid int64, asstype AssociationType) error

Create - creates a new association of two objects in hubspot

func (*Associations) CreateBulk

func (api *Associations) CreateBulk(data []*Association) error

CreateBulk - creates multiple associations in one call

func (*Associations) Delete

func (api *Associations) Delete(fromid int64, toid int64, asstype AssociationType) error

Delete - deletes an object association

func (*Associations) DeleteBulk

func (api *Associations) DeleteBulk(data []*Association) error

DeleteBulk - deletes multiple associations at once

func (*Associations) List

func (api *Associations) List(objectid int64, asstype AssociationType, page *Page) (*PageResponse, error)

List - lists associations of a type for an object

type Companies

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

Companies - access to companies api of hubspot using http

func NewCompanies

func NewCompanies(rest IRestClient, model *Model) *Companies

NewCompanies - creates a new companies api

func (*Companies) BatchUpdate

func (api *Companies) BatchUpdate(companies []interface{}) error

BatchUpdate - updates multiple companies in hubspot in a single call

func (*Companies) Create

func (api *Companies) Create(company interface{}) (interface{}, error)

Create - creates a new company in hubspot

func (*Companies) Delete

func (api *Companies) Delete(id int64) error

Delete - deletes a company in backend

func (*Companies) Get

func (api *Companies) Get(id int64) (interface{}, error)

Get - get a company by id

func (*Companies) List

func (api *Companies) List(page *Page, props ...string) (*PageResponse, error)

List - lists a page of companies in hubspot

func (*Companies) Query added in v0.3.0

func (api *Companies) Query() IQuery

Query - creates a query usable to search for contacts

func (*Companies) RecentlyCreated

func (api *Companies) RecentlyCreated(page *Page) (*PageResponse, error)

RecentlyCreated - get a list of recently created companies

func (*Companies) RecentlyModified

func (api *Companies) RecentlyModified(page *Page) (*PageResponse, error)

RecentlyModified - get recently modified companies

func (*Companies) SearchByDomain

func (api *Companies) SearchByDomain(domain string, page *Page, props ...string) (*PageResponse, error)

SearchByDomain - lists companies by filtering for their domain

func (*Companies) Update

func (api *Companies) Update(id int64, company interface{}) (interface{}, error)

Update - updates a company in hubspot

type Contacts

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

Contacts - hubspot contacts api

func NewContacts

func NewContacts(rest IRestClient, model *Model) *Contacts

NewContacts - creates a new contacts api

func (*Contacts) CreateOrUpdate

func (api *Contacts) CreateOrUpdate(email string, contact interface{}) (int64, error)

CreateOrUpdate - creates or updates a contact in hubspot

func (*Contacts) Delete

func (api *Contacts) Delete(id int64) error

Delete - deletes a contact in hubspot

func (*Contacts) GetByEmail

func (api *Contacts) GetByEmail(email string) (interface{}, error)

GetByEmail - get contact information by email

func (*Contacts) GetByID

func (api *Contacts) GetByID(id int64) (interface{}, error)

GetByID - get a contact by id

func (*Contacts) ListPage

func (api *Contacts) ListPage(page *Page, props ...string) (*PageResponse, error)

ListPage - lists a page of contact listing in hubspot

func (*Contacts) Query added in v0.3.0

func (api *Contacts) Query() IQuery

Query - creates a query usable to search for contacts

func (*Contacts) Update

func (api *Contacts) Update(id int64, contact interface{}) error

Update - updates a contact in hubspot

type Deals added in v0.2.0

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

Deals - rest implementation of hubspot deals api

func NewDeals added in v0.2.0

func NewDeals(rest IRestClient, model *Model) *Deals

NewDeals - creates a new deals api

func (*Deals) Create added in v0.2.0

func (api *Deals) Create(deal interface{}) (interface{}, error)

Create - creates a deal in hubspot

func (*Deals) Delete added in v0.2.0

func (api *Deals) Delete(id int64) error

Delete - delete a deal in hubspot

func (*Deals) Get added in v0.2.0

func (api *Deals) Get(id int64) (interface{}, error)

Get - get deal information from hubspot

func (*Deals) List added in v0.2.0

func (api *Deals) List(page *Page, includeassociations bool, props ...string) (*PageResponse, error)

List - lists a page of deals from hubspot

func (*Deals) Query added in v0.3.0

func (api *Deals) Query() IQuery

Query - searches for deals by criterias

func (*Deals) RecentlyCreated added in v0.2.0

func (api *Deals) RecentlyCreated(page *Page, since *time.Time, includeassociations bool) (*PageResponse, error)

RecentlyCreated - lists a page of recently created deals

func (*Deals) RecentlyModified added in v0.2.0

func (api *Deals) RecentlyModified(page *Page, since *time.Time, includeassociations bool) (*PageResponse, error)

RecentlyModified - lists a page of recently modified deals

func (*Deals) Update added in v0.2.0

func (api *Deals) Update(id int64, deal interface{}) (interface{}, error)

Update - updates data of a deal

func (*Deals) UpdateBulk added in v0.2.0

func (api *Deals) UpdateBulk(deals []interface{}) error

UpdateBulk - updates multiple deal entries in hubspot

type Filter added in v0.3.0

type Filter struct {
	PropertyName string      `json:"propertyName"`
	Operator     string      `json:"operator"`
	Value        interface{} `json:"value,omitempty"`
}

Filter - a filter for a property filters are combined using AND by hubspot

func ContainsToken added in v0.3.0

func ContainsToken(property string) *Filter

func Equals added in v0.3.0

func Equals(property string, value interface{}) *Filter

Equals - creates a filter which checks for equality

func Greater added in v0.3.0

func Greater(property string, value interface{}) *Filter

func GreaterEqual added in v0.3.0

func GreaterEqual(property string, value interface{}) *Filter

func HasProperty added in v0.3.0

func HasProperty(property string) *Filter

func Less added in v0.3.0

func Less(property string, value interface{}) *Filter

func LessEqual added in v0.3.0

func LessEqual(property string, value interface{}) *Filter

func NotContainsToken added in v0.3.0

func NotContainsToken(property string) *Filter

func NotEquals added in v0.3.0

func NotEquals(property string, value interface{}) *Filter

NotEquals - creates a filter which checks whether a property does not equal a value

func NotHasProperty added in v0.3.0

func NotHasProperty(property string) *Filter

type FilterGroup added in v0.3.0

type FilterGroup struct {
	Filters []*Filter `json:"filters"`
}

FilterGroup - specifies a group of filters filter groups are combined using OR by hubspot

type IAssociations

type IAssociations interface {
	Create(fromid int64, toid int64, asstype AssociationType) error
	CreateBulk(data []*Association) error
	List(objectid int64, asstype AssociationType, page *Page) (*PageResponse, error)
	Delete(fromid int64, toid int64, asstype AssociationType) error
	DeleteBulk(data []*Association) error
}

IAssociations - interface for associations api

type ICompanies

type ICompanies interface {
	Create(company interface{}) (interface{}, error)
	Update(id int64, company interface{}) (interface{}, error)
	BatchUpdate(companies []interface{}) error
	List(page *Page, props ...string) (*PageResponse, error)
	RecentlyModified(page *Page) (*PageResponse, error)
	RecentlyCreated(page *Page) (*PageResponse, error)
	SearchByDomain(domain string, page *Page, props ...string) (*PageResponse, error)
	Delete(id int64) error
	Get(id int64) (interface{}, error)
	Query() IQuery
}

ICompanies - access to companies api of hubspot

type IContacts

type IContacts interface {
	CreateOrUpdate(email string, contact interface{}) (int64, error)
	Update(id int64, contact interface{}) error
	Delete(id int64) error
	ListPage(page *Page, props ...string) (*PageResponse, error)
	GetByID(id int64) (interface{}, error)
	GetByEmail(email string) (interface{}, error)
	Query() IQuery
}

IContacts - interface for the hubspot contact api

type IDeals added in v0.2.0

type IDeals interface {
	Create(deal interface{}) (interface{}, error)
	Update(id int64, deal interface{}) (interface{}, error)
	UpdateBulk(deals []interface{}) error
	List(page *Page, includeassociations bool, props ...string) (*PageResponse, error)
	RecentlyModified(page *Page, since *time.Time, includeassociations bool) (*PageResponse, error)
	RecentlyCreated(page *Page, since *time.Time, includeassociations bool) (*PageResponse, error)
	Delete(id int64) error
	Get(id int64) (interface{}, error)
	Query() IQuery
}

IDeals - interface for deals api

type IQuery added in v0.3.0

type IQuery interface {
	Where(filter ...*Filter) IQuery
	Properties(props ...string) IQuery
	Ascending(property string) IQuery
	Descending(property string) IQuery
	Execute(*Page) (*PageResponse, error)
}

IQuery - query for crm data

type IRestClient

type IRestClient interface {
	Post(url string, request interface{}, params ...*Parameter) (map[string]interface{}, error)
	Put(url string, request interface{}, params ...*Parameter) (map[string]interface{}, error)
	Delete(url string) error
	Get(url string, params ...*Parameter) (map[string]interface{}, error)
	BeginQuota()
	EndQuota()
}

IRestClient - interface for a client sending rest requests to hubspot

type ITickets added in v0.2.0

type ITickets interface {
	Create(ticket interface{}) (interface{}, error)
	Get(id int64) (interface{}, error)
	Query() IQuery
}

ITickets - access to tickets-api in hubspot

type Model

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

Model - model for hubspot entity mapping

func NewModel

func NewModel(entitytype reflect.Type) *Model

NewModel - creates a new model for an entity use tag values for 'hubspot' to specify hubspot properties. If no hubspot tag is specified the field name in all lower cases is used as fieldname on hubspot as default

name=<string> - specify hubspot field name
id            - transfer hubspot entity id to this field
deleted       - transfer deleted flag to this field
noexport      - don't export this field to hubspot on create/update

func (*Model) GetCompanies added in v0.2.0

func (mdl *Model) GetCompanies(entity interface{}) []int64

GetCompanies - get linked companies of a deal

func (*Model) GetContacts added in v0.2.0

func (mdl *Model) GetContacts(entity interface{}) []int64

GetContacts - get linked contacts of a deal

func (*Model) GetID

func (mdl *Model) GetID(entity interface{}) interface{}

GetID - get id of an entity

func (*Model) GetProperty

func (mdl *Model) GetProperty(name string) *ModelProperty

GetProperty - get property of model

type ModelProperty

type ModelProperty struct {
	StructField string
	HubspotName string
	NoExport    bool
}

ModelProperty - property in a hubspot model

func (*ModelProperty) GetValue

func (prop *ModelProperty) GetValue(entity reflect.Value) interface{}

GetValue - get value of a property

func (*ModelProperty) SetValue

func (prop *ModelProperty) SetValue(data map[string]interface{}, valuename string, entity reflect.Value)

SetValue - set value from a json response to an entity which is based on this model

type Options

type Options struct {
	IgnoreNil bool // ignores nil properties when updating data
}

type Page

type Page struct {
	Offset int64
	Count  int
}

Page - parameters for a page to be listed

func NewPage

func NewPage(offset int64, count int) *Page

NewPage - creates a new page parameter

**Parameters**

offset: offset where to start listing (use offset returned by a former page request)
count : number of items to return. If <= 0 is specified as count the request default is used

type PageResponse

type PageResponse struct {
	Data    []interface{}
	Offset  int64
	HasMore bool
}

PageResponse - response of a list page request

type Parameter

type Parameter struct {
	Key   string
	Value string
}

Parameter - parameter for a rest client

func NewParameter

func NewParameter(key string, value string) *Parameter

NewParameter - creates a new parameter

type Query added in v0.3.0

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

Query - a query for data in hubspot

func (*Query) Ascending added in v0.3.0

func (q *Query) Ascending(property string) IQuery

Ascending - creates a sort criteria in ascending order

func (*Query) Descending added in v0.3.0

func (q *Query) Descending(property string) IQuery

Descending - creates a sort criteria in descending order

func (*Query) Execute added in v0.3.0

func (q *Query) Execute(page *Page) (*PageResponse, error)

Execute - executes the query and returns the result

func (*Query) Properties added in v0.3.0

func (q *Query) Properties(props ...string) IQuery

Properties - specified properties to return in result objects if this is not specified only a default set of properties is returned for every object

func (*Query) Text added in v0.3.0

func (q *Query) Text(text string) IQuery

Text - specifies a text to query for in all properties

func (*Query) Where added in v0.3.0

func (q *Query) Where(filters ...*Filter) IQuery

Where - specifies a filter to query for Use the following methods to create filters

Equal            - property has to be equal to a value
NotEqual         - property must not equal a value
Less             - property has to be less than a value
LessEqual        - property has to be less or equal to a value
Greater          - property has to be greater than a value
GreaterEqual     - property has to be greater or equal to a value
HasProperty      - object has to contain a property
NotHasProperty   - object must not contain a property (value)
ContainsToken    - object must contain a token
NotContainsToken - object must not contain a token

All filters in a single call are combined using AND. Every following call is combined with OR to the other calls.

type QueryData added in v0.3.0

type QueryData struct {
	Limit int    `json:"limit,omitempty"`
	After string `json:"after,omitempty"`

	Properties []string `json:"properties,omitempty"` // properties to return
	Sorts      []*Sort  `json:"sorts,omitempty"`
	Text       string   `json:"query,omitempty"`

	// filters and filtergroups are mutually exclusive properties
	Filters      []*Filter      `json:"filters,omitempty"`
	FilterGroups []*FilterGroup `json:"filterGroups,omitempty"`
}

QueryData - data send to a hubspot query endpoint

type RestClient

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

RestClient - client used to send rest requests to hubspot

func NewRest

func NewRest(address string, apikey string) *RestClient

NewRest - creates a new rest client

func (*RestClient) BeginQuota added in v0.3.0

func (client *RestClient) BeginQuota()

BeginQuota - starts a quota call and waits until the next call is valid Always call EndQuota after a call to BeginQuota since sync involves a mutex which would deadlock otherwise this is used for queries since currently they are rate limited to 1 query per second

func (*RestClient) Delete

func (client *RestClient) Delete(address string) error

Delete - send a DELETE request to hubspot

func (*RestClient) EndQuota added in v0.3.0

func (client *RestClient) EndQuota()

EndQuota - ends a quota call

func (*RestClient) Get

func (client *RestClient) Get(address string, params ...*Parameter) (map[string]interface{}, error)

Get - send a GET request to hubspot

func (*RestClient) Post

func (client *RestClient) Post(address string, request interface{}, params ...*Parameter) (map[string]interface{}, error)

Post - send a POST request to hubspot

func (*RestClient) Put

func (client *RestClient) Put(address string, request interface{}, params ...*Parameter) (map[string]interface{}, error)

Put - send a PUT request to hubspot

type Sort added in v0.3.0

type Sort struct {
	Property  string `json:"propertyName"`
	Direction string `json:"direction"`
}

Sort - sort critera for a query

type Tickets added in v0.2.0

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

Tickets - access to tickets-api using rest

func NewTickets added in v0.2.0

func NewTickets(rest IRestClient, model *Model) *Tickets

NewTickets - creates a new tickets api

func (*Tickets) Create added in v0.2.0

func (api *Tickets) Create(ticket interface{}) (interface{}, error)

Create - creates a ticket in hubspot

func (*Tickets) Get added in v0.2.0

func (api *Tickets) Get(id int64) (interface{}, error)

Get - get a ticket by id

func (*Tickets) Query added in v0.3.0

func (api *Tickets) Query() IQuery

Query - creates a query usable to search for contacts

Jump to

Keyboard shortcuts

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