Skip to content

Commit

Permalink
chore(docs): fix incorrect client var names (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Jul 30, 2024
1 parent c76e487 commit 4a0ad83
Show file tree
Hide file tree
Showing 43 changed files with 338 additions and 360 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const client = new Intercom({
});

async function main() {
const adminWithApp = await intercom.me.retrieve();
const adminWithApp = await client.me.retrieve();

console.log(adminWithApp.id);
}
Expand All @@ -50,7 +50,7 @@ const client = new Intercom({
});

async function main() {
const adminWithApp: Intercom.AdminWithApp | null = await intercom.me.retrieve();
const adminWithApp: Intercom.AdminWithApp | null = await client.me.retrieve();
}

main();
Expand All @@ -67,7 +67,7 @@ a subclass of `APIError` will be thrown:
<!-- prettier-ignore -->
```ts
async function main() {
const adminWithApp = await intercom.me.retrieve().catch(async (err) => {
const adminWithApp = await client.me.retrieve().catch(async (err) => {
if (err instanceof Intercom.APIError) {
console.log(err.status); // 400
console.log(err.name); // BadRequestError
Expand Down Expand Up @@ -110,7 +110,7 @@ const client = new Intercom({
});

// Or, configure per-request:
await intercom.me.retrieve({
await client.me.retrieve({
maxRetries: 5,
});
```
Expand All @@ -127,7 +127,7 @@ const client = new Intercom({
});

// Override per-request:
await intercom.me.retrieve({
await client.me.retrieve({
timeout: 5 * 1000,
});
```
Expand All @@ -148,11 +148,11 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
```ts
const client = new Intercom();

const response = await intercom.me.retrieve().asResponse();
const response = await client.me.retrieve().asResponse();
console.log(response.headers.get('X-My-Header'));
console.log(response.statusText); // access the underlying Response object

const { data: adminWithApp, response: raw } = await intercom.me.retrieve().withResponse();
const { data: adminWithApp, response: raw } = await client.me.retrieve().withResponse();
console.log(raw.headers.get('X-My-Header'));
console.log(adminWithApp.id);
```
Expand Down Expand Up @@ -258,7 +258,7 @@ const client = new Intercom({
});

// Override per-request:
await intercom.me.retrieve({
await client.me.retrieve({
httpAgent: new http.Agent({ keepAlive: false }),
});
```
Expand Down
6 changes: 3 additions & 3 deletions tests/api-resources/admins/activity-logs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import Intercom from 'intercom-client';
import { Response } from 'node-fetch';

const intercom = new Intercom({
const client = new Intercom({
accessToken: 'My Access Token',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource activityLogs', () => {
test('list: only required params', async () => {
const responsePromise = intercom.admins.activityLogs.list({ created_at_after: 'created_at_after' });
const responsePromise = client.admins.activityLogs.list({ created_at_after: 'created_at_after' });
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -21,7 +21,7 @@ describe('resource activityLogs', () => {
});

test('list: required and optional params', async () => {
const response = await intercom.admins.activityLogs.list({
const response = await client.admins.activityLogs.list({
created_at_after: 'created_at_after',
created_at_before: 'created_at_before',
'Intercom-Version': '2.11',
Expand Down
18 changes: 9 additions & 9 deletions tests/api-resources/admins/admins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import Intercom from 'intercom-client';
import { Response } from 'node-fetch';

const intercom = new Intercom({
const client = new Intercom({
accessToken: 'My Access Token',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource admins', () => {
test('retrieve', async () => {
const responsePromise = intercom.admins.retrieve(123);
const responsePromise = client.admins.retrieve(123);
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -22,20 +22,20 @@ describe('resource admins', () => {

test('retrieve: request options instead of params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(intercom.admins.retrieve(123, { path: '/_stainless_unknown_path' })).rejects.toThrow(
await expect(client.admins.retrieve(123, { path: '/_stainless_unknown_path' })).rejects.toThrow(
Intercom.NotFoundError,
);
});

test('retrieve: request options and params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
intercom.admins.retrieve(123, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }),
client.admins.retrieve(123, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }),
).rejects.toThrow(Intercom.NotFoundError);
});

test('list', async () => {
const responsePromise = intercom.admins.list();
const responsePromise = client.admins.list();
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -47,20 +47,20 @@ describe('resource admins', () => {

test('list: request options instead of params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(intercom.admins.list({ path: '/_stainless_unknown_path' })).rejects.toThrow(
await expect(client.admins.list({ path: '/_stainless_unknown_path' })).rejects.toThrow(
Intercom.NotFoundError,
);
});

test('list: request options and params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
intercom.admins.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }),
client.admins.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }),
).rejects.toThrow(Intercom.NotFoundError);
});

test('setAway: only required params', async () => {
const responsePromise = intercom.admins.setAway(0, { away_mode_enabled: true, away_mode_reassign: true });
const responsePromise = client.admins.setAway(0, { away_mode_enabled: true, away_mode_reassign: true });
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -71,7 +71,7 @@ describe('resource admins', () => {
});

test('setAway: required and optional params', async () => {
const response = await intercom.admins.setAway(0, {
const response = await client.admins.setAway(0, {
away_mode_enabled: true,
away_mode_reassign: true,
'Intercom-Version': '2.11',
Expand Down
39 changes: 18 additions & 21 deletions tests/api-resources/articles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
import Intercom from 'intercom-client';
import { Response } from 'node-fetch';

const intercom = new Intercom({
const client = new Intercom({
accessToken: 'My Access Token',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource articles', () => {
test('create: only required params', async () => {
const responsePromise = intercom.articles.create({
author_id: 991268363,
title: 'Thanks for everything',
});
const responsePromise = client.articles.create({ author_id: 991268363, title: 'Thanks for everything' });
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -24,7 +21,7 @@ describe('resource articles', () => {
});

test('create: required and optional params', async () => {
const response = await intercom.articles.create({
const response = await client.articles.create({
author_id: 991268363,
title: 'Thanks for everything',
body: 'Body of the Article',
Expand Down Expand Up @@ -447,7 +444,7 @@ describe('resource articles', () => {
});

test('retrieve', async () => {
const responsePromise = intercom.articles.retrieve(123);
const responsePromise = client.articles.retrieve(123);
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -459,20 +456,20 @@ describe('resource articles', () => {

test('retrieve: request options instead of params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(intercom.articles.retrieve(123, { path: '/_stainless_unknown_path' })).rejects.toThrow(
await expect(client.articles.retrieve(123, { path: '/_stainless_unknown_path' })).rejects.toThrow(
Intercom.NotFoundError,
);
});

test('retrieve: request options and params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
intercom.articles.retrieve(123, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }),
client.articles.retrieve(123, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }),
).rejects.toThrow(Intercom.NotFoundError);
});

test('update', async () => {
const responsePromise = intercom.articles.update(123);
const responsePromise = client.articles.update(123);
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -484,15 +481,15 @@ describe('resource articles', () => {

test('update: request options instead of params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(intercom.articles.update(123, { path: '/_stainless_unknown_path' })).rejects.toThrow(
await expect(client.articles.update(123, { path: '/_stainless_unknown_path' })).rejects.toThrow(
Intercom.NotFoundError,
);
});

test('update: request options and params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
intercom.articles.update(
client.articles.update(
123,
{
author_id: 1295,
Expand Down Expand Up @@ -920,7 +917,7 @@ describe('resource articles', () => {
});

test('list', async () => {
const responsePromise = intercom.articles.list();
const responsePromise = client.articles.list();
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -932,20 +929,20 @@ describe('resource articles', () => {

test('list: request options instead of params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(intercom.articles.list({ path: '/_stainless_unknown_path' })).rejects.toThrow(
await expect(client.articles.list({ path: '/_stainless_unknown_path' })).rejects.toThrow(
Intercom.NotFoundError,
);
});

test('list: request options and params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
intercom.articles.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }),
client.articles.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }),
).rejects.toThrow(Intercom.NotFoundError);
});

test('remove', async () => {
const responsePromise = intercom.articles.remove(123);
const responsePromise = client.articles.remove(123);
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -957,20 +954,20 @@ describe('resource articles', () => {

test('remove: request options instead of params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(intercom.articles.remove(123, { path: '/_stainless_unknown_path' })).rejects.toThrow(
await expect(client.articles.remove(123, { path: '/_stainless_unknown_path' })).rejects.toThrow(
Intercom.NotFoundError,
);
});

test('remove: request options and params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
intercom.articles.remove(123, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }),
client.articles.remove(123, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }),
).rejects.toThrow(Intercom.NotFoundError);
});

test('search', async () => {
const responsePromise = intercom.articles.search();
const responsePromise = client.articles.search();
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -982,15 +979,15 @@ describe('resource articles', () => {

test('search: request options instead of params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(intercom.articles.search({ path: '/_stainless_unknown_path' })).rejects.toThrow(
await expect(client.articles.search({ path: '/_stainless_unknown_path' })).rejects.toThrow(
Intercom.NotFoundError,
);
});

test('search: request options and params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
intercom.articles.search(
client.articles.search(
{ help_center_id: 0, highlight: true, phrase: 'phrase', state: 'state', 'Intercom-Version': '2.11' },
{ path: '/_stainless_unknown_path' },
),
Expand Down
Loading

0 comments on commit 4a0ad83

Please sign in to comment.