Skip to content

Commit

Permalink
chore(docs): fix incorrect client var names (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Jul 27, 2024
1 parent 703a920 commit f14a152
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 68 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const client = new OnebusawaySDK({
});

async function main() {
const currentTimeRetrieveResponse = await onebusawaySDK.currentTime.retrieve();
const currentTimeRetrieveResponse = await client.currentTime.retrieve();
}

main();
Expand All @@ -47,7 +47,7 @@ const client = new OnebusawaySDK({

async function main() {
const currentTimeRetrieveResponse: OnebusawaySDK.CurrentTimeRetrieveResponse =
await onebusawaySDK.currentTime.retrieve();
await client.currentTime.retrieve();
}

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

// Or, configure per-request:
await onebusawaySDK.currentTime.retrieve({
await client.currentTime.retrieve({
maxRetries: 5,
});
```
Expand All @@ -124,7 +124,7 @@ const client = new OnebusawaySDK({
});

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

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

const { data: currentTimeRetrieveResponse, response: raw } = await onebusawaySDK.currentTime
const { data: currentTimeRetrieveResponse, response: raw } = await client.currentTime
.retrieve()
.withResponse();
console.log(raw.headers.get('X-My-Header'));
Expand Down Expand Up @@ -257,7 +257,7 @@ const client = new OnebusawaySDK({
});

// Override per-request:
await onebusawaySDK.currentTime.retrieve({
await client.currentTime.retrieve({
httpAgent: new http.Agent({ keepAlive: false }),
});
```
Expand Down
10 changes: 5 additions & 5 deletions tests/api-resources/agencies-with-coverage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import OnebusawaySDK from 'onebusaway-sdk';
import { Response } from 'node-fetch';

const onebusawaySDK = new OnebusawaySDK({
const client = new OnebusawaySDK({
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

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

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(
onebusawaySDK.agenciesWithCoverage.retrieve({ path: '/_stainless_unknown_path' }),
).rejects.toThrow(OnebusawaySDK.NotFoundError);
await expect(client.agenciesWithCoverage.retrieve({ path: '/_stainless_unknown_path' })).rejects.toThrow(
OnebusawaySDK.NotFoundError,
);
});
});
10 changes: 5 additions & 5 deletions tests/api-resources/agency.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import OnebusawaySDK from 'onebusaway-sdk';
import { Response } from 'node-fetch';

const onebusawaySDK = new OnebusawaySDK({
const client = new OnebusawaySDK({
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource agency', () => {
test('retrieve', async () => {
const responsePromise = onebusawaySDK.agency.retrieve('agencyID');
const responsePromise = client.agency.retrieve('agencyID');
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -22,8 +22,8 @@ describe('resource agency', () => {

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(
onebusawaySDK.agency.retrieve('agencyID', { path: '/_stainless_unknown_path' }),
).rejects.toThrow(OnebusawaySDK.NotFoundError);
await expect(client.agency.retrieve('agencyID', { path: '/_stainless_unknown_path' })).rejects.toThrow(
OnebusawaySDK.NotFoundError,
);
});
});
12 changes: 6 additions & 6 deletions tests/api-resources/arrival-and-departure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import OnebusawaySDK from 'onebusaway-sdk';
import { Response } from 'node-fetch';

const onebusawaySDK = new OnebusawaySDK({
const client = new OnebusawaySDK({
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource arrivalAndDeparture', () => {
test('retrieve: only required params', async () => {
const responsePromise = onebusawaySDK.arrivalAndDeparture.retrieve('1_75403', {
const responsePromise = client.arrivalAndDeparture.retrieve('1_75403', {
serviceDate: 0,
tripId: 'tripId',
});
Expand All @@ -24,7 +24,7 @@ describe('resource arrivalAndDeparture', () => {
});

test('retrieve: required and optional params', async () => {
const response = await onebusawaySDK.arrivalAndDeparture.retrieve('1_75403', {
const response = await client.arrivalAndDeparture.retrieve('1_75403', {
serviceDate: 0,
tripId: 'tripId',
stopSequence: 0,
Expand All @@ -34,7 +34,7 @@ describe('resource arrivalAndDeparture', () => {
});

test('list', async () => {
const responsePromise = onebusawaySDK.arrivalAndDeparture.list('1_75403');
const responsePromise = client.arrivalAndDeparture.list('1_75403');
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -47,14 +47,14 @@ describe('resource arrivalAndDeparture', () => {
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(
onebusawaySDK.arrivalAndDeparture.list('1_75403', { path: '/_stainless_unknown_path' }),
client.arrivalAndDeparture.list('1_75403', { path: '/_stainless_unknown_path' }),
).rejects.toThrow(OnebusawaySDK.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(
onebusawaySDK.arrivalAndDeparture.list(
client.arrivalAndDeparture.list(
'1_75403',
{ minutesAfter: 0, minutesBefore: 0, time: '2019-12-27T18:11:19.117Z' },
{ path: '/_stainless_unknown_path' },
Expand Down
6 changes: 3 additions & 3 deletions tests/api-resources/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import OnebusawaySDK from 'onebusaway-sdk';
import { Response } from 'node-fetch';

const onebusawaySDK = new OnebusawaySDK({
const client = new OnebusawaySDK({
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

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

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(onebusawaySDK.config.retrieve({ path: '/_stainless_unknown_path' })).rejects.toThrow(
await expect(client.config.retrieve({ path: '/_stainless_unknown_path' })).rejects.toThrow(
OnebusawaySDK.NotFoundError,
);
});
Expand Down
6 changes: 3 additions & 3 deletions tests/api-resources/current-time.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import OnebusawaySDK from 'onebusaway-sdk';
import { Response } from 'node-fetch';

const onebusawaySDK = new OnebusawaySDK({
const client = new OnebusawaySDK({
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

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

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(onebusawaySDK.currentTime.retrieve({ path: '/_stainless_unknown_path' })).rejects.toThrow(
await expect(client.currentTime.retrieve({ path: '/_stainless_unknown_path' })).rejects.toThrow(
OnebusawaySDK.NotFoundError,
);
});
Expand Down
10 changes: 5 additions & 5 deletions tests/api-resources/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import OnebusawaySDK from 'onebusaway-sdk';
import { Response } from 'node-fetch';

const onebusawaySDK = new OnebusawaySDK({
const client = new OnebusawaySDK({
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource route', () => {
test('retrieve', async () => {
const responsePromise = onebusawaySDK.route.retrieve('routeID');
const responsePromise = client.route.retrieve('routeID');
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -22,8 +22,8 @@ describe('resource route', () => {

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(
onebusawaySDK.route.retrieve('routeID', { path: '/_stainless_unknown_path' }),
).rejects.toThrow(OnebusawaySDK.NotFoundError);
await expect(client.route.retrieve('routeID', { path: '/_stainless_unknown_path' })).rejects.toThrow(
OnebusawaySDK.NotFoundError,
);
});
});
6 changes: 3 additions & 3 deletions tests/api-resources/stop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import OnebusawaySDK from 'onebusaway-sdk';
import { Response } from 'node-fetch';

const onebusawaySDK = new OnebusawaySDK({
const client = new OnebusawaySDK({
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource stop', () => {
test('retrieve', async () => {
const responsePromise = onebusawaySDK.stop.retrieve('stopID');
const responsePromise = client.stop.retrieve('stopID');
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -22,7 +22,7 @@ describe('resource stop', () => {

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(onebusawaySDK.stop.retrieve('stopID', { path: '/_stainless_unknown_path' })).rejects.toThrow(
await expect(client.stop.retrieve('stopID', { path: '/_stainless_unknown_path' })).rejects.toThrow(
OnebusawaySDK.NotFoundError,
);
});
Expand Down
6 changes: 3 additions & 3 deletions tests/api-resources/stops-for-location.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import OnebusawaySDK from 'onebusaway-sdk';
import { Response } from 'node-fetch';

const onebusawaySDK = new OnebusawaySDK({
const client = new OnebusawaySDK({
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource stopsForLocation', () => {
test('retrieve: only required params', async () => {
const responsePromise = onebusawaySDK.stopsForLocation.retrieve({ key: 'key' });
const responsePromise = client.stopsForLocation.retrieve({ key: 'key' });
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -21,6 +21,6 @@ describe('resource stopsForLocation', () => {
});

test('retrieve: required and optional params', async () => {
const response = await onebusawaySDK.stopsForLocation.retrieve({ key: 'key', lat: 0, lon: 0 });
const response = await client.stopsForLocation.retrieve({ key: 'key', lat: 0, lon: 0 });
});
});
12 changes: 6 additions & 6 deletions tests/api-resources/stops-for-route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import OnebusawaySDK from 'onebusaway-sdk';
import { Response } from 'node-fetch';

const onebusawaySDK = new OnebusawaySDK({
const client = new OnebusawaySDK({
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource stopsForRoute', () => {
test('list', async () => {
const responsePromise = onebusawaySDK.stopsForRoute.list('routeID');
const responsePromise = client.stopsForRoute.list('routeID');
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -22,15 +22,15 @@ describe('resource stopsForRoute', () => {

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(
onebusawaySDK.stopsForRoute.list('routeID', { path: '/_stainless_unknown_path' }),
).rejects.toThrow(OnebusawaySDK.NotFoundError);
await expect(client.stopsForRoute.list('routeID', { path: '/_stainless_unknown_path' })).rejects.toThrow(
OnebusawaySDK.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(
onebusawaySDK.stopsForRoute.list(
client.stopsForRoute.list(
'routeID',
{ includePolylines: true, time: 'time' },
{ path: '/_stainless_unknown_path' },
Expand Down
12 changes: 6 additions & 6 deletions tests/api-resources/trip-details.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import OnebusawaySDK from 'onebusaway-sdk';
import { Response } from 'node-fetch';

const onebusawaySDK = new OnebusawaySDK({
const client = new OnebusawaySDK({
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource tripDetails', () => {
test('retrieve', async () => {
const responsePromise = onebusawaySDK.tripDetails.retrieve('tripID');
const responsePromise = client.tripDetails.retrieve('tripID');
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -22,15 +22,15 @@ describe('resource tripDetails', () => {

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(
onebusawaySDK.tripDetails.retrieve('tripID', { path: '/_stainless_unknown_path' }),
).rejects.toThrow(OnebusawaySDK.NotFoundError);
await expect(client.tripDetails.retrieve('tripID', { path: '/_stainless_unknown_path' })).rejects.toThrow(
OnebusawaySDK.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(
onebusawaySDK.tripDetails.retrieve(
client.tripDetails.retrieve(
'tripID',
{ includeSchedule: true, includeStatus: true, includeTrip: true, serviceDate: 0, time: 0 },
{ path: '/_stainless_unknown_path' },
Expand Down
Loading

0 comments on commit f14a152

Please sign in to comment.