crm

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package crm implements HubSpot CRM API requests using a portal access token.

Index

Constants

View Source
const (
	AccountMetadataPath   = "/account-info/v3/details"
	ContactPropertiesPath = "/crm/properties/" + supportedAPIVersion + "/contacts"
)
View Source
const (
	MaxBatchUpsertInputs = 100
)

Variables

This section is empty.

Functions

func IsCustomObjectTypeID

func IsCustomObjectTypeID(objectType string) bool

func IsStandardObject

func IsStandardObject(objectType string) bool

Types

type AccountDetails

type AccountDetails struct {
	AccountID   int64  `json:"portalId"`
	CompanyName string `json:"companyName"`
}

type Client

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

func New

func New(ctx context.Context, config Config, accessToken string) (*Client, error)

New validates the access token and base URL, then creates an SSRF-protected transport when private hosts are disabled.

func (*Client) AccountDetails

func (c *Client) AccountDetails(ctx context.Context) (*AccountDetails, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) List

func (c *Client) List(ctx context.Context, req ListRequest) (*Page, error)

func (*Client) ListCustomObjectSchemas

func (c *Client) ListCustomObjectSchemas(ctx context.Context) ([]CustomObjectSchema, error)

func (*Client) ListCustomObjectSchemasBounded

func (c *Client) ListCustomObjectSchemasBounded(
	ctx context.Context,
	maxBytes int64,
) ([]CustomObjectSchema, error)

ListCustomObjectSchemasBounded retrieves account-defined object schemas and their property definitions under the caller's response-size budget.

func (*Client) ListProperties

func (c *Client) ListProperties(ctx context.Context, objectType string) ([]Property, error)

func (*Client) ListPropertiesBounded

func (c *Client) ListPropertiesBounded(ctx context.Context, objectType string, maxBytes int64) ([]Property, error)

ListPropertiesBounded lists schema properties while limiting the provider response before decoding it into an in-memory property slice.

func (*Client) Search

func (c *Client) Search(ctx context.Context, req SearchRequest) (*Page, error)

func (*Client) Upsert

func (c *Client) Upsert(ctx context.Context, req UpsertRequest) (*UpsertResult, error)

type Config

type Config struct {
	BaseURL           string `json:"base_url,omitempty" validate:"omitempty,url"`
	TimeoutSeconds    int    `json:"timeout_seconds,omitempty" validate:"omitempty,min=1,max=300"`
	AllowPrivateHosts bool   `json:"allow_private_hosts,omitempty"`
}

type CustomObjectSchema

type CustomObjectSchema struct {
	ObjectTypeID string
	Name         string
	Label        string
	Properties   []Property
}

type Filter

type Filter struct {
	PropertyName string
	Operator     string
	Value        any
	HighValue    any
	Values       []any
}

type FilterGroup

type FilterGroup struct {
	Filters []Filter
}

type ListRequest

type ListRequest struct {
	ObjectType       string
	Properties       []string
	After            string
	Limit            int
	MaxResponseBytes int64
}

type Object

type Object struct {
	Name  string `json:"name"`
	Label string `json:"label"`
}

func SupportedObjects

func SupportedObjects() []Object

type Page

type Page struct {
	ObjectType string
	Records    []Record
	NextAfter  *string
	HasMore    bool
}

type Property

type Property struct {
	Name           string `json:"name"`
	Label          string `json:"label"`
	Type           string `json:"type"`
	HasUniqueValue bool   `json:"has_unique_value,omitempty"`
	ReadOnlyValue  bool   `json:"read_only_value,omitempty"`
}

func ReadContactMetadata

func ReadContactMetadata(ctx context.Context, transport *http.Client, accessToken string, accountID, maxBytes int64) ([]Property, error)

ReadContactMetadata uses the caller's restricted HTTP client and fixed provider endpoint. Account identity is checked before reading properties.

type Record

type Record struct {
	ID         string
	Properties map[string]any
}

type SearchRequest

type SearchRequest struct {
	ObjectType       string
	Properties       []string
	Query            string
	Sorts            []string
	After            string
	Limit            int
	FilterGroups     []FilterGroup
	MaxResponseBytes int64
}

type UpsertInput

type UpsertInput struct {
	ID         string
	IDProperty string
	Properties map[string]any
}

type UpsertRecord

type UpsertRecord struct {
	ID      string
	Created bool
}

type UpsertRequest

type UpsertRequest struct {
	ObjectType       string
	Inputs           []UpsertInput
	MaxResponseBytes int64
}

type UpsertResult

type UpsertResult struct {
	Records []UpsertRecord
}

Jump to

Keyboard shortcuts

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