intercom-go: github.com/intercom/intercom-go Index | Files | Directories

package intercom

import "github.com/intercom/intercom-go"

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 App ID and Api Key from your [settings](http://app.intercom.io/apps/api_keys).

import (
  "gopkg.in/intercom/intercom-go.v2"
)
ic := intercom.NewClient("appID", "apiKey")

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.Users.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)
  Delete(string, interface{}) ([]byte, error)
}

The client will probably need to work with `appId`, `apiKey` 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.Users.List(pageParams)

Index

Package Files

admin.go admin_api.go bool.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 page.go reply.go requestUserMapper.go segment_api.go segments.go tag.go tag_api.go tagging.go user.go user_api.go

func BaseURI Uses

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 Uses

func Bool(value bool) *bool

Bool is a helper method to create *bool. *bool is preferred to bool because it allows distinction between false and absence.

func SetHTTPClient Uses

func SetHTTPClient(httpClient interfaces.HTTPClient) option

SetHTTPClient sets a HTTPClient for the Intercom Client to use. Useful for customising timeout behaviour etc.

func TraceHTTP Uses

func TraceHTTP(trace bool) option

TraceHTTP turns on HTTP request/response tracing for debugging.

type Admin Uses

type Admin struct {
    ID    json.Number `json:"id"`
    Type  string      `json:"type"`
    Name  string      `json:"name"`
    Email string      `json:"email"`
}

Admin represents an Admin in Intercom.

func (Admin) IsNobodyAdmin Uses

func (a Admin) IsNobodyAdmin() bool

IsNobodyAdmin is a helper function to determine if the Admin is 'Nobody'.

func (Admin) MessageAddress Uses

func (a Admin) MessageAddress() MessageAddress

Get the address for a Contact in order to message them

func (Admin) String Uses

func (a Admin) String() string

type AdminAPI Uses

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

AdminAPI implements AdminRepository

type AdminList Uses

type AdminList struct {
    Admins []Admin
}

AdminList represents an object holding list of Admins

type AdminRepository Uses

type AdminRepository interface {
    // contains filtered or unexported methods
}

AdminRepository defines the interface for working with Admins through the API.

type AdminService Uses

type AdminService struct {
    Repository AdminRepository
}

AdminService handles interactions with the API through an AdminRepository.

func (*AdminService) List Uses

func (c *AdminService) List() (AdminList, error)

List lists the Admins associated with your App.

type Client Uses

