File tree Expand file tree Collapse file tree 11 files changed +176
-13
lines changed
Expand file tree Collapse file tree 11 files changed +176
-13
lines changed Original file line number Diff line number Diff line change @@ -948,6 +948,34 @@ const response = await client.messages.create({
948948});
949949```
950950
951+ ### Notes
952+
953+ #### [ Create a note] ( https://developers.intercom.com/intercom-api-reference/reference/create-note-for-contact )
954+
955+ ``` typescript
956+ const response = await client .notes .create ({
957+ adminId: ' 12345' ,
958+ body: ' Shiny' ,
959+ contactId: ' 5678' ,
960+ });
961+ ```
962+
963+ #### [ Retrieve a note] ( https://developers.intercom.com/intercom-api-reference/reference/view-a-note )
964+
965+ ``` typescript
966+ const response = await client .notes .find ({ id: ' 123' });
967+ ```
968+
969+ #### [ List all notes] ( https://developers.intercom.com/intercom-api-reference/reference/list-notes-of-contact )
970+
971+ ``` typescript
972+ const response = await client .notes .list ({
973+ contactId: ' 123' ,
974+ page: 2 ,
975+ perPage: 3 ,
976+ });
977+ ```
978+
951979### Segments
952980
953981#### [ Retrieve a segment] ( https://developers.intercom.com/intercom-api-reference/reference/view-a-segment )
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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
812export 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-
106106type ArticleFindByIdData = OperationById ;
107107
108108type UpdateArticleData = Partial < CreateArticleData > & OperationById ;
Original file line number Diff line number Diff line change @@ -10,8 +10,9 @@ import Contact from './contact';
1010import DataAttribute from './dataAttribute' ;
1111import Event from './event' ;
1212import HelpCenter from './helpCenter' ;
13- import Segment from './segment' ;
1413import Message from './message' ;
14+ import Note from './note' ;
15+ import Segment from './segment' ;
1516import Team from './team' ;
1617import Tag from './tag' ;
1718import Visitor from './visitor' ;
@@ -59,6 +60,7 @@ export default class Client {
5960 events : Event ;
6061 helpCenter : HelpCenter ;
6162 messages : Message ;
63+ notes : Note ;
6264 segments : Segment ;
6365 passwordPart ?: string ;
6466 propertiesToOmitInRequestOpts : string [ ] ;
@@ -90,6 +92,7 @@ export default class Client {
9092 this . events = new Event ( this ) ;
9193 this . helpCenter = new HelpCenter ( this ) ;
9294 this . messages = new Message ( this ) ;
95+ this . notes = new Note ( this ) ;
9396 this . segments = new Segment ( this ) ;
9497 this . tags = new Tag ( this ) ;
9598 this . teams = new Team ( this ) ;
Original file line number Diff line number Diff 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+ }
Original file line number Diff line number Diff line change 11import { Client } from '.' ;
2- import { GenericDeletedResponse , Paginated } from './common/common.types' ;
2+ import {
3+ GenericDeletedResponse ,
4+ OperationById ,
5+ Paginated ,
6+ } from './common/common.types' ;
37import {
48 CollectionObject ,
59 GroupTranslatedContentObject ,
@@ -165,7 +169,3 @@ type SectionListData = {
165169} ;
166170
167171type SectionListResponse = Paginated < SectionObject > ;
168-
169- interface OperationById {
170- id : string ;
171- }
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ export * from './dataAttribute/dataAttribute.types';
3434export * from './event/event.types' ;
3535export * from './helpCenter/helpCenter.types' ;
3636export * from './message/message.types' ;
37+ export * from './note/note.types' ;
3738export * from './segment/segment.types' ;
3839export * from './subscription/subscription.types' ;
3940export * from './tag/tag.types' ;
Original file line number Diff line number Diff line change 1+ import { Client , NoteObject } from '.' ;
2+ import { OperationById , Paginated } from './common/common.types' ;
3+
4+ export default class Note {
5+ public readonly baseUrl = 'notes' ;
6+
7+ constructor ( private readonly client : Client ) {
8+ this . client = client ;
9+ }
10+
11+ create ( { adminId, body, contactId } : CreateNoteData ) {
12+ const data = {
13+ admin_id : adminId ,
14+ body,
15+ } ;
16+
17+ return this . client . post < NoteObject > ( {
18+ url : `/${ this . client . contacts . baseUrl } /${ contactId } /${ this . baseUrl } ` ,
19+ data,
20+ } ) ;
21+ }
22+ find ( { id } : FindNoteByIdData ) {
23+ return this . client . get < NoteObject > ( {
24+ url : `/${ this . baseUrl } /${ id } ` ,
25+ } ) ;
26+ }
27+ list ( { contactId, page, perPage : per_page } : ListNotesData ) {
28+ const params = {
29+ page,
30+ per_page,
31+ } ;
32+
33+ return this . client . get < ListNotesResponse > ( {
34+ url : `/${ this . client . contacts . baseUrl } /${ contactId } /${ this . baseUrl } ` ,
35+ params,
36+ } ) ;
37+ }
38+ }
39+
40+ interface CreateNoteData {
41+ adminId : string ;
42+ body : string ;
43+ contactId : string ;
44+ }
45+
46+ type FindNoteByIdData = OperationById ;
47+
48+ type ListNotesData = {
49+ contactId : string ;
50+ page ?: number ;
51+ perPage ?: number ;
52+ } ;
53+
54+ type ListNotesResponse = Paginated < NoteObject > ;
Original file line number Diff line number Diff line change 1+ import { AdminObject , Timestamp } from '..' ;
2+
3+ export type NoteObject = {
4+ type : 'note' ;
5+ id : string ;
6+ created_at : Timestamp ;
7+ contact : {
8+ type : 'contact' ;
9+ id : string ;
10+ } ;
11+ author ?: Pick <
12+ AdminObject ,
13+ | 'type'
14+ | 'id'
15+ | 'name'
16+ | 'email'
17+ | 'away_mode_enabled'
18+ | 'away_mode_reassign'
19+ | 'avatar'
20+ > ;
21+ body : string ;
22+ } ;
Original file line number Diff line number Diff line change 11{
22 "name" : " intercom-client" ,
3- "version" : " 3.0.1 " ,
3+ "version" : " 3.1.0 " ,
44 "description" : " Official Node bindings to the Intercom API" ,
55 "homepage" : " https://github.com/intercom/intercom-node" ,
66 "bugs:" : " https://github.com/intercom/intercom-node/issues" ,
You can’t perform that action at this time.
0 commit comments