Skip to content

Commit fccdf60

Browse files
authored
Merge pull request #303 from intercom/3.1.0
3.1.0 Release
2 parents c26cbf8 + 3de4949 commit fccdf60

File tree

17 files changed

+752
-20
lines changed

17 files changed

+752
-20
lines changed

README.md

Lines changed: 138 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ const article = await client.articles.create({
128128
title: 'Allez les verts',
129129
description: 'French description',
130130
body: '<p>French body in html</p>',
131-
authorId: 1,
131+
author_id: 1,
132132
state: 'published',
133133
},
134134
},
@@ -158,7 +158,7 @@ const article = await client.articles.update({
158158
title: 'Allez les verts',
159159
description: 'French description',
160160
body: '<p>French body in html</p>',
161-
authorId: 1,
161+
author_id: 1,
162162
state: 'published',
163163
},
164164
},
@@ -746,6 +746,62 @@ const response = await client.conversations.redactConversationPart({
746746
});
747747
```
748748

749+
### Counts
750+
751+
#### [App Total Count](https://developers.intercom.com/intercom-api-reference/reference/company-user-counts)
752+
753+
```typescript
754+
const response = await client.counts.forApp();
755+
```
756+
757+
#### [Conversation Count Model](https://developers.intercom.com/intercom-api-reference/reference/conversation-counts)
758+
759+
```typescript
760+
const response = await client.counts.countConversation();
761+
```
762+
763+
#### [Admin Conversation Count Model](https://developers.intercom.com/intercom-api-reference/reference/admin-conversations)
764+
765+
```typescript
766+
const response = await client.counts.countAdminConversation();
767+
```
768+
769+
#### [User Segment/Tag Count Model](https://developers.intercom.com/intercom-api-reference/reference/user-tag-counts)
770+
771+
##### Count User Segment
772+
773+
```typescript
774+
const response = await client.counts.countUserSegment();
775+
```
776+
777+
##### Count User Tag
778+
779+
```typescript
780+
const response = await client.counts.countUserTag();
781+
```
782+
783+
#### [Company User/Segment/Tag Count Model](https://developers.intercom.com/intercom-api-reference/reference/company-tag-counts)
784+
785+
##### Count Company Segment
786+
787+
```typescript
788+
const response = await client.counts.countCompanySegment();
789+
const response = await client.counts.countCompanyTag();
790+
const response = await client.counts.countCompanyUser();
791+
```
792+
793+
##### Count Company Tag
794+
795+
```typescript
796+
const response = await client.counts.countCompanyTag();
797+
```
798+
799+
##### Count Company User
800+
801+
```typescript
802+
const response = await client.counts.countCompanyUser();
803+
```
804+
749805
### Data Attributes
750806

751807
#### [Create Data Attribute](https://developers.intercom.com/intercom-api-reference/reference/create-data-attributes)
@@ -845,7 +901,7 @@ const article = await client.helpCenter.collections.update({
845901
id: '123',
846902
name: 'Thanks for everything',
847903
description: 'English description',
848-
translatedContent: {
904+
translated_content: {
849905
fr: {
850906
name: 'Allez les verts',
851907
description: 'French description',
@@ -878,7 +934,7 @@ const response = client.helpCenter.collections.list({
878934
```typescript
879935
const collection = await client.helpCenter.sections.create({
880936
name: 'Thanks for everything',
881-
parentId: '1234',
937+
parent_id: '1234',
882938
translatedContent: {
883939
fr: {
884940
name: 'Allez les verts',
@@ -900,8 +956,8 @@ const response = await client.helpCenter.sections.find({ id: '123' });
900956
const article = await client.helpCenter.sections.update({
901957
id: '123',
902958
name: 'Thanks for everything',
903-
parentId: '456',
904-
translatedContent: {
959+
parent_id: '456',
960+
translated_content: {
905961
fr: {
906962
name: 'Allez les verts',
907963
description: 'French description',
@@ -948,6 +1004,34 @@ const response = await client.messages.create({
9481004
});
9491005
```
9501006

1007+
### Notes
1008+
1009+
#### [Create a note](https://developers.intercom.com/intercom-api-reference/reference/create-note-for-contact)
1010+
1011+
```typescript
1012+
const response = await client.notes.create({
1013+
adminId: '12345',
1014+
body: 'Shiny',
1015+
contactId: '5678',
1016+
});
1017+
```
1018+
1019+
#### [Retrieve a note](https://developers.intercom.com/intercom-api-reference/reference/view-a-note)
1020+
1021+
```typescript
1022+
const response = await client.notes.find({ id: '123' });
1023+
```
1024+
1025+
#### [List all notes](https://developers.intercom.com/intercom-api-reference/reference/list-notes-of-contact)
1026+
1027+
```typescript
1028+
const response = await client.notes.list({
1029+
contactId: '123',
1030+
page: 2,
1031+
perPage: 3,
1032+
});
1033+
```
1034+
9511035
### Segments
9521036

9531037
#### [Retrieve a segment](https://developers.intercom.com/intercom-api-reference/reference/view-a-segment)
@@ -1067,6 +1151,54 @@ const response = await client.teams.find({
10671151
const response = await client.teams.list();
10681152
```
10691153

1154+
### Visitors
1155+
1156+
#### [Retrieve a Visitor](https://developers.intercom.com/intercom-api-reference/reference/view-a-visitor)
1157+
1158+
```typescript
1159+
const response = await client.visitors.find({ id: '123' });
1160+
```
1161+
1162+
OR
1163+
1164+
```typescript
1165+
const response = await client.visitors.find({ userId: '123' });
1166+
```
1167+
1168+
#### [Update a Visitor](https://developers.intercom.com/intercom-api-reference/reference/update-a-visitor)
1169+
1170+
```typescript
1171+
const response = await client.visitors.update({
1172+
userId: '123',
1173+
name: 'anonymous bruh',
1174+
customAttributes: {
1175+
paid_subscriber: true,
1176+
},
1177+
});
1178+
```
1179+
1180+
#### [Delete a Visitor](https://developers.intercom.com/intercom-api-reference/reference/delete-a-visitor)
1181+
1182+
```typescript
1183+
const response = await client.visitors.delete({
1184+
id,
1185+
});
1186+
```
1187+
1188+
#### [Convert a Visitor](https://developers.intercom.com/intercom-api-reference/reference/convert-a-visitor-to-a-user)
1189+
1190+
```typescript
1191+
const response = await client.visitors.mergeToContact({
1192+
visitor: {
1193+
id: '123',
1194+
},
1195+
user: {
1196+
userId: '123',
1197+
},
1198+
type: Role.USER,
1199+
});
1200+
```
1201+
10701202
### Identity verification
10711203

10721204
`intercom-node` provides a helper for using [identity verification](https://docs.intercom.com/configure-intercom-for-your-product-or-site/staying-secure/enable-identity-verification-on-your-web-product):

lib/admin/admin.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ export interface AdminObject {
88
away_mode_reassign: boolean;
99
has_inbox_seat: boolean;
1010
team_ids: Array<number>;
11-
avatar: string;
11+
avatar: string | { image_url: string };
1212
}

lib/article.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import {
33
ArticleObject,
44
TranslatedContentObject,
55
} from './article/article.types';
6-
import { GenericDeletedResponse, Paginated } from './common/common.types';
6+
import {
7+
GenericDeletedResponse,
8+
OperationById,
9+
Paginated,
10+
} from './common/common.types';
711

812
export default class Article {
913
public readonly baseUrl = 'articles';
@@ -99,10 +103,6 @@ interface CreateArticleData {
99103
translatedContent?: Omit<TranslatedContentObject, 'type'>;
100104
}
101105

102-
interface OperationById {
103-
id: string;
104-
}
105-
106106
type ArticleFindByIdData = OperationById;
107107

108108
type UpdateArticleData = Partial<CreateArticleData> & OperationById;

lib/client.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@ import { merge, omit } from 'lodash';
55
import Article from './article';
66
import Admin from './admin';
77
import Company from './company';
8-
import Conversation from './conversation';
98
import Contact from './contact';
9+
import Conversation from './conversation';
10+
import Count from './count';
1011
import DataAttribute from './dataAttribute';
1112
import Event from './event';
1213
import HelpCenter from './helpCenter';
13-
import Segment from './segment';
1414
import Message from './message';
15+
import Note from './note';
16+
import Segment from './segment';
1517
import Team from './team';
1618
import Tag from './tag';
19+
import Visitor from './visitor';
1720

1821
import * as packageJson from '../package.json';
1922

@@ -54,10 +57,12 @@ export default class Client {
5457
companies: Company;
5558
contacts: Contact;
5659
conversations: Conversation;
60+
counts: Count;
5761
dataAttributes: DataAttribute;
5862
events: Event;
5963
helpCenter: HelpCenter;
6064
messages: Message;
65+
notes: Note;
6166
segments: Segment;
6267
passwordPart?: string;
6368
propertiesToOmitInRequestOpts: string[];
@@ -66,6 +71,7 @@ export default class Client {
6671
teams: Team;
6772
usebaseURL: (baseURL: string) => this;
6873
usernamePart?: string;
74+
visitors: Visitor;
6975

7076
constructor(args: Constructor) {
7177
const [usernamePart, passwordPart] = Client.getAuthDetails(args);
@@ -84,13 +90,16 @@ export default class Client {
8490
this.companies = new Company(this);
8591
this.contacts = new Contact(this);
8692
this.conversations = new Conversation(this);
93+
this.counts = new Count(this);
8794
this.dataAttributes = new DataAttribute(this);
8895
this.events = new Event(this);
8996
this.helpCenter = new HelpCenter(this);
9097
this.messages = new Message(this);
98+
this.notes = new Note(this);
9199
this.segments = new Segment(this);
92100
this.tags = new Tag(this);
93101
this.teams = new Team(this);
102+
this.visitors = new Visitor(this);
94103
this.requestOpts = {
95104
baseURL: 'https://api.intercom.io',
96105
};

lib/common/common.types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,7 @@ export interface GenericDeletedResponse<ObjectType extends string> {
6969
object: ObjectType;
7070
deleted: boolean;
7171
}
72+
73+
export interface OperationById {
74+
id: string;
75+
}

lib/count.ts

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import {
2+
Client,
3+
CompanySegmentCountResponse,
4+
CompanyTagCountResponse,
5+
CompanyUserCountResponse,
6+
UserCountResponse,
7+
UserSegmentCountResponse,
8+
UserTagCountResponse,
9+
} from '.';
10+
import {
11+
AdminConversationCountResponse,
12+
AppTotalCountResponse,
13+
CompanyCountResponse,
14+
ConversationCountResponse,
15+
CountEntity,
16+
CountType,
17+
} from './count/count.types';
18+
19+
export default class Count {
20+
public readonly baseUrl = 'counts';
21+
22+
constructor(private readonly client: Client) {
23+
this.client = client;
24+
}
25+
26+
forApp() {
27+
return this.client.get<AppTotalCountResponse>({
28+
url: `/${this.baseUrl}`,
29+
});
30+
}
31+
32+
countCompany() {
33+
return this.client.get<CompanyCountResponse>({
34+
url: `/${this.baseUrl}`,
35+
params: { type: CountType.COMPANY },
36+
});
37+
}
38+
countCompanySegment() {
39+
return this.client.get<CompanySegmentCountResponse>({
40+
url: `/${this.baseUrl}`,
41+
params: { type: CountType.COMPANY, count: CountEntity.SEGMENT },
42+
});
43+
}
44+
countCompanyTag() {
45+
return this.client.get<CompanyTagCountResponse>({
46+
url: `/${this.baseUrl}`,
47+
params: { type: CountType.COMPANY, count: CountEntity.TAG },
48+
});
49+
}
50+
countCompanyUser() {
51+
return this.client.get<CompanyUserCountResponse>({
52+
url: `/${this.baseUrl}`,
53+
params: { type: CountType.COMPANY, count: CountEntity.USER },
54+
});
55+
}
56+
countConversation() {
57+
return this.client.get<ConversationCountResponse>({
58+
url: `/${this.baseUrl}`,
59+
params: { type: CountType.CONVERSATION },
60+
});
61+
}
62+
countAdminConversation() {
63+
return this.client.get<AdminConversationCountResponse>({
64+
url: `/${this.baseUrl}`,
65+
params: { type: CountType.CONVERSATION, count: CountEntity.ADMIN },
66+
});
67+
}
68+
countUser() {
69+
return this.client.get<UserCountResponse>({
70+
url: `/${this.baseUrl}`,
71+
params: { type: CountType.USER },
72+
});
73+
}
74+
countUserSegment() {
75+
return this.client.get<UserSegmentCountResponse>({
76+
url: `/${this.baseUrl}`,
77+
params: { type: CountType.USER, count: CountEntity.SEGMENT },
78+
});
79+
}
80+
countUserTag() {
81+
return this.client.get<UserTagCountResponse>({
82+
url: `/${this.baseUrl}`,
83+
params: { type: CountType.USER, count: CountEntity.TAG },
84+
});
85+
}
86+
}

0 commit comments

Comments
 (0)