data

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package data provides services for Intercom custom data.

EventsService tracks custom events. AttributesService manages custom data attributes. ObjectsService handles custom object instances for extending the Intercom data model.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseCreateResult

func ParseCreateResult(r *api.Result) error

ParseCreateResult validates a Result for the Create endpoint (empty body).

func ParseCreateSummariesResult

func ParseCreateSummariesResult(r *api.Result) error

ParseCreateSummariesResult validates a Result for the CreateSummaries endpoint (empty body).

Types

type Attribute

type Attribute struct {
	Type              string   `json:"type"`
	ID                int      `json:"id,omitempty"`
	Model             string   `json:"model"`
	Name              string   `json:"name"`
	FullName          string   `json:"full_name,omitempty"`
	Label             string   `json:"label,omitempty"`
	Description       string   `json:"description,omitempty"`
	DataType          string   `json:"data_type,omitempty"`
	Options           []string `json:"options,omitempty"`
	APIWritable       bool     `json:"api_writable,omitempty"`
	UIWritable        bool     `json:"ui_writable,omitempty"`
	MessengerWritable bool     `json:"messenger_writable,omitempty"`
	Custom            bool     `json:"custom,omitempty"`
	Archived          bool     `json:"archived,omitempty"`
	CreatedAt         int64    `json:"created_at,omitempty"`
	UpdatedAt         int64    `json:"updated_at,omitempty"`
	AdminID           string   `json:"admin_id,omitempty"`
}

Attribute represents an Intercom data attribute.

func ParseAttributeCreateResult

func ParseAttributeCreateResult(r *api.Result) (*Attribute, error)

ParseAttributeCreateResult decodes a Result into an Attribute.

func ParseAttributeUpdateResult

func ParseAttributeUpdateResult(r *api.Result) (*Attribute, error)

ParseAttributeUpdateResult decodes a Result into an Attribute.

type AttributeList

type AttributeList struct {
	Type string      `json:"type"`
	Data []Attribute `json:"data"`
}

AttributeList represents a list of data attributes.

func ParseAttributeListResult

func ParseAttributeListResult(r *api.Result) (*AttributeList, error)

ParseAttributeListResult decodes a Result into an AttributeList.

type AttributeOption

type AttributeOption struct {
	Value string `json:"value"`
}

AttributeOption represents an option value for list-type data attributes.

type AttributesService

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

AttributesService handles communication with the data attribute related methods of the Intercom API.

func NewAttributesService

func NewAttributesService(c api.Caller) *AttributesService

NewAttributesService creates a new data attributes service.

func (*AttributesService) CreateRaw

CreateRaw creates a new data attribute with the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/data-attributes/createdataattribute

func (*AttributesService) List

List returns all data attributes for the workspace.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/data-attributes/listdataattributes

func (*AttributesService) ListRaw

ListRaw returns all data attributes for the workspace with the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/data-attributes/listdataattributes

func (*AttributesService) UpdateRaw

func (s *AttributesService) UpdateRaw(ctx context.Context, id int, body *UpdateAttributeRequest) (*api.Result, error)

UpdateRaw updates a data attribute by ID with the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/data-attributes/updatedataattribute

type CreateAttributeRequest

type CreateAttributeRequest struct {
	Name              string            `json:"name"`
	Model             string            `json:"model"`
	DataType          string            `json:"data_type"`
	Description       string            `json:"description,omitempty"`
	MessengerWritable *bool             `json:"messenger_writable,omitempty"`
	Options           []AttributeOption `json:"options,omitempty"`
}

CreateAttributeRequest represents the request body for creating a data attribute.

type CreateEventRequest

type CreateEventRequest struct {
	EventName string         `json:"event_name"`
	CreatedAt int64          `json:"created_at"`
	UserID    string         `json:"user_id,omitempty"`
	ID        string         `json:"id,omitempty"`
	Email     string         `json:"email,omitempty"`
	Metadata  map[string]any `json:"metadata,omitempty"`
}

CreateEventRequest represents the request body for creating a data event.

type CreateOrUpdateObjectRequest

type CreateOrUpdateObjectRequest struct {
	ExternalID        string         `json:"external_id,omitempty"`
	ExternalCreatedAt *int64         `json:"external_created_at,omitempty"`
	ExternalUpdatedAt *int64         `json:"external_updated_at,omitempty"`
	CustomAttributes  map[string]any `json:"custom_attributes,omitempty"`
}

CreateOrUpdateObjectRequest represents a request to create or update a custom object instance.

type CreateSummariesRequest

type CreateSummariesRequest struct {
	UserID         string         `json:"user_id"`
	EventSummaries []EventSummary `json:"event_summaries"`
}

CreateSummariesRequest represents the request body for creating event summaries.

