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 ¶
- func ParseCreateResult(r *api.Result) error
- func ParseCreateSummariesResult(r *api.Result) error
- type Attribute
- type AttributeList
- type AttributeOption
- type AttributesService
- func (s *AttributesService) Create(ctx context.Context, body *CreateAttributeRequest) (*Attribute, error)
- func (s *AttributesService) CreateRaw(ctx context.Context, body *CreateAttributeRequest) (*api.Result, error)
- func (s *AttributesService) List(ctx context.Context, opts *ListAttributesOptions) (*AttributeList, error)
- func (s *AttributesService) ListRaw(ctx context.Context, opts *ListAttributesOptions) (*api.Result, error)
- func (s *AttributesService) Update(ctx context.Context, id int, body *UpdateAttributeRequest) (*Attribute, error)
- func (s *AttributesService) UpdateRaw(ctx context.Context, id int, body *UpdateAttributeRequest) (*api.Result, error)
- type CreateAttributeRequest
- type CreateEventRequest
- type CreateOrUpdateObjectRequest
- type CreateSummariesRequest
- type Event
- type EventPages
- type EventSummary
- type EventsService
- func (s *EventsService) Create(ctx context.Context, body *CreateEventRequest) error
- func (s *EventsService) CreateRaw(ctx context.Context, body *CreateEventRequest) (*api.Result, error)
- func (s *EventsService) CreateSummaries(ctx context.Context, body *CreateSummariesRequest) error
- func (s *EventsService) CreateSummariesRaw(ctx context.Context, body *CreateSummariesRequest) (*api.Result, error)
- func (s *EventsService) List(ctx context.Context, opts *ListOptions) (*SummaryResponse, error)
- func (s *EventsService) ListRaw(ctx context.Context, opts *ListOptions) (*api.Result, error)
- type ListAttributesOptions
- type ListOptions
- type ObjectInstance
- type ObjectInstanceDeleted
- type ObjectsService
- func (s *ObjectsService) CreateOrUpdate(ctx context.Context, typeIdentifier string, body *CreateOrUpdateObjectRequest) (*ObjectInstance, error)
- func (s *ObjectsService) CreateOrUpdateRaw(ctx context.Context, typeIdentifier string, body *CreateOrUpdateObjectRequest) (*api.Result, error)
- func (s *ObjectsService) Delete(ctx context.Context, typeIdentifier, instanceID string) (*ObjectInstanceDeleted, error)
- func (s *ObjectsService) DeleteByExternalID(ctx context.Context, typeIdentifier, externalID string) (*ObjectInstanceDeleted, error)
- func (s *ObjectsService) DeleteByExternalIDRaw(ctx context.Context, typeIdentifier, externalID string) (*api.Result, error)
- func (s *ObjectsService) DeleteRaw(ctx context.Context, typeIdentifier, instanceID string) (*api.Result, error)
- func (s *ObjectsService) Get(ctx context.Context, typeIdentifier, instanceID string) (*ObjectInstance, error)
- func (s *ObjectsService) GetByExternalID(ctx context.Context, typeIdentifier, externalID string) (*ObjectInstance, error)
- func (s *ObjectsService) GetByExternalIDRaw(ctx context.Context, typeIdentifier, externalID string) (*api.Result, error)
- func (s *ObjectsService) GetRaw(ctx context.Context, typeIdentifier, instanceID string) (*api.Result, error)
- type SummaryResponse
- type UpdateAttributeRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseCreateResult ¶
ParseCreateResult validates a Result for the Create endpoint (empty body).
func ParseCreateSummariesResult ¶
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 ¶
ParseAttributeCreateResult decodes a Result into an Attribute.
type AttributeList ¶
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) Create ¶
func (s *AttributesService) Create(ctx context.Context, body *CreateAttributeRequest) (*Attribute, error)
Create creates a new data attribute.
func (*AttributesService) CreateRaw ¶
func (s *AttributesService) CreateRaw(ctx context.Context, body *CreateAttributeRequest) (*api.Result, error)
CreateRaw creates a new data attribute with the full HTTP result.
func (*AttributesService) List ¶
func (s *AttributesService) List(ctx context.Context, opts *ListAttributesOptions) (*AttributeList, error)
List returns all data attributes for the workspace.
func (*AttributesService) ListRaw ¶
func (s *AttributesService) ListRaw(ctx context.Context, opts *ListAttributesOptions) (*api.Result, error)
ListRaw returns all data attributes for the workspace with the full HTTP result.
func (*AttributesService) Update ¶
func (s *AttributesService) Update(ctx context.Context, id int, body *UpdateAttributeRequest) (*Attribute, error)
Update updates a data attribute by ID.
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.
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.
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.
func (*EventsService) List ¶
func (s *EventsService) List(ctx context.Context, opts *ListOptions) (*SummaryResponse, error)
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).
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.
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.
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.
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.
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.
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.
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.
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.
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.