type Client struct {
    // Services for interacting with various resources in Intercom.
    Admins        AdminService
    Companies     CompanyService
    Contacts      ContactService
    Conversations ConversationService
    Events        EventService
    Jobs          JobService
    Messages      MessageService
    Segments      SegmentService
    Tags          TagService
    Users         UserService

    // Mappings for resources to API constructs
    AdminRepository        AdminRepository
    CompanyRepository      CompanyRepository
    ContactRepository      ContactRepository
    ConversationRepository ConversationRepository
    EventRepository        EventRepository
    JobRepository          JobRepository
    MessageRepository      MessageRepository
    SegmentRepository      SegmentRepository
    TagRepository          TagRepository
    UserRepository         UserRepository

    // AppID For Intercom.
    AppID string

    // APIKey for Intercom's API. See http://app.intercom.io/apps/api_keys.
    APIKey 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 Uses

func NewClient(appID, apiKey string) *Client

NewClient returns a new Intercom API client, configured with the default HTTPClient.

func (*Client) Option Uses

func (c *Client) Option(opts ...option) (previous option)

Set Options on the Intercom Client, see TraceHTTP, BaseURI and SetHTTPClient.

type Company Uses

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,omitempty"`
    UserCount        int64                  `json:"user_count,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.

func (Company) String Uses

func (c Company) String() string

type CompanyAPI Uses

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

CompanyAPI implements CompanyRepository

type CompanyIdentifiers Uses

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 Uses

type CompanyList struct {
    Pages       PageParams
    Companies   []Company
    ScrollParam string `json:"scroll_param,omitempty"`
}

CompanyList holds a list of Companies and paging information

type CompanyRepository Uses

type CompanyRepository interface {
    // contains filtered or unexported methods
}

CompanyRepository defines the interface for working with Companies through the API.

type CompanyService Uses

type CompanyService struct {
    Repository CompanyRepository
}

CompanyService handles interactions with the API through a CompanyRepository.

func (*CompanyService) FindByCompanyID Uses

func (c *CompanyService) FindByCompanyID(companyID string) (Company, error)

FindByCompanyID finds a Company using their CompanyID CompanyID is a customer-defined field

func (*CompanyService) FindByID Uses

func (c *CompanyService) FindByID(id string) (Company, error)

FindByID finds a Company using their Intercom ID

func (*CompanyService) FindByName Uses

func (c *CompanyService) FindByName(name string) (Company, error)

FindByName finds a Company using their Name

func (*CompanyService) List Uses

func (c *CompanyService) List(params PageParams) (CompanyList, error)

List Companies

func (*CompanyService) ListBySegment Uses

func (c *CompanyService) ListBySegment(segmentID string, params PageParams) (CompanyList, error)

List Companies by Segment

func (*CompanyService) ListByTag Uses

func (c *CompanyService) ListByTag(tagID string, params PageParams) (CompanyList, error)

List Companies by Tag

func (*CompanyService) Save Uses

func (c *CompanyService) Save(user *Company) (Company, error)

Save a new Company, or update an existing one.

func (*CompanyService) Scroll Uses

func (c *CompanyService) Scroll(scrollParam string) (CompanyList, error)

List all Companies for App via Scroll API

type Contact Uses

type Contact struct {
    ID                     string                 `json:"id,omitempty"`
    Email                  string                 `json:"email,omitempty"`
    Phone                  string                 `json:"phone,omitempty"`
    UserID                 string                 `json:"user_id,omitempty"`
    Name                   string                 `json:"name,omitempty"`
    Avatar                 *UserAvatar            `json:"avatar,omitempty"`
    LocationData           *LocationData          `json:"location_data,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"`
    LastSeenIP             string                 `json:"last_seen_ip,omitempty"`
    SocialProfiles         *SocialProfileList     `json:"social_profiles,omitempty"`
    UnsubscribedFromEmails *bool                  `json:"unsubscribed_from_emails,omitempty"`
    UserAgentData          string                 `json:"user_agent_data,omitempty"`
    Tags                   *TagList               `json:"tags,omitempty"`
    Segments               *SegmentList           `json:"segments,omitempty"`
    Companies              *CompanyList           `json:"companies,omitempty"`
    CustomAttributes       map[string]interface{} `json:"custom_attributes,omitempty"`
    UpdateLastRequestAt    *bool                  `json:"update_last_request_at,omitempty"`
    NewSession             *bool                  `json:"new_session,omitempty"`
}

Contact represents a Contact 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 Uses

func (c Contact) MessageAddress() MessageAddress

Get the address for a Contact in order to message them

func (Contact) String Uses

func (c Contact) String() string

type ContactAPI Uses

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

ContactAPI implements ContactRepository

type ContactList Uses

type ContactList struct {
    Pages       PageParams
    Contacts    []Contact
    ScrollParam string `json:"scroll_param,omitempty"`
}

ContactList holds a list of Contacts and paging information

type ContactRepository Uses

type ContactRepository interface {
    // contains filtered or unexported methods
}

ContactRepository defines the interface for working with Contacts through the API.

type ContactService Uses

type ContactService struct {
    Repository ContactRepository
}

ContactService handles interactions with the API through a ContactRepository.

func (*ContactService) Convert Uses

func (c *ContactService) Convert(contact *Contact, user *User) (User, error)

Convert Contact to User

func (*ContactService) Create Uses

func (c *ContactService) Create(contact *Contact) (Contact, error)

Create Contact

func (*ContactService) Delete Uses

func (c *ContactService) Delete(contact *Contact) (Contact, error)

Delete Contact

func (*ContactService) FindByID Uses

func (c *ContactService) FindByID(id string) (Contact, error)

FindByID looks up a Contact by their Intercom ID.

func (*ContactService) FindByUserID Uses

func (c *ContactService) FindByUserID(userID string) (Contact, error)

FindByUserID looks up a Contact by their UserID (automatically generated server side).

func (*ContactService) List Uses

func (c *ContactService) List(params PageParams) (ContactList, error)

List all Contacts for App.

func (*ContactService) ListByEmail Uses

func (c *ContactService) ListByEmail(email string, params PageParams) (ContactList, error)

ListByEmail looks up a list of Contacts by their Email.

func (*ContactService) ListBySegment Uses

func (c *ContactService) ListBySegment(segmentID string, params PageParams) (ContactList, error)

List Contacts by Segment.

func (*ContactService) ListByTag Uses

func (c *ContactService) ListByTag(tagID string, params PageParams) (ContactList, error)

List Contacts By Tag.

func (*ContactService) Scroll Uses

func (c *ContactService) Scroll(scrollParam string) (ContactList, error)

List all Contacts for App via Scroll API

func (*ContactService) Update Uses

func (c *ContactService) Update(contact *Contact) (Contact, error)

Update Contact

type Conversation Uses

type Conversation struct {
    ID                  string               `json:"id"`
    CreatedAt           int64                `json:"created_at"`
    UpdatedAt           int64                `json:"updated_at"`
    User                User                 `json:"user"`
    Assignee            Admin                `json:"assignee"`
    Open                bool                 `json:"open"`
    Read                bool                 `json:"read"`
    ConversationMessage ConversationMessage  `json:"conversation_message"`
    ConversationParts   ConversationPartList `json:"conversation_parts"`
}

A Conversation represents a conversation between users and admins in Intercom.

type ConversationAPI Uses

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

ConversationAPI implements ConversationRepository

type ConversationList Uses

type ConversationList struct {
    Pages         PageParams     `json:"pages"`
    Conversations []Conversation `json:"conversations"`
}

ConversationList is a list of Conversations

type ConversationListState Uses

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 User Conversation queries)

const (
    SHOW_ALL ConversationListState = iota
    SHOW_OPEN
    SHOW_CLOSED
    SHOW_UNREAD
)

type ConversationMessage Uses

type ConversationMessage struct {
    Subject string         `json:"subject"`
    Body    string         `json:"body"`
    Author  MessageAddress `json:"author"`
}

A ConversationMessage is the message that started the conversation rendered for presentation

type ConversationPart Uses

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 Uses

type ConversationPartList struct {
    Parts []ConversationPart `json:"conversation_parts"`
}

A ConversationPartList lists the subsequent Conversation Parts

type ConversationRepository Uses

type ConversationRepository interface {
    // contains filtered or unexported methods
}

ConversationRepository defines the interface for working with Conversations through the API.

type ConversationService Uses

type ConversationService struct {
    Repository ConversationRepository
}

ConversationService handles interactions with the API through an ConversationRepository.

func (*ConversationService) Assign Uses

func (c *ConversationService) Assign(id string, assigner, assignee *Admin) (Conversation, error)

Assign a Conversation to an Admin

func (*ConversationService) Close Uses

func (c *ConversationService) Close(id string, closer *Admin) (Conversation, error)

Close a Conversation (without a body)

func (*ConversationService) Find Uses

func (c *ConversationService) Find(id string) (Conversation, error)

Find Conversation by conversation id

func (*ConversationService) ListAll Uses

func (c *ConversationService) ListAll(pageParams PageParams) (ConversationList, error)

List all Conversations

func (*ConversationService) ListByAdmin Uses

func (c *ConversationService) ListByAdmin(admin *Admin, state ConversationListState, pageParams PageParams) (ConversationList, error)

List Conversations by Admin

func (*ConversationService) ListByUser Uses

func (c *ConversationService) ListByUser(user *User, state ConversationListState, pageParams PageParams) (ConversationList, error)

List Conversations by User

func (*ConversationService) MarkRead Uses

func (c *ConversationService) MarkRead(id string) (Conversation, error)

Mark Conversation as read (by a User)

func (*ConversationService) Open Uses

func (c *ConversationService) Open(id string, opener *Admin) (Conversation, error)

Open a Conversation (without a body)

func (*ConversationService) Reply Uses

func (c *ConversationService) Reply(id string, author MessagePerson, replyType ReplyType, body string) (Conversation, error)

func (*ConversationService) ReplyWithAttachmentURLs Uses

func (c *ConversationService) ReplyWithAttachmentURLs(id string, author MessagePerson, replyType ReplyType, body string, attachmentURLs []string) (Conversation, error)

Reply to a Conversation by id

type Event Uses

type Event struct {
    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.

func (Event) String Uses

func (e Event) String() string

type EventAPI Uses

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

EventAPI implements EventRepository

type EventRepository Uses

type EventRepository interface {
    // contains filtered or unexported methods
}

EventRepository defines the interface for working with Events through the API.

type EventService Uses

type EventService struct {
    Repository EventRepository
}

EventService handles interactions with the API through an EventRepository.

func (*EventService) Save Uses

func (e *EventService) Save(event *Event) error

Save a new Event

type IntercomError Uses

type IntercomError interface {
    Error() string
    GetStatusCode() int
    GetCode() string
    GetMessage() string
}

IntercomError is a known error from the Intercom API

type JobAPI Uses

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

JobAPI implements TagRepository

type JobData Uses

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 Uses

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 NewEventJobItem Uses

func NewEventJobItem(event *Event) *JobItem

NewEventJobItem creates a JobItem that holds an Event.

func NewUserJobItem Uses

func NewUserJobItem(user *User, method JobItemMethod) *JobItem

NewUserJobItem creates a JobItem that holds an User. It can take either a JOB_POST (for updates) or JOB_DELETE (for deletes) method.

type JobItemMethod Uses

type JobItemMethod int
const (
    JOB_POST JobItemMethod = iota
    JOB_DELETE
)

func (JobItemMethod) String Uses

func (state JobItemMethod) String() string

type JobRepository Uses

type JobRepository interface {
    // contains filtered or unexported methods
}

JobRepository defines the interface for working with Jobs.

type JobRequest Uses

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 Uses

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 Uses

func (j JobResponse) String() string

type JobService Uses

type JobService struct {
    Repository JobRepository
}

JobService builds jobs to process

func (*JobService) AppendEvents Uses

func (js *JobService) AppendEvents(id string, items ...*JobItem) (JobResponse, error)

Append Event items to existing Job

func (*JobService) AppendUsers Uses

func (js *JobService) AppendUsers(id string, items ...*JobItem) (JobResponse, error)

Append User items to existing Job

func (*JobService) Find Uses

func (js *JobService) Find(id string) (JobResponse, error)

Find existing Job

func (*JobService) NewEventJob Uses

func (js *JobService) NewEventJob(items ...*JobItem) (JobResponse, error)

NewEventJob creates a new Job for processing Events.

func (*JobService) NewUserJob Uses

func (js *JobService) NewUserJob(items ...*JobItem) (JobResponse, error)

NewUserJob creates a new Job for processing Users.

type JobState Uses

type JobState int

The state of a Job

const (
    PENDING JobState = iota
    RUNNING
    COMPLETED
    FAILED
)

func (JobState) String Uses

func (state JobState) String() string

type LocationData Uses

type LocationData struct {
    CityName      string  `json:"city_name,omitempty"`
    ContinentCode string  `json:"continent_code,omitempty"`
    CountryName   string  `json:"country_name,omitempty"`
    Latitude      float64 `json:"latitude,omitempty"`
    Longitude     float64 `json:"longitude,omitempty"`
    PostalCode    string  `json:"postal_code,omitempty"`
    RegionName    string  `json:"region_name,omitempty"`
    Timezone      string  `json:"timezone,omitempty"`
    CountryCode   string  `json:"country_code,omitempty"`
}

LocationData represents the location for a User.

func (LocationData) String Uses

func (l LocationData) String() string

type MessageAPI Uses

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

MessageAPI implements MessageRepository

type MessageAddress Uses

type MessageAddress struct {
    Type   string `json:"type,omitempty"`
    ID     string `json:"id,omitempty"`
    Email  string `json:"email,omitempty"`
    UserID string `json:"user_id,omitempty"`
}

type MessagePerson Uses

type MessagePerson interface {
    MessageAddress() MessageAddress
}

A MessagePerson is someone to send a Message to and from.

type MessageRepository Uses

type MessageRepository interface {
    // contains filtered or unexported methods
}

MessageRepository defines the interface for creating and updating Messages through the API.

type MessageRequest Uses

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, User, or Contact.

func NewEmailMessage Uses

func NewEmailMessage(template MessageTemplate, from, to MessagePerson, subject, body string) MessageRequest

NewEmailMessage creates a new *Message of email type.

func NewInAppMessage Uses

func NewInAppMessage(from, to MessagePerson, body string) MessageRequest

NewInAppMessage creates a new *Message of InApp (widget) type.

func NewUserMessage Uses

func NewUserMessage(from MessagePerson, body string) MessageRequest

NewUserMessage creates a new *Message from a User.

type MessageResponse Uses

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 to be sent through Intercom from/to an Admin, User, or Contact.

func (MessageResponse) String Uses

func (m MessageResponse) String() string

type MessageService Uses

type MessageService struct {
    Repository MessageRepository
}

MessageService handles interactions with the API through an MessageRepository.

func (*MessageService) Save Uses

func (m *MessageService) Save(message *MessageRequest) (MessageResponse, error)

Save (send) a Message

type MessageTemplate Uses

type MessageTemplate int

MessageTemplate determines the template used for email messages to Users or Contacts (plain or personal)

const (
    NO_TEMPLATE MessageTemplate = iota
    PERSONAL_TEMPLATE
    PLAIN_TEMPLATE
)

func (MessageTemplate) String Uses

func (template MessageTemplate) String() string

func (*MessageTemplate) UnmarshalJSON Uses

func (template *MessageTemplate) UnmarshalJSON(b []byte) error

type PageParams Uses

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 Plan Uses

type Plan struct {
    ID   string `json:"id,omitempty"`
    Name string `json:"name,omitempty"`
}

The Plan a Company is on

func (Plan) String Uses

func (p Plan) String() string

type Reply Uses

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"`
    UserID         string   `json:"user_id,omitempty"`
    AttachmentURLs []string `json:"attachment_urls,omitempty"`
}

