Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 0.1.0-alpha.39 #184

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.38"
".": "0.1.0-alpha.39"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 25
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-f0a1f65a327091207db6d5ecc22149149967274b0c54c192cc442f93cc819c64.yml
configured_endpoints: 27
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-e4779565160778ba4193bbe8b27556a49f0f8c31ef15ac72c9ee1eb791f92d33.yml
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.1.0-alpha.39 (2024-08-12)

Full Changelog: [v0.1.0-alpha.38...v0.1.0-alpha.39](https://github.com/OneBusAway/js-sdk/compare/v0.1.0-alpha.38...v0.1.0-alpha.39)

### Features

* **api:** OpenAPI spec update via Stainless API ([#183](https://github.com/OneBusAway/js-sdk/issues/183)) ([890130e](https://github.com/OneBusAway/js-sdk/commit/890130e2e3a41453804066a313831da79fd27410))
* **api:** update via SDK Studio ([#185](https://github.com/OneBusAway/js-sdk/issues/185)) ([87faf11](https://github.com/OneBusAway/js-sdk/commit/87faf117774e9835d7c51d1dbdaff4067d07439e))

## 0.1.0-alpha.38 (2024-08-10)

Full Changelog: [v0.1.0-alpha.37...v0.1.0-alpha.38](https://github.com/OneBusAway/js-sdk/compare/v0.1.0-alpha.37...v0.1.0-alpha.38)
Expand Down
20 changes: 20 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,23 @@ Types:
Methods:

- <code title="get /api/where/search/route.json">client.searchForRoute.<a href="./src/resources/search-for-route.ts">retrieve</a>({ ...params }) -> SearchForRouteRetrieveResponse</code>

# Block

Types:

- <code><a href="./src/resources/block.ts">BlockRetrieveResponse</a></code>

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>
21 changes: 21 additions & 0 deletions examples/block.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import onebusaway from '../dist/index.mjs';
import { loadSettings } from './helpers/load-env.mjs';

// Load settings from .env file, if it exists. If not, we'll use the
// Puget Sound server URL (which is also the default in the SDK) and
// the 'TEST' API key.
const settings = loadSettings({
apiKey: 'TEST',
baseUrl: 'https://api.pugetsound.onebusaway.org/',
});

// Create a new instance of the OneBusAway SDK with the settings we loaded.
const oba = new onebusaway(settings);

async function main() {
const blockId = '1_7310845';
const response = await oba.block.retrieve(blockId);
console.log(response.data.entry.configurations[0].trips[0]);
}

main();
20 changes: 20 additions & 0 deletions examples/report-problem-with-trip.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import onebusaway from '../dist/index.mjs';
import { loadSettings } from './helpers/load-env.mjs';

// Load settings from .env file, if it exists. If not, we'll use the
// Puget Sound server URL (which is also the default in the SDK) and
// the 'TEST' API key.
const settings = loadSettings({
apiKey: 'TEST',
baseUrl: 'https://api.pugetsound.onebusaway.org/',
});

// Create a new instance of the OneBusAway SDK with the settings we loaded.
const oba = new onebusaway(settings);

async function main() {
const response = await oba.reportProblemWithTrip.retrieve('1_79430293');
console.log(response);
}

main();
21 changes: 21 additions & 0 deletions examples/shape.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import onebusaway from '../dist/index.mjs';
import { loadSettings } from './helpers/load-env.mjs';

// Load settings from .env file, if it exists. If not, we'll use the
// Puget Sound server URL (which is also the default in the SDK) and
// the 'TEST' API key.
const settings = loadSettings({
apiKey: 'TEST',
baseUrl: 'https://api.pugetsound.onebusaway.org/',
});

// Create a new instance of the OneBusAway SDK with the settings we loaded.
const oba = new onebusaway(settings);

async function main() {
const shapeId = '1_10002005';
const response = await oba.shape.retrieve(shapeId);
console.log(response.data.entry.points[0]);
}

main();
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "onebusaway-sdk",
"version": "0.1.0-alpha.38",
"version": "0.1.0-alpha.39",
"description": "The official TypeScript library for the Onebusaway SDK API",
"author": "Onebusaway SDK <[email protected]>",
"types": "dist/index.d.ts",
Expand Down
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ export class OnebusawaySDK extends Core.APIClient {
reportProblemWithTrip: API.ReportProblemWithTrip = new API.ReportProblemWithTrip(this);
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 @@ -291,6 +293,12 @@ export namespace OnebusawaySDK {
export import SearchForRouteRetrieveResponse = API.SearchForRouteRetrieveResponse;
export import SearchForRouteRetrieveParams = API.SearchForRouteRetrieveParams;

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
87 changes: 87 additions & 0 deletions src/resources/block.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

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

export class Block extends APIResource {
/**
* Get details of a specific block by ID
*/
retrieve(blockId: string, options?: Core.RequestOptions): Core.APIPromise<BlockRetrieveResponse> {
return this._client.get(`/api/where/block/${blockId}.json`, options);
}
}

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

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

references: Shared.References;
}

export namespace Data {
export interface Entry {
id: string;

configurations: Array<Entry.Configuration>;
}

export namespace Entry {
export interface Configuration {
activeServiceIds: Array<string>;

trips: Array<Configuration.Trip>;

inactiveServiceIds?: Array<string>;
}

export namespace Configuration {
export interface Trip {
accumulatedSlackTime: number;

blockStopTimes: Array<Trip.BlockStopTime>;

distanceAlongBlock: number;

tripId: string;
}

export namespace Trip {
export interface BlockStopTime {
accumulatedSlackTime: number;

blockSequence: number;

distanceAlongBlock: number;

stopTime: BlockStopTime.StopTime;
}

export namespace BlockStopTime {
export interface StopTime {
arrivalTime: number;

departureTime: number;

stopId: string;

dropOffType?: number;

pickupType?: number;
}
}
}
}
}
}
}

export namespace Block {
export import BlockRetrieveResponse = BlockAPI.BlockRetrieveResponse;
}
2 changes: 2 additions & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export {
ArrivalAndDepartureListParams,
ArrivalAndDeparture,
} from './arrival-and-departure';
export { BlockRetrieveResponse, Block } from './block';
export { ConfigRetrieveResponse, Config } from './config';
export { CurrentTimeRetrieveResponse, CurrentTime } from './current-time';
export { ReportProblemWithStopRetrieveParams, ReportProblemWithStop } from './report-problem-with-stop';
Expand Down Expand Up @@ -38,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;
}
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '0.1.0-alpha.38'; // x-release-please-version
export const VERSION = '0.1.0-alpha.39'; // x-release-please-version
29 changes: 29 additions & 0 deletions tests/api-resources/block.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 block', () => {
test('retrieve', async () => {
const responsePromise = client.block.retrieve('blockID');
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.block.retrieve('blockID', { path: '/_stainless_unknown_path' })).rejects.toThrow(
OnebusawaySDK.NotFoundError,
);
});
});
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,
);
});
});