Skip to content

Commit

Permalink
feat(api): update via SDK Studio
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Jun 6, 2024
1 parent 768ce13 commit dca56d2
Show file tree
Hide file tree
Showing 45 changed files with 79 additions and 89 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The full API of this library can be found in [api.md](api.md).
import Intercom from 'intercom';

const intercom = new Intercom({
bearerToken: process.env['INTERCOM_TEST_1_BEARER_TOKEN'], // This is the default and can be omitted
apiKey: process.env['INTERCOM_API_KEY'], // This is the default and can be omitted
environment: 'environment_1', // or 'production' | 'environment_2'; defaults to 'production'
});

Expand All @@ -45,7 +45,7 @@ This library includes TypeScript definitions for all request params and response
import Intercom from 'intercom';

const intercom = new Intercom({
bearerToken: process.env['INTERCOM_TEST_1_BEARER_TOKEN'], // This is the default and can be omitted
apiKey: process.env['INTERCOM_API_KEY'], // This is the default and can be omitted
environment: 'environment_1', // or 'production' | 'environment_2'; defaults to 'production'
});

Expand Down
20 changes: 10 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ type Environment = keyof typeof environments;

export interface ClientOptions {
/**
* Defaults to process.env['INTERCOM_TEST_1_BEARER_TOKEN'].
* Defaults to process.env['INTERCOM_API_KEY'].
*/
bearerToken?: string | undefined;
apiKey?: string | undefined;

/**
* Specifies the environment to use for the API.
Expand Down Expand Up @@ -89,14 +89,14 @@ export interface ClientOptions {

/** API Client for interfacing with the Intercom API. */
export class Intercom extends Core.APIClient {
bearerToken: string;
apiKey: string;

private _options: ClientOptions;

/**
* API Client for interfacing with the Intercom API.
*
* @param {string | undefined} [opts.bearerToken=process.env['INTERCOM_TEST_1_BEARER_TOKEN'] ?? undefined]
* @param {string | undefined} [opts.apiKey=process.env['INTERCOM_API_KEY'] ?? undefined]
* @param {Environment} [opts.environment=production] - Specifies the environment URL to use for the API.
* @param {string} [opts.baseURL=process.env['INTERCOM_BASE_URL'] ?? https://api.intercom.io] - Override the default base URL for the API.
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
Expand All @@ -108,17 +108,17 @@ export class Intercom extends Core.APIClient {
*/
constructor({
baseURL = Core.readEnv('INTERCOM_BASE_URL'),
bearerToken = Core.readEnv('INTERCOM_TEST_1_BEARER_TOKEN'),
apiKey = Core.readEnv('INTERCOM_API_KEY'),
...opts
}: ClientOptions = {}) {
if (bearerToken === undefined) {
if (apiKey === undefined) {
throw new Errors.IntercomError(
"The INTERCOM_TEST_1_BEARER_TOKEN environment variable is missing or empty; either provide it, or instantiate the Intercom client with an bearerToken option, like new Intercom({ bearerToken: 'My Bearer Token' }).",
"The INTERCOM_API_KEY environment variable is missing or empty; either provide it, or instantiate the Intercom client with an apiKey option, like new Intercom({ apiKey: 'My API Key' }).",
);
}

const options: ClientOptions = {
bearerToken,
apiKey,
...opts,
baseURL,
environment: opts.environment ?? 'production',
Expand All @@ -139,7 +139,7 @@ export class Intercom extends Core.APIClient {
});
this._options = options;

this.bearerToken = bearerToken;
this.apiKey = apiKey;
}

me: API.Me = new API.Me(this);
Expand Down Expand Up @@ -178,7 +178,7 @@ export class Intercom extends Core.APIClient {
}

protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
return { Authorization: `Bearer ${this.bearerToken}` };
return { Authorization: `Bearer ${this.apiKey}` };
}

protected override stringifyQuery(query: Record<string, unknown>): string {
Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/admins/activity-logs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/admins/admins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/articles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/companies/companies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/companies/contacts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/companies/segments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/contacts/companies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/contacts/contacts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/contacts/notes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/contacts/segments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/contacts/subscriptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/contacts/tags.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/conversations/conversations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/conversations/customers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/conversations/parts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/conversations/reply.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/conversations/tags.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/data-attributes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/data-events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/data-exports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/download/content/data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/export/content/data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/export/export.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/help-center/collections.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/help-center/help-centers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/me.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/messages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/news/news-items.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/news/newsfeeds/items.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/news/newsfeeds/newsfeeds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/notes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/phone-call-redirects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/segments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Intercom from 'intercom';
import { Response } from 'node-fetch';

const intercom = new Intercom({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
Loading

0 comments on commit dca56d2

Please sign in to comment.