A Reply to an Intercom conversation

type ReplyType Uses

type ReplyType int

ReplyType determines the type of Reply

const (
    CONVERSATION_COMMENT ReplyType = iota
    CONVERSATION_NOTE
    CONVERSATION_ASSIGN
    CONVERSATION_OPEN
    CONVERSATION_CLOSE
)

func (ReplyType) String Uses

func (reply ReplyType) String() string

type RequestUserMapper Uses

type RequestUserMapper struct{}

func (RequestUserMapper) ConvertUser Uses

func (rum RequestUserMapper) ConvertUser(user *User) requestUser

func (RequestUserMapper) MakeUserCompaniesFromCompanies Uses

func (rum RequestUserMapper) MakeUserCompaniesFromCompanies(companies []Company) []UserCompany

type Segment Uses

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.

func (Segment) String Uses

func (s Segment) String() string

type SegmentAPI Uses

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

SegmentAPI implements SegmentRepository

type SegmentList Uses

type SegmentList struct {
    Segments []Segment `json:"segments,omitempty"`
}

SegmentList, an object holding a list of Segments

type SegmentRepository Uses

type SegmentRepository interface {
    // contains filtered or unexported methods
}

SegmentRepository defines the interface for working with Segments through the API.

type SegmentService Uses

type SegmentService struct {
    Repository SegmentRepository
}

