Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

oohira/intercom-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

intercom-java

A Java client library for Intercom web service. This is just a tiny wrapper around Intercom API v1, please see Intercom API Documentation for detail.

Build Status

ATTENTION

Intercom API v1 was deprecated. You can use an official Java library for Intercom API v2.

The V1 API is deprecated as of June 17th 2014, and no longer available for new apps after 15th January 2015.

Deprecation means the V1 API and its clients are no longer actively developed. The V1 API will be retired in the future. As a result we recommend and encourage you to move to the new Intercom API, which is actively supported and developed. The new Intercom API can be considered a superset of the V1 API - as well as matching its functionality, it provides a wealth of other data and operations.

Installation

<dependency>
   <groupId>com.github.oohira</groupId>
   <artifactId>intercom-java</artifactId>
   <version>0.0.4</version>
</dependency>

Dependencies

License

This software is released under the MIT License, see LICENSE.txt.

Usage

Initialization

Intercom intercom = new Intercom("APP_ID", "API_KEY");

Users

User user = new User();
user.setUserId("abc123");
user.setEmail("john.doe@example.com");
user.setName("John Doe");
Company company = new Company();
company.setId("company1");
company.setName("Anonymous Company");
user.setCompanies(new Company[]{company});
intercom.createUser(user);
User user = intercom.getUserById("abc123");
Map<String, Object> customData = new LinkedHashMap<String, Object>();
customData.put("custom_data_1", "test");
customData.put("custom_data_2", 7);
user.setCustomData(customData);
intercom.updateUser(user);
for (User user : intercom.getUsers()) {
    // do something
}

Tags

Tag tag = intercom.getTag("Free Trial");
tag.setUserIds(new String[]{"abc123", "def456"});
tag.setTagOrUntag("tag");
intercom.updateTag(tag);
Tag tag = intercom.getTag("Free Trial");
tag.setUserIds(new String[]{"abc123"});
tag.setTagOrUntag("untag");
intercom.updateTag(tag);

Notes

Note note = new Note();
note.setEmail("john.doe@example.com");
note.setBody("This is the text of my note.");
intercom.createNote(note);

Impressions

Impression impression = new Impression();
impression.setUserId("abc123");
impression.setUserIp("127.0.0.1");
intercom.createImpression(impression);

Events

Event event = new Event();
event.setEventName("invited-friend");
event.setUserId("abc123");
event.setCreatedAt(new Date());
Map<String, Object> metadata = new LinkedHashMap<String, Object>();
metadata.put("invitee_email", "jane.doe@example.com");
metadata.put("invite_code", "ADDAFRIEND");
event.setMetadata(metadata);
intercom.trackEvent(event);

Limitations

  • Message Threads API is not supported yet. Now implementing.