File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1101,6 +1101,14 @@ const response = await client.segments.list({
11011101});
11021102```
11031103
1104+
1105+ ### Subscriptions
1106+
1107+ #### [ List all subscription types] ( https://developers.intercom.com/intercom-api-reference/reference/list-all-subscription-types )
1108+
1109+ ``` typescript
1110+ const response = await client .subscriptions .listTypes ();
1111+ ```
11041112### PhoneCallRedirects
11051113
11061114#### [ Create a phone call redirect] ( https://developers.intercom.com/intercom-api-reference/reference/create-a-phone-switch )
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import HelpCenter from './helpCenter';
1414import Message from './message' ;
1515import Note from './note' ;
1616import Segment from './segment' ;
17+ import Subscription from './subscription' ;
1718import Team from './team' ;
1819import Tag from './tag' ;
1920import Visitor from './visitor' ;
@@ -66,6 +67,7 @@ export default class Client {
6667 messages : Message ;
6768 notes : Note ;
6869 segments : Segment ;
70+ subscriptions : Subscription ;
6971 passwordPart ?: string ;
7072 propertiesToOmitInRequestOpts : string [ ] ;
7173 requestOpts : Partial < AxiosDefaults > ;
@@ -100,6 +102,7 @@ export default class Client {
100102 this . messages = new Message ( this ) ;
101103 this . notes = new Note ( this ) ;
102104 this . segments = new Segment ( this ) ;
105+ this . subscriptions = new Subscription ( this ) ;
103106 this . tags = new Tag ( this ) ;
104107 this . teams = new Team ( this ) ;
105108 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