SegmentService handles interactions with the API through a SegmentRepository.

func (*SegmentService) Find Uses

func (t *SegmentService) Find(id string) (Segment, error)

Find a particular Segment in the App

func (*SegmentService) List Uses

func (t *SegmentService) List() (SegmentList, error)

List all Segments for the App

type SocialProfile Uses

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 User.

func (SocialProfile) String Uses

func (s SocialProfile) String() string

type SocialProfileList Uses

type SocialProfileList struct {
    SocialProfiles []SocialProfile `json:"social_profiles,omitempty"`
}

SocialProfile list is a list of SocialProfiles for a User.

type Tag Uses

type Tag struct {
    ID   string `json:"id,omitempty"`
    Name string `json:"name,omitempty"`
}

Tag represents an Tag in Intercom.

func (Tag) String Uses

func (t Tag) String() string

type TagAPI Uses

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

TagAPI implements TagRepository

type TagList Uses

type TagList struct {
    Tags []Tag `json:"tags,omitempty"`
}

TagList, an object holding a list of Tags

type TagRepository Uses

type TagRepository interface {
    // contains filtered or unexported methods
}

TagRepository defines the interface for working with Tags through the API.

type TagService Uses

type TagService struct {
    Repository TagRepository
}

TagService handles interactions with the API through a TagRepository.

