intercom

package module
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

Intercom-Go

Circle CI

Thin client for the Intercom API.

Install

go get gopkg.in/intercom/intercom-go.v2

docker_image 1
Try out our Docker Image (Beta) to help you get started more quickly.
It should make it easier to get setup with the SDK and start interacting with the API.
(Note, this is in Beta and is for testing purposes only, it should not be used in production)

Usage

Getting a Client
import (
	intercom "gopkg.in/intercom/intercom-go.v2"
)
// You can use either an an OAuth or Access Token
ic := intercom.NewClient("access_token", "")

This client can then be used to make requests.

If you already have an access token you can find it here. If you want to create or learn more about access tokens then you can find more info here.

If you are building a third party application you can get your OAuth token by setting-up-oauth for Intercom. You can use the Goth library which is a simple OAuth package for Go web aplicaitons and supports Intercom to more easily implement Oauth.

Client Options

The client can be configured with different options by calls to ic.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, see below for more info

or combined:

ic.Option(intercom.TraceHTTP(true), intercom.BaseURI("http://intercom.dev"))
Users
Save
user := intercom.User{
	UserID: "27",
	Email: "test@example.com",
	Name: "InterGopher",
	SignedUpAt: int64(time.Now().Unix()),
	CustomAttributes: map[string]interface{}{"is_cool": true},
}
savedUser, err := ic.Users.Save(&user)
  • One of UserID, or Email is required.
  • SignedUpAt (optional), like all dates in the client, must be an integer(32) representing seconds since Unix Epoch.
Adding/Removing Companies

Adding a Company:

companyList := intercom.CompanyList{
	Companies: []intercom.Company{
		{CompanyID: "5"},
	},
}
user := intercom.User{
	UserID: "27",
	Companies: &companyList,
}

Removing is similar, but adding a Remove: intercom.Bool(true) attribute to a company.

Find
user, err := ic.Users.FindByID("46adad3f09126dca")
user, err := ic.Users.FindByUserID("27")
user, err := ic.Users.FindByEmail("test@example.com")
List
userList, err := ic.Users.List(intercom.PageParams{Page: 2})
userList.Pages // page information
userList.Users // []User
userList, err := ic.Users.Scroll("")
scrollParam := userList.ScrollParam
userList, err := ic.Users.Scroll(scrollParam)
userList, err := ic.Users.ListBySegment("segmentID123", intercom.PageParams{})
userList, err := ic.Users.ListByTag("42", intercom.PageParams{})
Delete
user, err := ic.Users.Delete("46adad3f09126dca")
Contacts
Contacts are the same as leads.

In the Intercom API we refer to contacts as leads. See here for more info We did not change this in the SDK since that would be a major breaking change. This is something we will address shortly. So any reference to contacts in the SDK is a reference to a lead in Intercom

Find
contact, err := ic.Contacts.FindByID("46adad3f09126dca")
contact, err := ic.Contacts.FindByUserID("27")
List
contactList, err := ic.Contacts.List(intercom.PageParams{Page: 2})
contactList.Pages // page information
contactList.Contacts // []Contact
contactList, err := ic.Contacts.Scroll("")
scrollParam = contactList.ScrollParam
contactList, err := ic.Contacts.Scroll(scrollParam)
contactList, err := ic.Contacts.ListByEmail("test@example.com", intercom.PageParams{})
Create
contact := intercom.Contact{
	Email: "test@example.com",
	Name: "SomeContact",
	CustomAttributes: map[string]interface{}{"is_cool": true},
}
savedContact, err := ic.Contacts.Create(&contact)
  • No identifier is required.
  • Set values for UserID will be ignored (consider creating Users instead)
Update
contact := intercom.Contact{
	UserID: "abc-13d-3",
	Name: "SomeContact",
	CustomAttributes: map[string]interface{}{"is_cool": true},
}
savedContact, err := ic.Contacts.Update(&contact)
  • ID or UserID is required.
  • Will not create new contacts.
Convert

Used to convert a Contact into a User

contact := intercom.Contact{
	UserID: "abc-13d-3",
}
user := intercom.User{
	Email: "myuser@signedup.com",
}
savedUser, err := ic.Contacts.Convert(&contact, &user)
  • If the User does not already exist in Intercom, the Contact will be uplifted to a User.
  • If the User does exist, the Contact will be merged into it and the User returned.
Companies
Save
company := intercom.Company{
	CompanyID: "27",
	Name: "My Co",
	CustomAttributes: map[string]interface{}{"is_cool": true},
	Plan: &intercom.Plan{Name: "MyPlan"},
}
savedCompany, err := ic.Companies.Save(&company)
  • CompanyID is required.
