Documentation ¶
Index ¶
- Constants
- Variables
- func GetResultId(row *common.ReadResultRow) string
- type AccountInfo
- type Connector
- func (c *Connector) GetAccountInfo(ctx context.Context) (*AccountInfo, *common.JSONHTTPResponse, error)
- func (c *Connector) GetPostAuthInfo(ctx context.Context) (*common.PostAuthInfo, error)
- func (c *Connector) GetRecord(ctx context.Context, objectName string, recordId string) (*common.ReadResultRow, error)
- func (c *Connector) GetRecordFromSubscriptionEvent(ctx context.Context, evt *SubscriptionEvent) (*common.ReadResultRow, error)
- func (c *Connector) GetRecordsWithIds(ctx context.Context, objectName string, ids []string, fields []string) ([]common.ReadResultRow, error)
- func (c *Connector) HTTPClient() *common.HTTPClient
- func (c *Connector) JSONHTTPClient() *common.JSONHTTPClient
- func (c *Connector) ListObjectMetadata(ctx context.Context, objectNames []string) (*common.ListObjectMetadataResult, error)
- func (c *Connector) Provider() providers.Provider
- func (c *Connector) Read(ctx context.Context, config common.ReadParams) (*common.ReadResult, error)
- func (c *Connector) Search(ctx context.Context, config SearchParams) (*common.ReadResult, error)
- func (c *Connector) String() string
- func (c *Connector) VerifyWebhookMessage(_ context.Context, params *common.WebhookVerificationParameters) (bool, error)
- func (c *Connector) Write(ctx context.Context, config common.WriteParams) (*common.WriteResult, error)
- type ErrContext
- type ErrDetail
- type ErrLinks
- type Filter
- type FilterGroup
- type FilterOperatorType
- type HubspotError
- type ObjectField
- type ObjectType
- type Option
- type SearchParams
- type SortBy
- type SortDirection
- type SubscriptionEvent
Constants ¶
const ( // ModuleEmpty is used for proxying requests through. ModuleEmpty common.ModuleID = "" // ModuleCRM is the module used for accessing standard CRM objects. ModuleCRM common.ModuleID = "CRM" )
const ( SortDirectionAsc SortDirection = "ASCENDING" SortDirectionDesc SortDirection = "DESCENDING" FilterOperatorTypeEQ FilterOperatorType = "EQ" FilterOperatorTypeNEQ FilterOperatorType = "NEQ" FilterOperatorTypeGT FilterOperatorType = "GT" FilterOperatorTypeGTE FilterOperatorType = "GTE" FilterOperatorTypeLT FilterOperatorType = "LT" FilterOperatorTypeLTE FilterOperatorType = "LTE" FilterOperatorBetween FilterOperatorType = "BETWEEN" FilterOperatorIN FilterOperatorType = "IN" FilterOperatorNIN FilterOperatorType = "NIN" FilterPropertyHasProperty FilterOperatorType = "HAS_PROPERTY" FilterPropertyNotHasProperty FilterOperatorType = "NOT_HAS_PROPERTY" FilterPropertyContainsToken FilterOperatorType = "CONTAINS_TOKEN" FilterPropertyNotContainsToken FilterOperatorType = "NOT_CONTAINS_TOKEN" )
const (
// DefaultPageSize is the default page size for paginated requests.
DefaultPageSize = "100"
)
Variables ¶
Functions ¶
func GetResultId ¶
func GetResultId(row *common.ReadResultRow) string
GetResultId returns the id of a hubspot result row. nolint:cyclop
Types ¶
type AccountInfo ¶
type AccountInfo struct { PortalId int `json:"portalId"` TimeZone string `json:"timeZone"` CompanyCurrency string `json:"companyCurrency"` AdditionalCurrencies []string UTCOffset string `json:"utcOffset"` UTCOffsetMilliseconds int `json:"utcOffsetMilliseconds"` UIDomain string `json:"uiDomain"` DataHostingLocation string `json:"dataHostingLocation"` }
type Connector ¶
type Connector struct { BaseURL string Client *common.JSONHTTPClient Module common.Module }
Connector is a Hubspot connector.
func NewConnector ¶
NewConnector returns a new Hubspot connector.
func (*Connector) GetAccountInfo ¶
func (c *Connector) GetAccountInfo(ctx context.Context) (*AccountInfo, *common.JSONHTTPResponse, error)
func (*Connector) GetPostAuthInfo ¶
func (*Connector) GetRecord ¶
func (c *Connector) GetRecord(ctx context.Context, objectName string, recordId string) (*common.ReadResultRow, error)
GetRecord returns a record from the object with the given ID and object name.
func (*Connector) GetRecordFromSubscriptionEvent ¶
func (c *Connector) GetRecordFromSubscriptionEvent( ctx context.Context, evt *SubscriptionEvent, ) (*common.ReadResultRow, error)
GetRecordFromSubscriptionEvent fetches a record from the Hubspot API using the data from a subscription event.
func (*Connector) GetRecordsWithIds ¶
func (*Connector) HTTPClient ¶
func (c *Connector) HTTPClient() *common.HTTPClient
func (*Connector) JSONHTTPClient ¶
func (c *Connector) JSONHTTPClient() *common.JSONHTTPClient
JSONHTTPClient returns the underlying JSON HTTP client.
func (*Connector) ListObjectMetadata ¶
func (c *Connector) ListObjectMetadata( ctx context.Context, objectNames []string, ) (*common.ListObjectMetadataResult, error)
ListObjectMetadata returns object metadata for each object name provided.
func (*Connector) Read ¶
func (c *Connector) Read(ctx context.Context, config common.ReadParams) (*common.ReadResult, error)
Read reads data from Hubspot. If Since is set, it will use the Search endpoint instead to filter records, but it will be limited to a maximum of 10,000 records. This is a limit of the search endpoint. If Since is not set, it will use the read endpoint. In case Deleted objects won’t appear in any search results. Deleted objects can only be read by using this endpoint.
func (*Connector) Search ¶
func (c *Connector) Search(ctx context.Context, config SearchParams) (*common.ReadResult, error)
Search uses the POST /search endpoint to filter object records and return the result. This endpoint has a limit of 10,000 records. If the result has more than 10,000 records, the caller should employ sorting to paginate through the result on the client side. This endpoint paginates using paging.next.after which is to be used as an offset. Archived results do not appear in search results. Read more @ https://developers.hubspot.com/docs/api/crm/search
func (*Connector) String ¶
String returns a string representation of the connector, which is useful for logging / debugging.
func (*Connector) VerifyWebhookMessage ¶
func (c *Connector) VerifyWebhookMessage( _ context.Context, params *common.WebhookVerificationParameters, ) (bool, error)
VerifyWebhookMessage verifies the signature of a webhook message from Hubspot.
func (*Connector) Write ¶
func (c *Connector) Write(ctx context.Context, config common.WriteParams) (*common.WriteResult, error)
type ErrContext ¶
type Filter ¶
type Filter struct { FieldName string `json:"propertyName,omitempty"` Operator FilterOperatorType `json:"operator,omitempty"` Value string `json:"value,omitempty"` }
func BuildIdFilterGroup ¶
BuildIdFilterGroup filters records greater than the given id.
func BuildLastModifiedFilterGroup ¶
func BuildLastModifiedFilterGroup(params *common.ReadParams) Filter
BuildLastModifiedFilterGroup filters records modified since the given time. If the time is zero, it returns an empty filter. For contacts, it uses the lastmodifieddate field. For other objects, it uses the hs_lastmodifieddate. Read more: https://community.hubspot.com/t5/APIs-Integrations/CRM-V3-API-Search-issue-with-Contacts-when-using-Filters/m-p/324617
type FilterGroup ¶
type FilterGroup struct {
Filters []Filter `json:"filters,omitempty"`
}
type FilterOperatorType ¶
type FilterOperatorType string
type HubspotError ¶
type HubspotError struct { HTTPStatusCode int `json:"httpStatusCode"` 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 ObjectField ¶
type ObjectField string
ObjectField is used to define fields that exist on a hubspot object.
const ( ObjectFieldHsObjectId ObjectField = "hs_object_id" ObjectFieldHsLastModifiedDate ObjectField = "hs_lastmodifieddate" ObjectFieldLastModifiedDate ObjectField = "lastmodifieddate" ObjectFieldId ObjectField = "id" ObjectFieldProperties ObjectField = "properties" )
type Option ¶
type Option = func(params *parameters)
Option is a function which mutates the hubspot connector configuration.
func WithAuthenticatedClient ¶
func WithAuthenticatedClient(client common.AuthenticatedHTTPClient) Option
WithAuthenticatedClient sets the http client to use for the connector. Its usage is optional.
func WithClient ¶
func WithClient(ctx context.Context, client *http.Client, config *oauth2.Config, token *oauth2.Token, opts ...common.OAuthOption, ) Option
WithClient sets the http client to use for the connector. Saves some boilerplate.
func WithModule ¶
WithModule sets the hubspot API module to use for the connector. It's required.
type SearchParams ¶
type SearchParams struct { // The name of the object we are reading, e.g. "Account" ObjectName string // required // NextPage is an opaque token that can be used to get the next page of results. NextPage common.NextPageToken // optional, only set this if you want to read the next page of results // SortBy is the field to sort by in the direction specified by SortDirection. SortBy []SortBy // optional // FilterBy is the filter to apply to the search FilterGroups []FilterGroup // optional // Fields is the list of fields to return in the result. Fields datautils.Set[string] // optional }
func (SearchParams) ValidateParams ¶
func (p SearchParams) ValidateParams() error
type SortBy ¶
type SortBy struct { // The name of the field to sort by. PropertyName string `json:"propertyName,omitempty"` // The direction to sort by. Direction SortDirection `json:"direction,omitempty"` }
func BuildSort ¶
func BuildSort(field ObjectField, dir SortDirection) SortBy
BuildSort builds a sort by clause for the given field and direction.
type SortDirection ¶
type SortDirection string
type SubscriptionEvent ¶
type SubscriptionEvent struct { AppId int `json:"appId"` EventId int `json:"eventId"` SubscriptionId int `json:"subscriptionId"` PortalId int `json:"portalId"` OccurredAt int `json:"occurredAt"` SubscriptionType string `json:"subscriptionType"` AttemptNumber int `json:"attemptNumber"` ObjectId int `json:"objectId"` ChangeSource string `json:"changeSource"` PropertyName string `json:"propertyName"` PropertyValue string `json:"propertyValue"` }
func (*SubscriptionEvent) EventType ¶
func (evt *SubscriptionEvent) EventType() (common.SubscriptionEventType, error)
func (*SubscriptionEvent) ObjectName ¶
func (evt *SubscriptionEvent) ObjectName() (string, error)
func (*SubscriptionEvent) RawEventName ¶
func (evt *SubscriptionEvent) RawEventName() (string, error)
func (*SubscriptionEvent) Workspace ¶
func (evt *SubscriptionEvent) Workspace() (string, error)