File tree Expand file tree Collapse file tree 5 files changed +64
-2
lines changed
Expand file tree Collapse file tree 5 files changed +64
-2
lines changed Original file line number Diff line number Diff line change @@ -82,8 +82,8 @@ If you are using the european instance of intercom and would like to call it dir
8282``` typescript
8383const client = new Client ({ tokenAuth: { token: ' my_token' } });
8484client .useRequestOpts ({
85- baseUrl: ' https://api.eu.intercom.io'
86- })
85+ baseUrl: ' https://api.eu.intercom.io' ,
86+ });
8787```
8888
8989## Examples
@@ -1078,6 +1078,14 @@ const response = await client.segments.list({
10781078});
10791079```
10801080
1081+ ### Subscriptions
1082+
1083+ #### [ List all subscription types] ( https://developers.intercom.com/intercom-api-reference/reference/list-all-subscription-types )
1084+
1085+ ``` typescript
1086+ const response = await client .subscriptions .listTypes ();
1087+ ```
1088+
10811089### Tags
10821090
10831091#### [ Create or update a tag] ( https://developers.intercom.com/intercom-api-reference/reference/create-and-update-tags )
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import HelpCenter from './helpCenter';
1313import Message from './message' ;
1414import Note from './note' ;
1515import Segment from './segment' ;
16+ import Subscription from './subscription' ;
1617import Team from './team' ;
1718import Tag from './tag' ;
1819import Visitor from './visitor' ;
@@ -63,6 +64,7 @@ export default class Client {
6364 messages : Message ;
6465 notes : Note ;
6566 segments : Segment ;
67+ subscriptions : Subscription ;
6668 passwordPart ?: string ;
6769 propertiesToOmitInRequestOpts : string [ ] ;
6870 requestOpts : Partial < AxiosDefaults > ;
@@ -95,6 +97,7 @@ export default class Client {
9597 this . messages = new Message ( this ) ;
9698 this . notes = new Note ( this ) ;
9799 this . segments = new Segment ( this ) ;
100+ this . subscriptions = new Subscription ( this ) ;
98101 this . tags = new Tag ( this ) ;
99102 this . teams = new Team ( this ) ;
100103 this . visitors = new Visitor ( this ) ;
Original file line number Diff line number Diff line change 1+ import { Client } from '.' ;
2+ import { SubscriptionObject } from './subscription/subscription.types' ;
3+
4+ export default class Subscription {
5+ public readonly baseUrl = 'subscription_types' ;
6+
7+ constructor ( private readonly client : Client ) {
8+ this . client = client ;
9+ }
10+ listTypes ( ) {
11+ return this . client . get < ListResponse > ( {
12+ url : `/${ this . baseUrl } ` ,
13+ } ) ;
14+ }
15+ }
16+
17+ interface ListResponse {
18+ type : 'list' ;
19+ data : SubscriptionObject [ ] ;
20+ }
Original file line number Diff line number Diff line change 1+ import { Client } from '../../dist' ;
2+ import assert from 'assert' ;
3+ import { token } from './utils/config' ;
4+
5+ describe ( 'Subscriptions' , ( ) => {
6+ const client = new Client ( { tokenAuth : { token } } ) ;
7+
8+ it ( 'listTypes' , async ( ) => {
9+ const response = await client . subscriptions . listTypes ( ) ;
10+
11+ assert . notEqual ( response , undefined ) ;
12+ } ) ;
13+ } ) ;
Original file line number Diff line number Diff line change 1+ import assert from 'assert' ;
2+ import { Client } from '../../lib' ;
3+ import nock from 'nock' ;
4+
5+ describe ( 'subscriptions' , ( ) => {
6+ const client = new Client ( {
7+ usernameAuth : { username : 'foo' , password : 'bar' } ,
8+ } ) ;
9+
10+ it ( 'should be listed' , async ( ) => {
11+ nock ( 'https://api.intercom.io' )
12+ . get ( '/subscription_types' )
13+ . reply ( 200 , { type : 'list' , data : [ ] } ) ;
14+ const response = await client . subscriptions . listTypes ( ) ;
15+
16+ assert . deepStrictEqual ( { type : 'list' , data : [ ] } , response ) ;
17+ } ) ;
18+ } ) ;
You can’t perform that action at this time.
0 commit comments