Find
company, err := ic.Companies.FindByID("46adad3f09126dca")
company, err := ic.Companies.FindByCompanyID("27")
company, err := ic.Companies.FindByName("My Co")
List
companyList, err := ic.Companies.List(intercom.PageParams{Page: 2})
companyList.Pages // page information
companyList.Companies // []Companies
companyList, err := ic.Companies.ListBySegment("segmentID123", intercom.PageParams{})
companyList, err := ic.Companies.ListByTag("42", intercom.PageParams{})
ListUsers
userList, err := ic.Companies.ListUsersByID("46adad3f09126dca", intercom.PageParams{})
userList.Users // []User
userList, err := ic.Companies.ListUsersByCompanyID("27", intercom.PageParams{})
Events
Save
event := intercom.Event{
	UserID: "27",
	EventName: "bought_item",
	CreatedAt: int64(time.Now().Unix()),
	Metadata: map[string]interface{}{"item_name": "PocketWatch"},
}
err := ic.Events.Save(&event)
  • One of UserID, ID, or Email is required (With leads you need to use ID).
  • EventName is required.
  • CreatedAt is required, must be an integer representing seconds since Unix Epoch. Will be set to now unless given.
  • Metadata is optional, and can be constructed using the helper as above, or as a passed map[string]interface{}.
Admins
List
adminList, err := ic.Admins.List()
admins := adminList.Admins
Tags
List
tagList, err := ic.Tags.List()
tags := tagList.Tags
Save
tag := intercom.Tag{Name: "GoTag"}
savedTag, err := ic.Tags.Save(&tag)

Name is required. Passing an ID will attempt to update the tag with that ID.

Delete
err := ic.Tags.Delete("6")
Tagging Users/Companies
taggingList := intercom.TaggingList{Name: "GoTag", Users: []intercom.Tagging{{UserID: "27"}}}
savedTag, err := ic.Tags.Tag(&taggingList)

A Tagging can identify a User or Company, and can be set to Untag:

taggingList := intercom.TaggingList{Name: "GoTag", Users: []intercom.Tagging{{UserID: "27", Untag: intercom.Bool(true)}}}
savedTag, err := ic.Tags.Tag(&taggingList)
Segments
List
segmentList := ic.Segments.List()
segments, err := segmentList.Segments
Find
segment, err := ic.Segments.Find("abc312daf2397")
Messages
New Admin to User/Contact Email
msg := intercom.NewEmailMessage(intercom.PERSONAL_TEMPLATE, intercom.Admin{ID: "1234"}, intercom.User{Email: "test@example.com"}, "subject", "body")
savedMessage, err := ic.Messages.Save(&msg)

Can use intercom.PLAIN_TEMPLATE too, or replace the intercom.User with an intercom.Contact.

New Admin to User/Contact InApp
msg := intercom.NewInAppMessage(intercom.Admin{ID: "1234"}, intercom.Contact{Email: "test@example.com"}, "body")
savedMessage, err := ic.Messages.Save(&msg)
New User Message
msg := intercom.NewUserMessage(intercom.User{Email: "test@example.com"}, "body")
savedMessage, err := ic.Messages.Save(&msg)
Conversations
Find Conversation
convo, err := intercom.Conversations.Find("1234")
List Conversations
All
convoList, err := intercom.Conversations.ListAll(intercom.PageParams{})
By User

Showing all for user:

convoList, err := intercom.Conversations.ListByUser(&user, intercom.SHOW_ALL, intercom.PageParams{})

Showing just Unread for user:

convoList, err := intercom.Conversations.ListByUser(&user, intercom.SHOW_UNREAD, intercom.PageParams{})
By Admin

Showing all for admin:

convoList, err := intercom.Conversations.ListByAdmin(&admin, intercom.SHOW_ALL, intercom.PageParams{})

Showing just Open for admin:

convoList, err := intercom.Conversations.ListByAdmin(&admin, intercom.SHOW_OPEN, intercom.PageParams{})

Showing just Closed for admin:

convoList, err := intercom.Conversations.ListByAdmin(&admin, intercom.SHOW_CLOSED, intercom.PageParams{})
Reply

User reply:

convo, err := intercom.Conversations.Reply("1234", &user, intercom.CONVERSATION_COMMENT, "my message")

User reply with attachment:

convo, err := intercom.Conversations.ReplyWithAttachmentURLs("1234", &user, intercom.CONVERSATION_COMMENT, "my message", string[]{"http://www.example.com/attachment.jpg"})

User reply that opens:

convo, err := intercom.Conversations.Reply("1234", &user, intercom.CONVERSATION_OPEN, "my message")

