Skip to content

Commit 8768954

Browse files
committed
feat(api): update via SDK Studio
1 parent 8470cf4 commit 8768954

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import Intercom from 'intercom';
2424

2525
const intercom = new Intercom({
2626
accessToken: process.env['INTERCOM_ACCESS_TOKEN'], // This is the default and can be omitted
27-
environment: 'environment_1', // or 'production' | 'environment_2'; defaults to 'production'
27+
environment: 'eu', // or 'us' | 'au'; defaults to 'us'
2828
});
2929

3030
async function main() {
@@ -46,7 +46,7 @@ import Intercom from 'intercom';
4646

4747
const intercom = new Intercom({
4848
accessToken: process.env['INTERCOM_ACCESS_TOKEN'], // This is the default and can be omitted
49-
environment: 'environment_1', // or 'production' | 'environment_2'; defaults to 'production'
49+
environment: 'eu', // or 'us' | 'au'; defaults to 'us'
5050
});
5151

5252
async function main() {

src/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import * as qs from 'qs';
88
import * as API from './resources/index';
99

1010
const environments = {
11-
production: 'https://api.intercom.io',
12-
environment_1: 'https://api.eu.intercom.io',
13-
environment_2: 'https://api.au.intercom.io',
11+
us: 'https://api.intercom.io',
12+
eu: 'https://api.eu.intercom.io',
13+
au: 'https://api.au.intercom.io',
1414
};
1515
type Environment = keyof typeof environments;
1616

@@ -24,9 +24,9 @@ export interface ClientOptions {
2424
* Specifies the environment to use for the API.
2525
*
2626
* Each environment maps to a different base URL:
27-
* - `production` corresponds to `https://api.intercom.io`
28-
* - `environment_1` corresponds to `https://api.eu.intercom.io`
29-
* - `environment_2` corresponds to `https://api.au.intercom.io`
27+
* - `us` corresponds to `https://api.intercom.io`
28+
* - `eu` corresponds to `https://api.eu.intercom.io`
29+
* - `au` corresponds to `https://api.au.intercom.io`
3030
*/
3131
environment?: Environment;
3232

@@ -97,7 +97,7 @@ export class Intercom extends Core.APIClient {
9797
* API Client for interfacing with the Intercom API.
9898
*
9999
* @param {string | undefined} [opts.accessToken=process.env['INTERCOM_ACCESS_TOKEN'] ?? undefined]
100-
* @param {Environment} [opts.environment=production] - Specifies the environment URL to use for the API.
100+
* @param {Environment} [opts.environment=us] - Specifies the environment URL to use for the API.
101101
* @param {string} [opts.baseURL=process.env['INTERCOM_BASE_URL'] ?? https://api.intercom.io] - Override the default base URL for the API.
102102
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
103103
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
@@ -121,7 +121,7 @@ export class Intercom extends Core.APIClient {
121121
accessToken,
122122
...opts,
123123
baseURL,
124-
environment: opts.environment ?? 'production',
124+
environment: opts.environment ?? 'us',
125125
};
126126

127127
if (baseURL && opts.environment) {
@@ -131,7 +131,7 @@ export class Intercom extends Core.APIClient {
131131
}
132132

133133
super({
134-
baseURL: options.baseURL || environments[options.environment || 'production'],
134+
baseURL: options.baseURL || environments[options.environment || 'us'],
135135
timeout: options.timeout ?? 60000 /* 1 minute */,
136136
httpAgent: options.httpAgent,
137137
maxRetries: options.maxRetries,

tests/index.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,12 @@ describe('instantiate client', () => {
170170
process.env['INTERCOM_BASE_URL'] = 'https://example.com/from_env';
171171

172172
expect(
173-
() => new Intercom({ accessToken: 'My Access Token', environment: 'production' }),
173+
() => new Intercom({ accessToken: 'My Access Token', environment: 'us' }),
174174
).toThrowErrorMatchingInlineSnapshot(
175175
`"Ambiguous URL; The \`baseURL\` option (or INTERCOM_BASE_URL env var) and the \`environment\` option are given. If you want to use the environment you must pass baseURL: null"`,
176176
);
177177

178-
const client = new Intercom({
179-
accessToken: 'My Access Token',
180-
baseURL: null,
181-
environment: 'production',
182-
});
178+
const client = new Intercom({ accessToken: 'My Access Token', baseURL: null, environment: 'us' });
183179
expect(client.baseURL).toEqual('https://api.intercom.io');
184180
});
185181
});

0 commit comments

Comments
 (0)