Documentation
¶
Overview ¶
Package intercom-go provides a thin client for the Intercom API: http://developers.intercom.com/reference.
The first step to using Intercom's Go client is to create a client object, using your Access Token from your [settings](http://app.intercom.io/apps/api_keys).
import (
"github.com/karnott/intercom-go/v2"
)
ic := intercom.NewClient("myAccessToken")
The client can be configured with different options by calls to Option:
ic.Option(intercom.TraceHTTP(true)) // turn http tracing on
ic.Option(intercom.BaseURI("http://intercom.dev")) // change the base uri used, useful for testing
ic.Option(intercom.SetHTTPClient(myHTTPClient)) // set a new HTTP client
Errors ¶
Errors may be returned from some calls. Errors returned from the API will implement `intercom.IntercomError` and can be checked:
_, err := ic.Contacts.FindByEmail("doesnotexist@intercom.io")
if herr, ok := err.(intercom.IntercomError); ok && herr.GetCode() == "not_found" {
fmt.Print(herr)
}
HTTP Client ¶
The HTTP Client used by this package can be swapped out for one of your choosing, with your own configuration, it just needs to implement the HTTPClient interface:
type HTTPClient interface {
Get(string, interface{}) ([]byte, error)
Post(string, interface{}) ([]byte, error)
Patch(string, interface{}) ([]byte, error)
Delete(string, interface{}) ([]byte, error)
}
The client will probably need to work with `accessToken` and `baseURI` values. See the provided client for an example. Then create an Intercom Client and inject the HTTPClient:
ic := intercom.Client{}
ic.Option(intercom.SetHTTPClient(myHTTPClient))
// ready to go!
On Bools ¶
Due to the way Go represents the zero value for a bool, it's necessary to pass pointers to bool instead in some places. The helper `intercom.Bool(true)` creates these for you.
Pagination ¶
For many resources, pagination should be applied through the use of a PageParams object passed into List() functions.
pageParams := PageParams{
Page: 2,
PerPage: 10,
}
ic.Contacts.List(pageParams)
Index ¶
- func BaseURI(baseURI string) option
- func Bool(value bool) *bool
- func SetHTTPClient(httpClient interfaces.HTTPClient) option
- func TraceHTTP(trace bool) option
- type Admin
- type AdminAPI
- type AdminAvatar
- type AdminList
- type AdminRepository
- type AdminService
- type Article
- type ArticleAPI
- type ArticleList
- type ArticleRepository
- type ArticleService
- type ArticleStatistics
- type Client
- type Collection
- type CollectionAPI
- type CollectionList
- type CollectionRepository
- type CollectionService
- type Company
- type CompanyAPI
- type CompanyIdentifiers
- type CompanyList
- type CompanyRepository
- type CompanyService
- func (c *CompanyService) FindByCompanyID(companyID string) (Company, error)
- func (c *CompanyService) FindByID(id string) (Company, error)
- func (c *CompanyService) FindByName(name string) (Company, error)
- func (c *CompanyService) List(params PageParams) (CompanyList, error)
- func (c *CompanyService) ListBySegment(segmentID string, params PageParams) (CompanyList, error)
- func (c *CompanyService) ListByTag(tagID string, params PageParams) (CompanyList, error)
- func (c *CompanyService) ListContactsByCompanyID(companyID string, params PageParams) (ContactList, error)
- func (c *CompanyService) ListContactsByID(id string, params PageParams) (ContactList, error)
- func (c *CompanyService) Save(user *Company) (Company, error)
- type Contact
- type ContactAPI
- type ContactAvatar
- type ContactCompany
- type ContactIdentifiers
- type ContactList
- type ContactLocation
- type ContactRepository
- type ContactService
- func (c *ContactService) Archive(id string) (Contact, error)
- func (c *ContactService) Create(contact *Contact) (Contact, error)
- func (c *ContactService) Delete(id string) (Contact, error)
- func (c *ContactService) FindByExternalID(externalID string) (Contact, error)
- func (c *ContactService) FindByID(id string) (Contact, error)
- func (c *ContactService) List(params PageParams) (ContactList, error)
- func (c *ContactService) ListByEmail(email string, params PageParams) (ContactList, error)
- func (c *ContactService) Merge(sourceID, targetID string) (Contact, error)
- func (c *ContactService) Unarchive(id string) (Contact, error)
- func (c *ContactService) Update(contact *Contact) (Contact, error)
- type Conversation
- type ConversationAPI
- type ConversationList
- type ConversationListParams
- type ConversationListState
- type ConversationMessage
- type ConversationPart
- type ConversationPartList
- type ConversationRepository
- type ConversationService
- func (c *ConversationService) Assign(id string, assigner, assignee *Admin) (Conversation, error)
- func (c *ConversationService) Close(id string, closer *Admin) (Conversation, error)
- func (c *ConversationService) Find(id string) (Conversation, error)
- func (c *ConversationService) ListAll(pageParams PageParams) (ConversationList, error)
- func (c *ConversationService) ListByAdmin(admin *Admin, state ConversationListState, pageParams PageParams) (ConversationList, error)
- func (c *ConversationService) ListByContact(contact *Contact, state ConversationListState, pageParams PageParams) (ConversationList, error)
- func (c *ConversationService) MarkRead(id string) (Conversation, error)
- func (c *ConversationService) Open(id string, opener *Admin) (Conversation, error)
- func (c *ConversationService) Reply(id string, author MessagePerson, replyType ReplyType, body string) (Conversation, error)
- func (c *ConversationService) ReplyWithAttachmentURLs(id string, author MessagePerson, replyType ReplyType, body string, ...) (Conversation, error)
- type CursorPages
- type Data
- type Event
- type EventAPI
- type EventRepository
- type EventService
- type IntercomError
- type JobAPI
- type JobData
- type JobItem
- type JobItemMethod
- type JobRepository
- type JobRequest
- type JobResponse
- type JobService
- func (js *JobService) AppendEvents(id string, items ...*JobItem) (JobResponse, error)
- func (js *JobService) AppendUsers(id string, items ...*JobItem) (JobResponse, error)
- func (js *JobService) Find(id string) (JobResponse, error)
- func (js *JobService) NewEventJob(items ...*JobItem) (JobResponse, error)
- func (js *JobService) NewUserJob(items ...*JobItem) (JobResponse, error)
- type JobState
- type MessageAPI
- type MessageAddress
- type MessagePerson
- type MessageRepository
- type MessageRequest
- type MessageResponse
- type MessageService
- type MessageTemplate
- type Notification
- type PageParams
- type Plan
- type Reply
- type ReplyType
- type Segment
- type SegmentAPI
- type SegmentList
- type SegmentRepository
- type SegmentService
- type SocialProfile
- type SocialProfileList
- type StartingAfterParam
- type Tag
- type TagAPI
- type TagList
- type TagRepository
- type TagService
- type Tagging
- type TaggingList
- type UserCompany
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BaseURI ¶
func BaseURI(baseURI string) option
BaseURI sets a base URI for the HTTP Client to use. Defaults to "https://api.intercom.io". Typically this would be used during testing to point to a stubbed service.
func Bool ¶
Bool is a helper method to create *bool. *bool is preferred to bool because it allows distinction between false and absence.
func SetHTTPClient ¶
func SetHTTPClient(httpClient interfaces.HTTPClient) option
SetHTTPClient sets a HTTPClient for the Intercom Client to use. Useful for customising timeout behaviour etc.
Types ¶
type Admin ¶
type Admin struct {
ID json.Number `json:"id"`
Type string `json:"type"`
Name string `json:"name"`
Email string `json:"email"`
Avatar *AdminAvatar `json:"avatar,omitempty"`
TeamPriorityLevel map[string]interface{} `json:"team_priority_level,omitempty"`
}
Admin represents an Admin in Intercom.
func (Admin) IsNobodyAdmin ¶
IsNobodyAdmin is a helper function to determine if the Admin is 'Nobody'.
func (Admin) MessageAddress ¶
func (a Admin) MessageAddress() MessageAddress
MessageAddress gets the address for a Contact in order to message them
type AdminAPI ¶
type AdminAPI struct {
// contains filtered or unexported fields
}
AdminAPI implements AdminRepository
type AdminAvatar ¶
type AdminAvatar struct {
ImageURL string `json:"image_url,omitempty"`
}
AdminAvatar represents an admin's avatar.
type AdminList ¶
type AdminList struct {
Admins []Admin
}
AdminList represents an object holding list of Admins
type AdminRepository ¶
type AdminRepository interface {
// contains filtered or unexported methods
}
AdminRepository defines the interface for working with Admins through the API.
type AdminService ¶
type AdminService struct {
Repository AdminRepository
}
AdminService handles interactions with the API through an AdminRepository.
func (*AdminService) List ¶
func (c *AdminService) List() (AdminList, error)
List lists the Admins associated with your App.
type Article ¶
type Article struct {
ID string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
WorkspaceID string `json:"workspace_id,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Body string `json:"body,omitempty"`
AuthorID int64 `json:"author_id,omitempty"`
State string `json:"state,omitempty"`
CreatedAt int64 `json:"created_at,omitempty"`
UpdatedAt int64 `json:"updated_at,omitempty"`
URL string `json:"url,omitempty"`
ParentID int64 `json:"parent_id,omitempty"`
ParentType string `json:"parent_type,omitempty"`
ParentIDs []int64 `json:"parent_ids,omitempty"`
Statistics ArticleStatistics `json:"statistics,omitempty"`
}
Article represents a Help Center Article in Intercom.
type ArticleAPI ¶
type ArticleAPI struct {
// contains filtered or unexported fields
}
ArticleAPI implements ArticleRepository
type ArticleList ¶
type ArticleList struct {
Pages PageParams `json:"pages,omitempty"`
TotalCount int64 `json:"total_count,omitempty"`
Articles []Article `json:"data,omitempty"`
}
ArticleList holds a list of Articles and pagination info.
type ArticleRepository ¶
type ArticleRepository interface {
// contains filtered or unexported methods
}
ArticleRepository defines the interface for working with Articles through the API.
type ArticleService ¶
type ArticleService struct {
Repository ArticleRepository
}
ArticleService handles interactions with the API through an ArticleRepository.
func (*ArticleService) Find ¶
func (s *ArticleService) Find(id string) (Article, error)
Find a particular Article by ID.
func (*ArticleService) List ¶
func (s *ArticleService) List(params PageParams) (ArticleList, error)
List all Articles for the App.
type ArticleStatistics ¶
type ArticleStatistics struct {
Views int64 `json:"views,omitempty"`
Conversations int64 `json:"conversations,omitempty"`
Reactions int64 `json:"reactions,omitempty"`
HappyReactionPercentage float64 `json:"happy_reaction_percentage,omitempty"`
NeutralReactionPercentage float64 `json:"neutral_reaction_percentage,omitempty"`
SadReactionPercentage float64 `json:"sad_reaction_percentage,omitempty"`
}
ArticleStatistics holds metrics for an Article.
type Client ¶
type Client struct {
// Services for interacting with various resources in Intercom.
Admins AdminService
Articles ArticleService
Collections CollectionService
Companies CompanyService
Contacts ContactService
Conversations ConversationService
Events EventService
Jobs JobService
Messages MessageService
Segments SegmentService
Tags TagService
// Mappings for resources to API constructs
AdminRepository AdminRepository
ArticleRepository ArticleRepository
CollectionRepository CollectionRepository
CompanyRepository CompanyRepository
ContactRepository ContactRepository
ConversationRepository ConversationRepository
EventRepository EventRepository
JobRepository JobRepository
MessageRepository MessageRepository
SegmentRepository SegmentRepository
TagRepository TagRepository
// AccessToken for Intercom's API (Bearer token).
AccessToken string
// HTTP Client used to interact with the API.
HTTPClient interfaces.HTTPClient
// contains filtered or unexported fields
}
A Client manages interacting with the Intercom API.
func NewClient ¶
NewClient returns a new Intercom API client, configured with the default HTTPClient.
func NewClientWithHTTPClient ¶
func NewClientWithHTTPClient(accessToken string, httpClient interfaces.HTTPClient) *Client
NewClientWithHTTPClient returns a new Intercom API client, configured with the supplied HTTPClient interface.
type Collection ¶
type Collection struct {
ID string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
WorkspaceID string `json:"workspace_id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
CreatedAt int64 `json:"created_at,omitempty"`
UpdatedAt int64 `json:"updated_at,omitempty"`
URL string `json:"url,omitempty"`
Icon string `json:"icon,omitempty"`
Order int64 `json:"order,omitempty"`
ParentID *string `json:"parent_id"`
}
Collection represents a Help Center Collection in Intercom.
func (Collection) String ¶
func (c Collection) String() string
type CollectionAPI ¶
type CollectionAPI struct {
// contains filtered or unexported fields
}
CollectionAPI implements CollectionRepository
type CollectionList ¶
type CollectionList struct {
Pages PageParams `json:"pages,omitempty"`
TotalCount int64 `json:"total_count,omitempty"`
Collections []Collection `json:"data,omitempty"`
}
CollectionList holds a list of Collections and pagination info.
type CollectionRepository ¶
type CollectionRepository interface {
// contains filtered or unexported methods
}
CollectionRepository defines the interface for working with Collections through the API.
type CollectionService ¶
type CollectionService struct {
Repository CollectionRepository
}
CollectionService handles interactions with the API through a CollectionRepository.
func (*CollectionService) Find ¶
func (s *CollectionService) Find(id string) (Collection, error)
Find a particular Collection by ID.
func (*CollectionService) List ¶
func (s *CollectionService) List(params PageParams) (CollectionList, error)
List all Collections for the App.
type Company ¶
type Company struct {
ID string `json:"id,omitempty"`
CompanyID string `json:"company_id,omitempty"`
Name string `json:"name,omitempty"`
RemoteCreatedAt int64 `json:"remote_created_at,omitempty"`
LastRequestAt int64 `json:"last_request_at,omitempty"`
CreatedAt int64 `json:"created_at,omitempty"`
UpdatedAt int64 `json:"updated_at,omitempty"`
SessionCount int64 `json:"session_count,omitempty"`
MonthlySpend int64 `json:"monthly_spend"`
UserCount int64 `json:"user_count,omitempty"`
Size int64 `json:"size,omitempty"`
Website string `json:"website,omitempty"`
Industry string `json:"industry,omitempty"`
Tags *TagList `json:"tags,omitempty"`
Segments *SegmentList `json:"segments,omitempty"`
Plan *Plan `json:"plan,omitempty"`
CustomAttributes map[string]interface{} `json:"custom_attributes,omitempty"`
Remove *bool `json:"-"`
}
Company represents a Company in Intercom Not all of the fields are writeable to the API, non-writeable fields are stripped out from the request. Please see the API documentation for details.
type CompanyAPI ¶
type CompanyAPI struct {
// contains filtered or unexported fields
}
CompanyAPI implements CompanyRepository
type CompanyIdentifiers ¶
type CompanyIdentifiers struct {
ID string `url:"-"`
CompanyID string `url:"company_id,omitempty"`
Name string `url:"name,omitempty"`
}
CompanyIdentifiers to identify a Company using the API
type CompanyList ¶
type CompanyList struct {
Pages PageParams
Companies []Company
}
CompanyList holds a list of Companies and paging information
type CompanyRepository ¶
type CompanyRepository interface {
// contains filtered or unexported methods
}
CompanyRepository defines the interface for working with Companies through the API.
type CompanyService ¶
type CompanyService struct {
Repository CompanyRepository
}
CompanyService handles interactions with the API through a CompanyRepository.
func (*CompanyService) FindByCompanyID ¶
func (c *CompanyService) FindByCompanyID(companyID string) (Company, error)
FindByCompanyID finds a Company using their CompanyID CompanyID is a customer-defined field
func (*CompanyService) FindByID ¶
func (c *CompanyService) FindByID(id string) (Company, error)
FindByID finds a Company using their Intercom ID
func (*CompanyService) FindByName ¶
func (c *CompanyService) FindByName(name string) (Company, error)
FindByName finds a Company using their Name
func (*CompanyService) List ¶
func (c *CompanyService) List(params PageParams) (CompanyList, error)
List Companies
func (*CompanyService) ListBySegment ¶
func (c *CompanyService) ListBySegment(segmentID string, params PageParams) (CompanyList, error)
List Companies by Segment
func (*CompanyService) ListByTag ¶
func (c *CompanyService) ListByTag(tagID string, params PageParams) (CompanyList, error)
List Companies by Tag
func (*CompanyService) ListContactsByCompanyID ¶
func (c *CompanyService) ListContactsByCompanyID(companyID string, params PageParams) (ContactList, error)
List Company Contacts by CompanyID
func (*CompanyService) ListContactsByID ¶
func (c *CompanyService) ListContactsByID(id string, params PageParams) (ContactList, error)
List Company Contacts by ID
type Contact ¶
type Contact struct {
ID string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
ExternalID string `json:"external_id,omitempty"`
Role string `json:"role,omitempty"`
Email string `json:"email,omitempty"`
EmailDomain string `json:"email_domain,omitempty"`
Phone string `json:"phone,omitempty"`
FormattedPhone string `json:"formatted_phone,omitempty"`
Name string `json:"name,omitempty"`
WorkspaceID string `json:"workspace_id,omitempty"`
Avatar *ContactAvatar `json:"avatar,omitempty"`
OwnerID int64 `json:"owner_id,omitempty"`
SocialProfiles *SocialProfileList `json:"social_profiles,omitempty"`
HasHardBounced bool `json:"has_hard_bounced,omitempty"`
MarkedEmailAsSpam bool `json:"marked_email_as_spam,omitempty"`
UnsubscribedFromEmails *bool `json:"unsubscribed_from_emails,omitempty"`
CreatedAt int64 `json:"created_at,omitempty"`
UpdatedAt int64 `json:"updated_at,omitempty"`
SignedUpAt int64 `json:"signed_up_at,omitempty"`
LastSeenAt int64 `json:"last_seen_at,omitempty"`
LastRepliedAt int64 `json:"last_replied_at,omitempty"`
LastContactedAt int64 `json:"last_contacted_at,omitempty"`
LastEmailOpenedAt int64 `json:"last_email_opened_at,omitempty"`
LastEmailClickedAt int64 `json:"last_email_clicked_at,omitempty"`
LanguageOverride string `json:"language_override,omitempty"`
Browser string `json:"browser,omitempty"`
BrowserVersion string `json:"browser_version,omitempty"`
BrowserLanguage string `json:"browser_language,omitempty"`
OS string `json:"os,omitempty"`
Tags *TagList `json:"tags,omitempty"`
Segments *SegmentList `json:"segments,omitempty"`
Companies *CompanyList `json:"companies,omitempty"`
Location *ContactLocation `json:"location,omitempty"`
Referrer string `json:"referrer,omitempty"`
UTMCampaign string `json:"utm_campaign,omitempty"`
UTMContent string `json:"utm_content,omitempty"`
UTMMedium string `json:"utm_medium,omitempty"`
UTMSource string `json:"utm_source,omitempty"`
UTMTerm string `json:"utm_term,omitempty"`
EnabledPushMessaging *bool `json:"enabled_push_messaging,omitempty"`
CustomAttributes map[string]interface{} `json:"custom_attributes,omitempty"`
}
Contact represents a Contact (user or lead) within Intercom. Not all of the fields are writeable to the API, non-writeable fields are stripped out from the request. Please see the API documentation for details.
func (Contact) MessageAddress ¶
func (c Contact) MessageAddress() MessageAddress
MessageAddress gets the address for a Contact in order to message them.
type ContactAPI ¶
type ContactAPI struct {
// contains filtered or unexported fields
}
ContactAPI implements ContactRepository
type ContactAvatar ¶
type ContactAvatar struct {
Type string `json:"type,omitempty"`
ImageURL string `json:"image_url,omitempty"`
}
ContactAvatar represents a contact's avatar.
type ContactCompany ¶
type ContactCompany struct {
CompanyID string `json:"company_id,omitempty"`
Name string `json:"name,omitempty"`
Remove *bool `json:"remove,omitempty"`
}
A ContactCompany represents a Company association for a Contact.
func MakeContactCompaniesFromCompanies ¶
func MakeContactCompaniesFromCompanies(companies []Company) []ContactCompany
MakeContactCompaniesFromCompanies converts a slice of Companies to ContactCompanies.
func MakeUserCompaniesFromCompanies ¶
func MakeUserCompaniesFromCompanies(companies []Company) []ContactCompany
MakeUserCompaniesFromCompanies is an alias for MakeContactCompaniesFromCompanies for backwards compatibility.
type ContactIdentifiers ¶
type ContactIdentifiers struct {
ID string `url:"-"`
ExternalID string `url:"external_id,omitempty"`
}
ContactIdentifiers hold identifiers for finding a Contact.
type ContactList ¶
type ContactList struct {
Pages CursorPages `json:"pages"`
TotalCount int64 `json:"total_count,omitempty"`
Contacts []Contact `json:"data,omitempty"`
}
ContactList holds a list of Contacts and cursor-based pagination info.
type ContactLocation ¶
type ContactLocation struct {
Type string `json:"type,omitempty"`
Country string `json:"country,omitempty"`
Region string `json:"region,omitempty"`
City string `json:"city,omitempty"`
CountryCode string `json:"country_code,omitempty"`
ContinentCode string `json:"continent_code,omitempty"`
}
ContactLocation holds location data for a contact.
type ContactRepository ¶
type ContactRepository interface {
// contains filtered or unexported methods
}
ContactRepository defines the interface for working with Contacts through the API.
type ContactService ¶
type ContactService struct {
Repository ContactRepository
}
ContactService handles interactions with the API through a ContactRepository.
func (*ContactService) Archive ¶
func (c *ContactService) Archive(id string) (Contact, error)
Archive a Contact.
func (*ContactService) Create ¶
func (c *ContactService) Create(contact *Contact) (Contact, error)
Create Contact.
func (*ContactService) Delete ¶
func (c *ContactService) Delete(id string) (Contact, error)
Delete Contact permanently.
func (*ContactService) FindByExternalID ¶
func (c *ContactService) FindByExternalID(externalID string) (Contact, error)
FindByExternalID looks up a Contact by their external ID.
func (*ContactService) FindByID ¶
func (c *ContactService) FindByID(id string) (Contact, error)
FindByID looks up a Contact by their Intercom ID.
func (*ContactService) List ¶
func (c *ContactService) List(params PageParams) (ContactList, error)
List all Contacts for App.
func (*ContactService) ListByEmail ¶
func (c *ContactService) ListByEmail(email string, params PageParams) (ContactList, error)
ListByEmail looks up a list of Contacts by their Email.
func (*ContactService) Merge ¶
func (c *ContactService) Merge(sourceID, targetID string) (Contact, error)
Merge two Contacts. The source contact is merged into the target.
type Conversation ¶
type Conversation struct {
ID string `json:"id"`
Title string `json:"title,omitempty"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
WaitingSince int64 `json:"waiting_since,omitempty"`
SnoozedUntil int64 `json:"snoozed_until,omitempty"`
Contacts ContactList `json:"contacts"`
AdminAssigneeID int64 `json:"admin_assignee_id,omitempty"`
TeamAssigneeID int64 `json:"team_assignee_id,omitempty"`
State string `json:"state,omitempty"`
Open bool `json:"open"`
Read bool `json:"read"`
ConversationMessage ConversationMessage `json:"conversation_message"`
ConversationParts ConversationPartList `json:"conversation_parts"`
TagList *TagList `json:"tags"`
}
A Conversation represents a conversation between contacts and admins in Intercom.
type ConversationAPI ¶
type ConversationAPI struct {
// contains filtered or unexported fields
}
ConversationAPI implements ConversationRepository
type ConversationList ¶
type ConversationList struct {
Pages CursorPages `json:"pages"`
TotalCount int64 `json:"total_count,omitempty"`
Conversations []Conversation `json:"conversations"`
}
ConversationList is a list of Conversations
type ConversationListParams ¶
type ConversationListParams struct {
PageParams
Type string `url:"type,omitempty"`
AdminID string `url:"admin_id,omitempty"`
IntercomUserID string `url:"intercom_user_id,omitempty"`
Email string `url:"email,omitempty"`
Open *bool `url:"open,omitempty"`
Unread *bool `url:"unread,omitempty"`
DisplayAs string `url:"display_as,omitempty"`
}
type ConversationListState ¶
type ConversationListState int
The state of Conversations to query SHOW_ALL shows all conversations, SHOW_OPEN shows only open conversations (only valid for Admin Conversation queries) SHOW_CLOSED shows only closed conversations (only valid for Admin Conversation queries) SHOW_UNREAD shows only unread conversations (only valid for Contact Conversation queries)
const ( SHOW_ALL ConversationListState = iota SHOW_OPEN SHOW_CLOSED SHOW_UNREAD )
type ConversationMessage ¶
type ConversationMessage struct {
ID string `json:"id"`
Subject string `json:"subject"`
Body string `json:"body"`
Author MessageAddress `json:"author"`
URL string `json:"url"`
}
A ConversationMessage is the message that started the conversation rendered for presentation
type ConversationPart ¶
type ConversationPart struct {
ID string `json:"id"`
PartType string `json:"part_type"`
Body string `json:"body"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
NotifiedAt int64 `json:"notified_at"`
AssignedTo Admin `json:"assigned_to"`
Author MessageAddress `json:"author"`
}
A ConversationPart is a Reply, Note, or Assignment to a Conversation
type ConversationPartList ¶
type ConversationPartList struct {
Parts []ConversationPart `json:"conversation_parts"`
}
A ConversationPartList lists the subsequent Conversation Parts
type ConversationRepository ¶
type ConversationRepository interface {
// contains filtered or unexported methods
}
ConversationRepository defines the interface for working with Conversations through the API.
type ConversationService ¶
type ConversationService struct {
Repository ConversationRepository
}
ConversationService handles interactions with the API through an ConversationRepository.
func (*ConversationService) Assign ¶
func (c *ConversationService) Assign(id string, assigner, assignee *Admin) (Conversation, error)
Assign a Conversation to an Admin
func (*ConversationService) Close ¶
func (c *ConversationService) Close(id string, closer *Admin) (Conversation, error)
Close a Conversation (without a body)
func (*ConversationService) Find ¶
func (c *ConversationService) Find(id string) (Conversation, error)
Find Conversation by conversation id
func (*ConversationService) ListAll ¶
func (c *ConversationService) ListAll(pageParams PageParams) (ConversationList, error)
List all Conversations
func (*ConversationService) ListByAdmin ¶
func (c *ConversationService) ListByAdmin(admin *Admin, state ConversationListState, pageParams PageParams) (ConversationList, error)
List Conversations by Admin
func (*ConversationService) ListByContact ¶
func (c *ConversationService) ListByContact(contact *Contact, state ConversationListState, pageParams PageParams) (ConversationList, error)
List Conversations by Contact
func (*ConversationService) MarkRead ¶
func (c *ConversationService) MarkRead(id string) (Conversation, error)
Mark Conversation as read (by a Contact)
func (*ConversationService) Open ¶
func (c *ConversationService) Open(id string, opener *Admin) (Conversation, error)
Open a Conversation (without a body)
func (*ConversationService) Reply ¶
func (c *ConversationService) Reply(id string, author MessagePerson, replyType ReplyType, body string) (Conversation, error)
func (*ConversationService) ReplyWithAttachmentURLs ¶
func (c *ConversationService) ReplyWithAttachmentURLs(id string, author MessagePerson, replyType ReplyType, body string, attachmentURLs []string) (Conversation, error)
Reply to a Conversation by id
type CursorPages ¶
type CursorPages struct {
Type string `json:"type,omitempty"`
Page int64 `json:"page,omitempty"`
PerPage int64 `json:"per_page,omitempty"`
TotalPages int64 `json:"total_pages,omitempty"`
Next *StartingAfterParam `json:"next,omitempty"`
}
CursorPages holds cursor-based pagination info returned by the API (v2.0+).
type Data ¶
type Data struct {
Item json.RawMessage `json:"item,omitempty"`
}
Data is the data node of the notification.
type Event ¶
type Event struct {
ID string `json:"id,omitempty"`
Email string `json:"email,omitempty"`
UserID string `json:"user_id,omitempty"`
EventName string `json:"event_name,omitempty"`
CreatedAt int64 `json:"created_at,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
An Event represents a new event that happens to a User.
type EventAPI ¶
type EventAPI struct {
// contains filtered or unexported fields
}
EventAPI implements EventRepository
type EventRepository ¶
type EventRepository interface {
// contains filtered or unexported methods
}
EventRepository defines the interface for working with Events through the API.
type EventService ¶
type EventService struct {
Repository EventRepository
}
EventService handles interactions with the API through an EventRepository.
type IntercomError ¶
type IntercomError interface {
Error() string
GetStatusCode() int
GetCode() string
GetMessage() string
}
IntercomError is a known error from the Intercom API
type JobAPI ¶
type JobAPI struct {
// contains filtered or unexported fields
}
JobAPI implements TagRepository
type JobData ¶
type JobData struct {
ID string `json:"id,omitempty"`
}
JobData is a payload that can be used to identify an existing Job to append to.
type JobItem ¶
type JobItem struct {
Method string `json:"method"`
DataType string `json:"data_type"`
Data interface{} `json:"data"`
}
A JobItem is an item to be processed as part of a bulk Job
func NewContactJobItem ¶
func NewContactJobItem(contact *Contact, method JobItemMethod) *JobItem
NewContactJobItem creates a JobItem that holds a Contact. It can take either a JOB_POST (for updates) or JOB_DELETE (for deletes) method.
func NewEventJobItem ¶
NewEventJobItem creates a JobItem that holds an Event.
type JobItemMethod ¶
type JobItemMethod int
const ( JOB_POST JobItemMethod = iota JOB_DELETE )
func (JobItemMethod) String ¶
func (state JobItemMethod) String() string
type JobRepository ¶
type JobRepository interface {
// contains filtered or unexported methods
}
JobRepository defines the interface for working with Jobs.
type JobRequest ¶
type JobRequest struct {
JobData *JobData `json:"job,omitempty"`
Items []*JobItem `json:"items,omitempty"`
// contains filtered or unexported fields
}
A JobRequest represents a new job to be sent to Intercom
type JobResponse ¶
type JobResponse struct {
ID string `json:"id,omitempty"`
AppID string `json:"app_id,omitempty"`
UpdatedAt int64 `json:"updated_at,omitempty"`
CreatedAt int64 `json:"created_at,omitempty"`
CompletedAt int64 `json:"completed_at,omitempty"`
ClosingAt int64 `json:"closing_at,omitempty"`
Name string `json:"name,omitempty"`
State string `json:"job_state,omitempty"`
Links map[string]string `json:"links,omitempty"`
}
A JobResponse represents a job enqueud on Intercom
func (JobResponse) String ¶
func (j JobResponse) String() string
type JobService ¶
type JobService struct {
Repository JobRepository
}
JobService builds jobs to process
func (*JobService) AppendEvents ¶
func (js *JobService) AppendEvents(id string, items ...*JobItem) (JobResponse, error)
Append Event items to existing Job
func (*JobService) AppendUsers ¶
func (js *JobService) AppendUsers(id string, items ...*JobItem) (JobResponse, error)
Append User items to existing Job
func (*JobService) Find ¶
func (js *JobService) Find(id string) (JobResponse, error)
Find existing Job
func (*JobService) NewEventJob ¶
func (js *JobService) NewEventJob(items ...*JobItem) (JobResponse, error)
NewEventJob creates a new Job for processing Events.
func (*JobService) NewUserJob ¶
func (js *JobService) NewUserJob(items ...*JobItem) (JobResponse, error)
NewUserJob creates a new Job for processing Users.
type MessageAPI ¶
type MessageAPI struct {
// contains filtered or unexported fields
}
MessageAPI implements MessageRepository
type MessageAddress ¶
type MessagePerson ¶
type MessagePerson interface {
MessageAddress() MessageAddress
}
A MessagePerson is someone to send a Message to and from.
type MessageRepository ¶
type MessageRepository interface {
// contains filtered or unexported methods
}
MessageRepository defines the interface for creating and updating Messages through the API.
type MessageRequest ¶
type MessageRequest struct {
MessageType string `json:"message_type,omitempty"`
Subject string `json:"subject,omitempty"`
Body string `json:"body,omitempty"`
Template string `json:"template,omitempty"`
From MessageAddress `json:"from,omitempty"`
To MessageAddress `json:"to,omitempty"`
}
MessageRequest represents a Message to be sent through Intercom from/to an Admin or Contact.
func NewContactMessage ¶
func NewContactMessage(from MessagePerson, body string) MessageRequest
NewContactMessage creates a new *Message from a Contact.
func NewEmailMessage ¶
func NewEmailMessage(template MessageTemplate, from, to MessagePerson, subject, body string) MessageRequest
NewEmailMessage creates a new *Message of email type.
func NewInAppMessage ¶
func NewInAppMessage(from, to MessagePerson, body string) MessageRequest
NewInAppMessage creates a new *Message of InApp (widget) type.
type MessageResponse ¶
type MessageResponse struct {
MessageType string `json:"message_type,omitempty"`
ID string `json:"id"`
CreatedAt int64 `json:"created_at,omitempty"`
Owner MessageAddress `json:"owner,omitempty"`
Subject string `json:"subject,omitempty"`
Body string `json:"body,omitempty"`
Template MessageTemplate `json:"template,omitempty"`
}
MessageResponse represents a Message response from Intercom.
func (MessageResponse) String ¶
func (m MessageResponse) String() string
type MessageService ¶
type MessageService struct {
Repository MessageRepository
}
MessageService handles interactions with the API through an MessageRepository.
func (*MessageService) Save ¶
func (m *MessageService) Save(message *MessageRequest) (MessageResponse, error)
Save (send) a Message
type MessageTemplate ¶
type MessageTemplate int
MessageTemplate determines the template used for email messages to Contacts (plain or personal)
const ( NO_TEMPLATE MessageTemplate = iota PERSONAL_TEMPLATE PLAIN_TEMPLATE )
func (MessageTemplate) String ¶
func (template MessageTemplate) String() string
func (*MessageTemplate) UnmarshalJSON ¶
func (template *MessageTemplate) UnmarshalJSON(b []byte) error
type Notification ¶
type Notification struct {
ID string `json:"id,omitempty"`
CreatedAt int64 `json:"created_at,omitempty"`
Topic string `json:"topic,omitempty"`
DeliveryAttempts int64 `json:"delivery_attempts,omitempty"`
FirstSentAt int64 `json:"first_sent_at,omitempty"`
RawData *Data `json:"data,omitempty"`
Conversation *Conversation `json:"-"`
Contact *Contact `json:"-"`
Tag *Tag `json:"-"`
Company *Company `json:"-"`
Event *Event `json:"-"`
}
Notification is the object delivered to a webhook.
func NewNotification ¶
func NewNotification(r io.Reader) (*Notification, error)
NewNotification parses a Notification from json read from an io.Reader. It may only contain partial objects (such as a single conversation part) depending on what is provided by the webhook.
type PageParams ¶
type PageParams struct {
Page int64 `json:"page" url:"page,omitempty"`
PerPage int64 `json:"per_page" url:"per_page,omitempty"`
TotalPages int64 `json:"total_pages" url:"-"`
}
PageParams determine paging information to and from the API
type Reply ¶
type Reply struct {
Type string `json:"type"`
ReplyType string `json:"message_type"`
Body string `json:"body,omitempty"`
AssigneeID string `json:"assignee_id,omitempty"`
AdminID string `json:"admin_id,omitempty"`
IntercomID string `json:"intercom_user_id,omitempty"`
Email string `json:"email,omitempty"`
AttachmentURLs []string `json:"attachment_urls,omitempty"`
}
A Reply to an Intercom conversation
type Segment ¶
type Segment struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
CreatedAt int64 `json:"created_at,omitempty"`
UpdatedAt int64 `json:"updated_at,omitempty"`
PersonType string `json:"person_type,omitempty"`
}
Segment represents an Segment in Intercom.
type SegmentAPI ¶
type SegmentAPI struct {
// contains filtered or unexported fields
}
SegmentAPI implements SegmentRepository
type SegmentList ¶
type SegmentList struct {
Segments []Segment `json:"segments,omitempty"`
}
SegmentList, an object holding a list of Segments
type SegmentRepository ¶
type SegmentRepository interface {
// contains filtered or unexported methods
}
SegmentRepository defines the interface for working with Segments through the API.
type SegmentService ¶
type SegmentService struct {
Repository SegmentRepository
}
SegmentService handles interactions with the API through a SegmentRepository.
func (*SegmentService) Find ¶
func (t *SegmentService) Find(id string) (Segment, error)
Find a particular Segment in the App
func (*SegmentService) List ¶
func (t *SegmentService) List() (SegmentList, error)
List all Segments for the App
type SocialProfile ¶
type SocialProfile struct {
Name string `json:"name,omitempty"`
ID string `json:"id,omitempty"`
Username string `json:"username,omitempty"`
URL string `json:"url,omitempty"`
}
SocialProfile represents a social account for a Contact.
type SocialProfileList ¶
type SocialProfileList struct {
SocialProfiles []SocialProfile `json:"social_profiles,omitempty"`
}
SocialProfileList is a list of SocialProfiles for a Contact.
type StartingAfterParam ¶
type StartingAfterParam struct {
PerPage int64 `json:"per_page,omitempty"`
StartingAfter string `json:"starting_after,omitempty"`
}
StartingAfterParam holds the cursor for the next page.
func (*StartingAfterParam) UnmarshalJSON ¶
func (s *StartingAfterParam) UnmarshalJSON(data []byte) error
UnmarshalJSON handles both formats returned by the Intercom API:
- Search endpoints return an object: {"starting_after": "WzXXX..."}
- List endpoints return a URL string: "https://api.intercom.io/...?page=2"
type TagAPI ¶
type TagAPI struct {
// contains filtered or unexported fields
}
TagAPI implements TagRepository
type TagList ¶
type TagList struct {
Tags []Tag `json:"tags,omitempty"`
}
TagList, an object holding a list of Tags
type TagRepository ¶
type TagRepository interface {
// contains filtered or unexported methods
}
TagRepository defines the interface for working with Tags through the API.
type TagService ¶
type TagService struct {
Repository TagRepository
}
TagService handles interactions with the API through a TagRepository.
func (*TagService) Save ¶
func (t *TagService) Save(tag *Tag) (Tag, error)
Save a new Tag for the App.
func (*TagService) Tag ¶
func (t *TagService) Tag(taggingList *TaggingList) (Tag, error)
Tag Users or Companies using a TaggingList.
type Tagging ¶
type Tagging struct {
ID string `json:"id,omitempty"`
UserID string `json:"user_id,omitempty"`
Email string `json:"email,omitempty"`
CompanyID string `json:"company_id,omitempty"`
Untag *bool `json:"untag,omitempty"`
}
A Tagging is an object identifying a User or Company to be tagged, that can optionally be set to untag.
type TaggingList ¶
type TaggingList struct {
Name string `json:"name,omitempty"`
Users []Tagging `json:"users,omitempty"`
Companies []Tagging `json:"companies,omitempty"`
}
TaggingList is an object used to Tag Users and Companies. The Name should be that of the Tag required, and Users and Companies are lists of Taggings
type UserCompany ¶
type UserCompany = ContactCompany
UserCompany is an alias for ContactCompany for backwards compatibility.
Source Files
¶
- admin.go
- admin_api.go
- article.go
- article_api.go
- bool.go
- collection.go
- collection_api.go
- company.go
- company_api.go
- contact.go
- contact_api.go
- conversation.go
- conversation_api.go
- doc.go
- event.go
- event_api.go
- intercom.go
- intercom_error.go
- job.go
- job_api.go
- job_item.go
- message.go
- message_api.go
- notification.go
- page.go
- reply.go
- request_company_mapper.go
- segment_api.go
- segments.go
- tag.go
- tag_api.go
- tagging.go