Admin reply:

convo, err := intercom.Conversations.Reply("1234", &admin, intercom.CONVERSATION_COMMENT, "my message")

Admin note:

convo, err := intercom.Conversations.Reply("1234", &admin, intercom.CONVERSATION_NOTE, "my message to just admins")
Open and Close

Open:

convo, err := intercom.Conversations.Open("1234", &openerAdmin)

Close:

convo, err := intercom.Conversations.Close("1234", &closerAdmin)
Assign
convo, err := intercom.Conversations.Assign("1234", &assignerAdmin, &assigneeAdmin)
Webhooks
Notifications

If you have received a JSON webhook notification, you may want to convert it into real Intercom object. A Notification can be created from any io.Reader, typically a http request:

var r io.Reader
notif, err := intercom.NewNotification(r)

The returned Notification will contain exactly 1 of the Company, Conversation, Event, Tag or User fields populated. It may only contain partial objects (such as a single conversation part) depending on what is provided by the webhook.

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

It'll 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.

Pull Requests
  • Add tests! Your patch won't be accepted if it doesn't have tests.

  • Document any change in behaviour. Make sure the README and any other relevant documentation are kept up-to-date.

  • Create topic branches. Don't ask us to pull from your master branch.

  • One pull request per feature. If you want to do more than one thing, send multiple pull requests.

  • Send coherent history. Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before sending them to us.

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

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

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

func SetHTTPClient(httpClient interfaces.HTTPClient) option

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

func TraceHTTP

func TraceHTTP(trace bool) option

TraceHTTP turns on HTTP request/response tracing for debugging.

Types

type Addressable

type Addressable struct {
	Type string `json:"type,omitempty"`
	ID   string `json:"id,omitempty"`
	URL  string `json:"url,omitempty"`
}

type AddressableList

type AddressableList struct {
	Type       string         `json:"type,omitempty"`
	Data       *[]Addressable `json:"data,omitempty"`
	URL        string         `json:"url,omitempty"`
	TotalCount int64          `json:"total_count,omitempty"`
	HasMore    *bool          `json:"has_more,omitempty"`
}

type Admin

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

func (a Admin) IsNobodyAdmin() bool

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

func (Admin) String

func (a Admin) String() string

type AdminAPI

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

AdminAPI implements AdminRepository

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 Client

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

func NewClient(appID, apiKey string) *Client

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

func NewClientWithHTTPClient

func NewClientWithHTTPClient(appID, apiKey string, httpClient interfaces.HTTPClient) *Client

NewClientWithHTTPClient returns a new Intercom API client, configured with the supplied HTTPClient interface

func (*Client) Option

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

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

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,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

func (c Company) String() string

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 `json:"data,omitempty"`
	ScrollParam string    `json:"scroll_param,omitempty"`
}

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) ListUsersByCompanyID

func (c *CompanyService) ListUsersByCompanyID(companyID string, params PageParams) (UserList, error)

List Company Users by CompanyID

func (*CompanyService) ListUsersByID

func (c *CompanyService) ListUsersByID(id string, params PageParams) (UserList, error)

List Company Users by ID

func (*CompanyService) Save

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

Save a new Company, or update an existing one.

func (*CompanyService) Scroll

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

List all Companies for App via Scroll API

type Contact

type Contact struct {
	Type        string `json:"type,omitempty"`
	ID          string `json:"id,omitempty"`
	WorkspaceID string `json:"workspace_id,omitempty"`
	ExternalID  string `json:"external_id,omitempty"`

	Email                  string                 `json:"email,omitempty"`
	Phone                  string                 `json:"phone,omitempty"`
	Name                   string                 `json:"name,omitempty"`
	Avatar                 string                 `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"`
	Location               *ContactLocation       `json:"location,omitempty"`
	AndroidAppName         string                 `json:"android_app_name,omitempty"`
	AndroidAppVersion      string                 `json:"android_app_version,omitempty"`
	AndroidDevice          string                 `json:"android_device,omitempty"`
	AndroidOSVersion       string                 `json:"android_os_version,omitempty"`
	AndroidSDKVersion      string                 `json:"android_sdk_version,omitempty"`
	AndroidLastSeenAt      int64                  `json:"android_last_seen_at,omitempty"`
	IOSAppName             string                 `json:"ios_app_name,omitempty"`
	IOSAppVersion          string                 `json:"ios_app_version,omitempty"`
	IOSDevice              string                 `json:"ios_device,omitempty"`
	IOSOSVersion           string                 `json:"ios_os_version,omitempty"`
	IOSSDKVersion          string                 `json:"ios_sdk_version,omitempty"`
	IOSLastSeenAt          int64                  `json:"ios_last_seen_at,omitempty"`
	CustomAttributes       map[string]interface{} `json:"custom_attributes,omitempty"`
	Tags                   *AddressableList       `json:"tags,omitempty"`
	Notes                  *AddressableList       `json:"notes,omitempty"`
	Companies              *AddressableList       `json:"companies,omitempty"`
	// contains filtered or unexported fields
}

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

