Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Aug 12, 2024
1 parent 890130e commit 87faf11
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 26
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-fbc053e98085f73b2bf9d6a71bd4992c5eec1b582a030fb48b727cc0788ceae7.yml
configured_endpoints: 27
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-e4779565160778ba4193bbe8b27556a49f0f8c31ef15ac72c9ee1eb791f92d33.yml
10 changes: 10 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,13 @@ Types:
Methods:

- <code title="get /api/where/block/{blockID}.json">client.block.<a href="./src/resources/block.ts">retrieve</a>(blockId) -> BlockRetrieveResponse</code>

# Shape

Types:

- <code><a href="./src/resources/shape.ts">ShapeRetrieveResponse</a></code>

Methods:

- <code title="get /api/where/shape/{shapeID}.json">client.shape.<a href="./src/resources/shape.ts">retrieve</a>(shapeId) -> ShapeRetrieveResponse</code>
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export class OnebusawaySDK extends Core.APIClient {
searchForStop: API.SearchForStop = new API.SearchForStop(this);
searchForRoute: API.SearchForRoute = new API.SearchForRoute(this);
block: API.Block = new API.Block(this);
shape: API.Shape = new API.Shape(this);

protected override defaultQuery(): Core.DefaultQuery | undefined {
return {
Expand Down Expand Up @@ -295,6 +296,9 @@ export namespace OnebusawaySDK {
export import Block = API.Block;
export import BlockRetrieveResponse = API.BlockRetrieveResponse;

export import Shape = API.Shape;
export import ShapeRetrieveResponse = API.ShapeRetrieveResponse;

export import References = API.References;
export import ResponseWrapper = API.ResponseWrapper;
}
Expand Down
1 change: 1 addition & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export {
SearchForRoute,
} from './search-for-route';
export { SearchForStopRetrieveResponse, SearchForStopRetrieveParams, SearchForStop } from './search-for-stop';
export { ShapeRetrieveResponse, Shape } from './shape';
export { StopIDsForAgencyListResponse, StopIDsForAgency } from './stop-ids-for-agency';
export { StopRetrieveResponse, Stop } from './stop';
export {
Expand Down
44 changes: 44 additions & 0 deletions src/resources/shape.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../resource';
import * as Core from '../core';
import * as ShapeAPI from './shape';
import * as Shared from './shared';

export class Shape extends APIResource {
/**
* Retrieve a shape (the path traveled by a transit vehicle) by ID.
*/
retrieve(shapeId: string, options?: Core.RequestOptions): Core.APIPromise<ShapeRetrieveResponse> {
return this._client.get(`/api/where/shape/${shapeId}.json`, options);
}
}

export interface ShapeRetrieveResponse extends Shared.ResponseWrapper {
data: ShapeRetrieveResponse.Data;
}

export namespace ShapeRetrieveResponse {
export interface Data {
entry: Data.Entry;

references: Shared.References;
}

export namespace Data {
export interface Entry {
length: number;

/**
* Encoded polyline format representing the shape of the path
*/
points: string;

levels?: string;
}
}
}

export namespace Shape {
export import ShapeRetrieveResponse = ShapeAPI.ShapeRetrieveResponse;
}
29 changes: 29 additions & 0 deletions tests/api-resources/shape.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import OnebusawaySDK from 'onebusaway-sdk';
import { Response } from 'node-fetch';

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

describe('resource shape', () => {
test('retrieve', async () => {
const responsePromise = client.shape.retrieve('shapeID');
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
expect(response).not.toBeInstanceOf(Response);
const dataAndResponse = await responsePromise.withResponse();
expect(dataAndResponse.data).toBe(response);
expect(dataAndResponse.response).toBe(rawResponse);
});

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(client.shape.retrieve('shapeID', { path: '/_stainless_unknown_path' })).rejects.toThrow(
OnebusawaySDK.NotFoundError,
);
});
});

0 comments on commit 87faf11

Please sign in to comment.