Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
Client *common.JSONHTTPClient
// contains filtered or unexported fields
}
Adapter handles batched record operations (create/update) against HubSpot's REST API. It abstracts API endpoint construction, versioning, and JSON response processing specific to the HubSpot Batch feature.
func NewAdapter ¶
func NewAdapter(hubspotCRMClient *common.HTTPClient, moduleInfo *providers.ModuleInfo) *Adapter
NewAdapter creates a new batch Adapter configured to work with Hubspot's APIs.
func (*Adapter) BatchWrite ¶
func (a *Adapter) BatchWrite(ctx context.Context, params *common.BatchWriteParam) (*common.BatchWriteResult, error)
BatchWrite performs a HubSpot batch create or update request.
The request body always includes an "inputs" array of record payloads, and the response contains a "results" array aligned by index.
HubSpot may return 400 (Bad Request) or 409 (Conflict) when record-level validation fails — these are treated as soft issues (non-fatal responses) and are parsed into a structured BatchWriteResult rather than raised as errors.
AllOrNone Policy ¶
For batch creates, the allOrNone policy is controlled via objectWriteTraceId:
- When allOrNone is false (default), objectWriteTraceId is included to enable partial success.
- When allOrNone is true, objectWriteTraceId is omitted, causing HubSpot to fail the entire batch if any record fails.
Reference: https://developers.hubspot.com/docs/api-reference/error-handling
For batch updates, HubSpot always allows partial success and does not support allOrNone behavior. The API returns 200 for full success or 207 Multi-Status when some records fail. This is a HubSpot API limitation.
Reference: https://developers.hubspot.com/changelog/simplifying-batch-update-response-codes-for-crm-v3-apis
type Issue ¶
type Issue any
Issue represents a single HubSpot error entry. Its structure varies by error type, but typically includes "message" and "context" fields.
type IssueResponse ¶
type IssueResponse struct {
Status string `json:"status,omitempty"`
Message string `json:"message,omitempty"`
CorrelationId string `json:"correlationId,omitempty"`
Errors []Issue `json:"errors,omitempty"`
Category string `json:"category,omitempty"`
}
IssueResponse models HubSpot's structured error response for 4xx cases.
type Payload ¶
type Payload struct {
Items []PayloadItem `json:"inputs"`
}
Payload represents the HubSpot batch request body.
type PayloadItem ¶
type PayloadItem struct {
ID string `json:"id,omitempty"`
Properties common.Record `json:"properties"`
Associations any `json:"associations,omitempty"`
ObjectWriteTraceId string `json:"objectWriteTraceId,omitempty"` //nolint:tagliatelle
}
PayloadItem represents a single item in the API payload. Hubspot's payload is identical to what client supplies to the connector. This is an alias.
func NewPayloadItem ¶
func NewPayloadItem(record common.Record, associations any) (*PayloadItem, error)
type Response ¶
type Response struct {
CompletedAt time.Time `json:"completedAt"`
Status string `json:"status"`
StartedAt time.Time `json:"startedAt"`
Results []ResponseItem `json:"results"`
Errors []Issue `json:"errors"`
}
Response models a HubSpot batch success response.
func (Response) GetItemsMap ¶
func (r Response) GetItemsMap() map[string]*ResponseItem
type ResponseItem ¶
type ResponseItem struct {
ID string `json:"id"`
Properties any `json:"properties"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Archived bool `json:"archived"`
URL string `json:"url"`
}
func (ResponseItem) ToWriteResult ¶
func (i ResponseItem) ToWriteResult() (*common.WriteResult, error)