func (c Contact) MessageAddress() MessageAddress

MessageAddress gets the address for a Contact in order to message them

func (Contact) String

func (c Contact) String() string

type ContactAPI

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

ContactAPI implements ContactRepository

type ContactList

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

ContactList holds a list of Contacts and paging information

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"`
}

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) Convert

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

Convert Contact to User

func (*ContactService) Create

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

Create Contact

func (*ContactService) Delete

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

Delete Contact

func (*ContactService) FindByID

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

FindByID looks up a Contact by their Intercom ID.

func (*ContactService) FindByUserID

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

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

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) ListBySegment

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

List Contacts by Segment.

func (*ContactService) ListByTag

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

List Contacts By Tag.

func (*ContactService) Scroll

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

List all Contacts for App via Scroll API

func (*ContactService) Update

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

Update Contact

type Conversation

type Conversation struct {
	Type               string                  `json:"type"`
	ID                 string                  `json:"id"`
	CreatedAt          int64                   `json:"created_at"`
	UpdatedAt          int64                   `json:"updated_at"`
	WaitingSince       int64                   `json:"waiting_since"`
	SnoozedUntil       int64                   `json:"snoozed_until"`
	Source             Source                  `json:source""`
	Contacts           ConversationContactList `json:"contacts"`
	FirstContactReply  FirstContactReply       `json:"first_contact_reply"`
	AdminAssigneeID    int64                   `json:"admin_assignee_id"`
	TeamAssigneeID     string                  `json:"team_assignee_id"`
	Open               bool                    `json:"open"`
	Read               bool                    `json:"read"`
	Tags               ConversationTagList     `json:"tags"`
	Priority           string                  `json:"priority"`
	SLAApplied         SLAApplied              `json:"sla_applied"`
	Statistics         ConversationStatistics  `json:"statistics"`
	ConversationRating ConversationRating      `json:"conversation_rating"`
	Teammates          ConversationTeammate    `json:"teammates"`
	Title              string                  `json:"title"`
	CustomAttributes   map[string]interface{}  `json:"custom_attributes"`
}

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

func (Conversation) String

func (c Conversation) String() string

type ConversationAPI

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

ConversationAPI implements ConversationRepository

type ConversationContactList

type ConversationContactList struct {
	Type     string                   `json:"type"`
	Contacts []ConversationContactObj `json:"contacts"`
}

ConversationContactList ...

type ConversationContactObj

type ConversationContactObj struct {
	Type string `json:"type"`
	ID   string `json:"id"`
}

ConversationContactObj ...

type ConversationList