type Event

type Event struct {
	Type           string         `json:"type,omitempty"`
	EventName      string         `json:"event_name"`
	CreatedAt      int64          `json:"created_at"`
	UserID         string         `json:"user_id,omitempty"`
	ID             string         `json:"id,omitempty"`
	IntercomUserID string         `json:"intercom_user_id,omitempty"`
	Email          string         `json:"email,omitempty"`
	Metadata       map[string]any `json:"metadata,omitempty"`
}

Event represents an Intercom data event.

type EventPages

type EventPages struct {
	Next  string `json:"next,omitempty"`
	Since string `json:"since,omitempty"`
}

EventPages represents pagination info for events.

type EventSummary

type EventSummary struct {
	EventName string `json:"event_name"`
	Count     int    `json:"count"`
	First     int64  `json:"first"`
	Last      int64  `json:"last"`
}

EventSummary represents a single event summary.

type EventsService

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

EventsService handles communication with the data event related methods of the Intercom API.

func NewEventsService

func NewEventsService(c api.Caller) *EventsService

NewEventsService creates a new data events service.

func (*EventsService) Create

func (s *EventsService) Create(ctx context.Context, body *CreateEventRequest) error

Create submits a new data event. Returns nil on success (API returns 202 with empty body).

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/data-events/createdataevent

func (*EventsService) CreateRaw

func (s *EventsService) CreateRaw(ctx context.Context, body *CreateEventRequest) (*api.Result, error)

CreateRaw submits a new data event and returns the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/data-events/createdataevent

func (*EventsService) CreateSummaries

func (s *EventsService) CreateSummaries(ctx context.Context, body *CreateSummariesRequest) error

CreateSummaries creates event summaries for a user.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/data-events/dataeventsummaries

func (*EventsService) CreateSummariesRaw

func (s *EventsService) CreateSummariesRaw(ctx context.Context, body *CreateSummariesRequest) (*api.Result, error)

CreateSummariesRaw creates event summaries for a user and returns the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/data-events/dataeventsummaries

func (*EventsService) List

List returns data events for a user or lead.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/data-events/listdataevents

func (*EventsService) ListRaw

func (s *EventsService) ListRaw(ctx context.Context, opts *ListOptions) (*api.Result, error)

ListRaw returns data events for a user or lead with the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/data-events/listdataevents

type ListAttributesOptions

type ListAttributesOptions struct {
	Model           string `url:"model,omitempty"`
	IncludeArchived *bool  `url:"include_archived,omitempty"`
}

ListAttributesOptions specifies optional parameters to the List method.

type ListOptions

type ListOptions struct {
	Type           string `url:"type"`
	UserID         string `url:"user_id,omitempty"`
	Email          string `url:"email,omitempty"`
	IntercomUserID string `url:"intercom_user_id,omitempty"`
	Summary        *bool  `url:"summary,omitempty"`
	PerPage        int    `url:"per_page,omitempty"`
}

ListOptions specifies parameters to the List method.

type ObjectInstance

type ObjectInstance struct {
	ID                string         `json:"id"`
	ExternalID        string         `json:"external_id,omitempty"`
	Type              string         `json:"type,omitempty"`
	ExternalCreatedAt *int64         `json:"external_created_at,omitempty"`
	ExternalUpdatedAt *int64         `json:"external_updated_at,omitempty"`
	CreatedAt         int64          `json:"created_at,omitempty"`
	UpdatedAt         int64          `json:"updated_at,omitempty"`
	CustomAttributes  map[string]any `json:"custom_attributes,omitempty"`
}

ObjectInstance represents an Intercom custom object instance.

func ParseObjectCreateOrUpdateResult

func ParseObjectCreateOrUpdateResult(r *api.Result) (*ObjectInstance, error)

ParseObjectCreateOrUpdateResult decodes a Result into an ObjectInstance.

func ParseObjectGetByExternalIDResult

func ParseObjectGetByExternalIDResult(r *api.Result) (*ObjectInstance, error)

ParseObjectGetByExternalIDResult decodes a Result into an ObjectInstance.

func ParseObjectGetResult

func ParseObjectGetResult(r *api.Result) (*ObjectInstance, error)

ParseObjectGetResult decodes a Result into an ObjectInstance.

type ObjectInstanceDeleted

type ObjectInstanceDeleted struct {
	ID      string `json:"id"`
	Object  string `json:"object"`
	Deleted bool   `json:"deleted"`
}

ObjectInstanceDeleted represents the response from deleting a custom object instance.

func ParseObjectDeleteByExternalIDResult

func ParseObjectDeleteByExternalIDResult(r *api.Result) (*ObjectInstanceDeleted, error)

ParseObjectDeleteByExternalIDResult decodes a Result into an ObjectInstanceDeleted.