func (*TagService) Delete Uses

func (t *TagService) Delete(id string) error

Delete a Tag

func (*TagService) List Uses

func (t *TagService) List() (TagList, error)

List all Tags for the App

func (*TagService) Save Uses

func (t *TagService) Save(tag *Tag) (Tag, error)

Save a new Tag for the App.

func (*TagService) Tag Uses

func (t *TagService) Tag(taggingList *TaggingList) (Tag, error)

Tag Users or Companies using a TaggingList.

type Tagging Uses

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 Uses

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 User Uses

type User struct {
    ID                     string                 `json:"id,omitempty"`
    Email                  string                 `json:"email,omitempty"`
    Phone                  string                 `json:"phone,omitempty"`
    UserID                 string                 `json:"user_id,omitempty"`
    Anonymous              *bool                  `json:"anonymous,omitempty"`
    Name                   string                 `json:"name,omitempty"`
    Pseudonym              string                 `json:"pseudonym,omitempty"`
    Avatar                 *UserAvatar            `json:"avatar,omitempty"`
    LocationData           *LocationData          `json:"location_data,omitempty"`
    SignedUpAt             int64                  `json:"signed_up_at,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"`
    LastSeenIP             string                 `json:"last_seen_ip,omitempty"`
    SocialProfiles         *SocialProfileList     `json:"social_profiles,omitempty"`
    UnsubscribedFromEmails *bool                  `json:"unsubscribed_from_emails,omitempty"`
    UserAgentData          string                 `json:"user_agent_data,omitempty"`
    Tags                   *TagList               `json:"tags,omitempty"`
    Segments               *SegmentList           `json:"segments,omitempty"`
    Companies              *CompanyList           `json:"companies,omitempty"`
    CustomAttributes       map[string]interface{} `json:"custom_attributes,omitempty"`
    UpdateLastRequestAt    *bool                  `json:"update_last_request_at,omitempty"`
    NewSession             *bool                  `json:"new_session,omitempty"`
    LastSeenUserAgent      string                 `json:"last_seen_user_agent,omitempty"`
}