type ConversationList struct {
	Pages         PageParams     `json:"pages"`
	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"`
	UserID         string `url:"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 User 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 ConversationRating

type ConversationRating struct {
	Rating    int32                  `json:"rating"`
	Remark    string                 `json:"remark"`
	CreatedAt int64                  `json:"created_at"`
	Contact   map[string]interface{} `json:"contact"`
	Teammate  map[string]interface{} `json:"teammate"`
}

ConversationRating ...

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

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) ListByUser

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

List Conversations by User

func (*ConversationService) MarkRead

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

Mark Conversation as read (by a User)

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 ConversationStatistics

type ConversationStatistics struct {
	TimeToAssignment           int64                  `json:"time_to_assignment"`
	TimeToAdminReply           int64                  `json:"time_to_admin_reply"`
	TimeToFirstClose           int64                  `json:"time_to_first_close"`
	TimeToLastClose            int64                  `json:"time_to_last_close"`
	MedianTimeToReply          int64                  `json:"median_time_to_reply"`
	FirstContactReplyAt        int64                  `json:"first_contact_reply_at"`
	FirstAssignmentAt          int64                  `json:"first_assignment_at"`
	FirstAdminReplyAt          int64                  `json:"first_admin_reply_at"`
	FirstCloseAt               int64                  `json:"first_close_at"`
	LastAssignmentAt           int64                  `json:"last_assignment_at"`
	LastAssignmentAdminReplyAt int64                  `json:"last_assignment_admin_reply_at"`
	LastContactReplyAt         int64                  `json:"last_contact_reply_at"`
	LastAdminReplyAt           int64                  `json:"last_admin_reply_at"`
	LastCloseAt                int64                  `json:"last_close_at"`
	LastClosedBy               map[string]interface{} `json:"last_closed_by"`
	CountReopens               int64                  `json:"count_reopens"`
	CountAssignments           int64                  `json:"count_assignments"`
	CountConversationsParts    int64                  `json:"count_conversations_parts"`
}

ConversationStatistics ...

type ConversationTagList

type ConversationTagList struct {
	Type string               `json:"type"`
	Tags []ConversationTagObj `json:"tags"`
}

ConversationTagList ...

type ConversationTagObj

type ConversationTagObj struct {
	Type string `json:"type"`
	ID   string `json:"id"`
	Name string `json:"name"`
}

ConversationTagObj ...

type ConversationTeammate

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

ConversationTeammate ...

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.

func (Event) String

func (e Event) String() string

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.

func (*EventService) Save

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

Save a new Event

type FirstContactReply

type FirstContactReply struct {
	Type      string `json:"type"`
	URL       string `json:"url"`
	CreatedAt int64  `json:"created_at"`
}

FirstContactReply ...

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 NewEventJobItem

func NewEventJobItem(event *Event) *JobItem

NewEventJobItem creates a JobItem that holds an Event.

func NewUserJobItem

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

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 JobState

type JobState int

The state of a Job

const (
	PENDING JobState = iota
	RUNNING
	COMPLETED
	FAILED
)

func (JobState) String

func (state JobState) String() string

type LocationData

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

func (l LocationData) String() string

type MessageAPI

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

MessageAPI implements MessageRepository

type MessageAddress

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

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

func NewUserMessage

func NewUserMessage(from MessagePerson, body string) MessageRequest

NewUserMessage creates a new *Message from a User.

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

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 Users or 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:"-"`
	User             *User         `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 Plan

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

The Plan a Company is on

func (Plan) String

func (p Plan) String() string

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

A Reply to an Intercom conversation

type ReplyType

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

func (reply ReplyType) String() string

type RequestUserMapper

type RequestUserMapper struct{}

func (RequestUserMapper) ConvertUser

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

func (RequestUserMapper) MakeUserCompaniesFromCompanies

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

type SLAApplied

type SLAApplied struct {
	SLAName   string `json:"sla_name"`
	SLAStatus string `json:"sla_status"`
}

SLAApplied ...

type Segment

type Segment struct {
	Type       string `json:"type,omitempty"`
	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

func (s Segment) String() string

type SegmentAPI

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

SegmentAPI implements SegmentRepository

type SegmentList

type SegmentList struct {
	Type     string    `json:"type,omitempty"`
	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 User.

func (SocialProfile) String

func (s SocialProfile) String() string

type SocialProfileList

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

SocialProfile list is a list of SocialProfiles for a User.

type Source

type Source struct {
	Type        string       `json:"type"`
	ID          string       `json:"id"`
	DeliveredAs string       `json:"delivered_as"`
	Subject     string       `json:"subject"`
	Body        string       `json:"body"`
	Author      SourceAuthor `json:"author"`
	// Attachments map[string]interface{} `json:"attachments"`
	URL string `json:"url"`
}

Source ...

type SourceAuthor

type SourceAuthor struct {
	Type string `json:"type"`
	ID   string `json:"id"`
}

SourceAuthor ...

type Tag

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

Tag represents an Tag in Intercom.

func (Tag) String

func (t Tag) String() string

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) Delete

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

Delete a Tag

func (*TagService) List

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

List all Tags for the App

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 User

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

func (u User) MessageAddress() MessageAddress

MessageAddress gets the address for an User in order to message them

func (User) String

func (u User) String() string

type UserAPI

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

UserAPI implements UserRepository

type UserAvatar

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

UserAvatar represents an avatar for a User.

func (UserAvatar) String

func (a UserAvatar) String() string

type UserCompany

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

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

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

UserList holds a list of Users and paging information

type UserRepository

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

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

type UserService

type UserService struct {
	Repository UserRepository
}

UserService handles interactions with the API through a UserRepository.

func (*UserService) Delete

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

func (*UserService) FindByEmail

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

FindByEmail looks up a User by their Email.

func (*UserService) FindByID

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

FindByID looks up a User by their Intercom ID.

func (*UserService) FindByUserID

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

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

func (*UserService) List

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

List all Users for App.

func (*UserService) ListBySegment

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

List Users by Segment.

func (*UserService) ListByTag

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

List Users By Tag.

func (*UserService) Save

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

Save a User, creating or updating them.

func (*UserService) Scroll

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

List all Users for App via Scroll API

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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