func ParseObjectDeleteResult

func ParseObjectDeleteResult(r *api.Result) (*ObjectInstanceDeleted, error)

ParseObjectDeleteResult decodes a Result into an ObjectInstanceDeleted.

type ObjectsService

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

ObjectsService handles communication with the custom object instance related methods of the Intercom API.

func NewObjectsService

func NewObjectsService(c api.Caller) *ObjectsService

NewObjectsService creates a new custom objects service.

func (*ObjectsService) CreateOrUpdate

func (s *ObjectsService) CreateOrUpdate(ctx context.Context, typeIdentifier string, body *CreateOrUpdateObjectRequest) (*ObjectInstance, error)

CreateOrUpdate creates or updates a custom object instance (upsert by external_id).

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/custom-object-instances/createcustomobjectinstances

func (*ObjectsService) CreateOrUpdateRaw

func (s *ObjectsService) CreateOrUpdateRaw(ctx context.Context, typeIdentifier string, body *CreateOrUpdateObjectRequest) (*api.Result, error)

CreateOrUpdateRaw creates or updates a custom object instance with the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/custom-object-instances/createcustomobjectinstances

func (*ObjectsService) Delete

func (s *ObjectsService) Delete(ctx context.Context, typeIdentifier, instanceID string) (*ObjectInstanceDeleted, error)

Delete deletes a custom object instance by type identifier and instance ID.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/custom-object-instances/deletecustomobjectinstancesbyid

func (*ObjectsService) DeleteByExternalID

func (s *ObjectsService) DeleteByExternalID(ctx context.Context, typeIdentifier, externalID string) (*ObjectInstanceDeleted, error)

DeleteByExternalID deletes a custom object instance by type identifier and external ID.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/custom-object-instances/deletecustomobjectinstancesbyexternalid

func (*ObjectsService) DeleteByExternalIDRaw

func (s *ObjectsService) DeleteByExternalIDRaw(ctx context.Context, typeIdentifier, externalID string) (*api.Result, error)

DeleteByExternalIDRaw deletes a custom object instance by type identifier and external ID with the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/custom-object-instances/deletecustomobjectinstancesbyexternalid

func (*ObjectsService) DeleteRaw

func (s *ObjectsService) DeleteRaw(ctx context.Context, typeIdentifier, instanceID string) (*api.Result, error)

DeleteRaw deletes a custom object instance by type identifier and instance ID with the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/custom-object-instances/deletecustomobjectinstancesbyid

func (*ObjectsService) Get

func (s *ObjectsService) Get(ctx context.Context, typeIdentifier, instanceID string) (*ObjectInstance, error)

Get retrieves a custom object instance by type identifier and instance ID.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/custom-object-instances/getcustomobjectinstancesbyid

func (*ObjectsService) GetByExternalID

func (s *ObjectsService) GetByExternalID(ctx context.Context, typeIdentifier, externalID string) (*ObjectInstance, error)

GetByExternalID retrieves a custom object instance by type identifier and external ID.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/custom-object-instances/getcustomobjectinstancesbyexternalid

func (*ObjectsService) GetByExternalIDRaw

func (s *ObjectsService) GetByExternalIDRaw(ctx context.Context, typeIdentifier, externalID string) (*api.Result, error)

GetByExternalIDRaw retrieves a custom object instance by type identifier and external ID with the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/custom-object-instances/getcustomobjectinstancesbyexternalid

func (*ObjectsService) GetRaw

func (s *ObjectsService) GetRaw(ctx context.Context, typeIdentifier, instanceID string) (*api.Result, error)

GetRaw retrieves a custom object instance by type identifier and instance ID with the full HTTP result.

See: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/custom-object-instances/getcustomobjectinstancesbyid

type SummaryResponse

type SummaryResponse struct {
	Type           string      `json:"type"`
	Events         []Event     `json:"events"`
	Pages          *EventPages `json:"pages,omitempty"`
	Email          string      `json:"email,omitempty"`
	IntercomUserID string      `json:"intercom_user_id,omitempty"`
	UserID         string      `json:"user_id,omitempty"`
}

SummaryResponse represents the response from the list events endpoint.

func ParseListResult

func ParseListResult(r *api.Result) (*SummaryResponse, error)

ParseListResult decodes a Result into a SummaryResponse.

type UpdateAttributeRequest

type UpdateAttributeRequest struct {
	Description       string            `json:"description,omitempty"`
	Archived          *bool             `json:"archived,omitempty"`
	MessengerWritable *bool             `json:"messenger_writable,omitempty"`
	Options           []AttributeOption `json:"options,omitempty"`
}

UpdateAttributeRequest represents the request body for updating a data attribute.

Jump to

Keyboard shortcuts

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