User represents a User 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 (User) MessageAddress Uses

func (u User) MessageAddress() MessageAddress

Get the address for an User in order to message them

func (User) String Uses

func (u User) String() string

type UserAPI Uses

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

UserAPI implements UserRepository

type UserAvatar Uses

type UserAvatar struct {
    ImageURL string `json:"image_url,omitempty"`
}

UserAvatar represents an avatar for a User.

func (UserAvatar) String Uses

func (a UserAvatar) String() string

type UserCompany Uses

type UserCompany struct {
    CompanyID string `json:"company_id,omitempty"`
    Name      string `json:"name,omitempty"`
    Remove    *bool  `json:"remove,omitempty"`
}

A Company the User belongs to used to update Companies on a User.

type UserIdentifiers Uses

type UserIdentifiers struct {
    ID     string `url:"-"`
    UserID string `url:"user_id,omitempty"`
    Email  string `url:"email,omitempty"`
}

UserIdentifiers are used to identify Users in Intercom.

type UserList Uses

type UserList struct {
    Pages       PageParams
    Users       []User
    ScrollParam string `json:"scroll_param,omitempty"`
}

UserList holds a list of Users and paging information

type UserRepository Uses

type UserRepository interface {
    // contains filtered or unexported methods
}

UserRepository defines the interface for working with Users through the API.

type UserService Uses

type UserService struct {
    Repository UserRepository
}

UserService handles interactions with the API through a UserRepository.

func (*UserService) Delete Uses

func (u *UserService) Delete(id string) (User, error)

func (*UserService) FindByEmail Uses

func (u *UserService) FindByEmail(email string) (User, error)

FindByEmail looks up a User by their Email.

func (*UserService) FindByID Uses

func (u *UserService) FindByID(id string) (User, error)

FindByID looks up a User by their Intercom ID.

func (*UserService) FindByUserID Uses

func (u *UserService) FindByUserID(userID string) (User, error)

FindByUserID looks up a User by their UserID (customer supplied).

func (*UserService) List Uses

func (u *UserService) List(params PageParams) (UserList, error)

List all Users for App.

func (*UserService) ListBySegment Uses

func (u *UserService) ListBySegment(segmentID string, params PageParams) (UserList, error)

List Users by Segment.

func (*UserService) ListByTag Uses

func (u *UserService) ListByTag(tagID string, params PageParams) (UserList, error)

List Users By Tag.

func (*UserService) Save Uses

func (u *UserService) Save(user *User) (User, error)

Save a User, creating or updating them.

func (*UserService) Scroll Uses

func (u *UserService) Scroll(scrollParam string) (UserList, error)

List all Users for App via Scroll API

Directories

PathSynopsis
interfaces

Package intercom imports 5 packages (graph). Updated 2017-04-25. Refresh now. Tools for package owners.