Skip to content

Commit

Permalink
Merge pull request #135 from OneBusAway/release-please--branches--mai…
Browse files Browse the repository at this point in the history
…n--changes--next--components--onebusaway-sdk

release: 0.1.0-alpha.30
  • Loading branch information
Ahmedhossamdev authored Jul 30, 2024
2 parents c4a5e88 + a379322 commit b3b4dd2
Show file tree
Hide file tree
Showing 12 changed files with 218 additions and 7 deletions.
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.29"
".": "0.1.0-alpha.30"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 16
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-7a71bec90a568b0dbefc3d81206069d9759259460cffa0543b162f6835be1e9a.yml
configured_endpoints: 17
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-160e2615de51b1febaeb9f4a2fbbb7e70939e1ebec74946e7ec1e026868fed7e.yml
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 0.1.0-alpha.30 (2024-07-30)

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

### Features

* **api:** OpenAPI spec update via Stainless API ([#134](https://github.com/OneBusAway/js-sdk/issues/134)) ([6481606](https://github.com/OneBusAway/js-sdk/commit/648160678f5bf5334b44b936b9315d11789f6aba))


### Chores

* **internal:** add constant for default timeout ([#136](https://github.com/OneBusAway/js-sdk/issues/136)) ([0531e45](https://github.com/OneBusAway/js-sdk/commit/0531e45c902f76a063ab9374dd4f5a6aee9d3311))

## 0.1.0-alpha.29 (2024-07-29)

Full Changelog: [v0.1.0-alpha.28...v0.1.0-alpha.29](https://github.com/OneBusAway/js-sdk/compare/v0.1.0-alpha.28...v0.1.0-alpha.29)
Expand Down
10 changes: 10 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ Methods:

- <code title="get /api/where/stop-ids-for-agency/{agencyID}.json">client.stopIdsForAgency.<a href="./src/resources/stop-ids-for-agency.ts">list</a>(agencyId) -> StopIDsForAgencyListResponse</code>

# ScheduleForStop

Types:

- <code><a href="./src/resources/schedule-for-stop.ts">ScheduleForStopRetrieveResponse</a></code>

Methods:

- <code title="get /api/where/schedule-for-stop/{stopID}.json">client.scheduleForStop.<a href="./src/resources/schedule-for-stop.ts">retrieve</a>(stopId, { ...params }) -> ScheduleForStopRetrieveResponse</code>

# Route

Types:
Expand Down
27 changes: 27 additions & 0 deletions examples/schedule-for-stop.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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 stopId = '1_75403';
const response = await oba.scheduleForStop.retrieve(stopId);

for (let route of response.data.entry.stopRouteSchedules) {
console.log(`Route ${route.routeId}`);
for (let trip of route.stopRouteDirectionSchedules[0].scheduleStopTimes) {
console.log(` ${trip.tripId} ${trip.arrivalTime}`);
}
}
}

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.29",
"version": "0.1.0-alpha.30",
"description": "The official TypeScript library for the Onebusaway SDK API",
"author": "Onebusaway SDK <info@onebusaway.org>",
"types": "dist/index.d.ts",
Expand Down
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export class OnebusawaySDK extends Core.APIClient {
stopsForRoute: API.StopsForRoute = new API.StopsForRoute(this);
stop: API.Stop = new API.Stop(this);
stopIdsForAgency: API.StopIDsForAgency = new API.StopIDsForAgency(this);
scheduleForStop: API.ScheduleForStop = new API.ScheduleForStop(this);
route: API.Route = new API.Route(this);
arrivalAndDeparture: API.ArrivalAndDeparture = new API.ArrivalAndDeparture(this);
trip: API.Trip = new API.Trip(this);
Expand All @@ -154,6 +155,7 @@ export class OnebusawaySDK extends Core.APIClient {
}

static OnebusawaySDK = this;
static DEFAULT_TIMEOUT = 60000; // 1 minute

static OnebusawaySDKError = Errors.OnebusawaySDKError;
static APIError = Errors.APIError;
Expand Down Expand Up @@ -225,6 +227,10 @@ export namespace OnebusawaySDK {
export import StopIDsForAgency = API.StopIDsForAgency;
export import StopIDsForAgencyListResponse = API.StopIDsForAgencyListResponse;

export import ScheduleForStop = API.ScheduleForStop;
export import ScheduleForStopRetrieveResponse = API.ScheduleForStopRetrieveResponse;
export import ScheduleForStopRetrieveParams = API.ScheduleForStopRetrieveParams;

export import Route = API.Route;
export import RouteRetrieveResponse = API.RouteRetrieveResponse;

Expand Down
5 changes: 5 additions & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ export {
export { ConfigRetrieveResponse, Config } from './config';
export { CurrentTimeRetrieveResponse, CurrentTime } from './current-time';
export { RouteRetrieveResponse, Route } from './route';
export {
ScheduleForStopRetrieveResponse,
ScheduleForStopRetrieveParams,
ScheduleForStop,
} from './schedule-for-stop';
export { StopIDsForAgencyListResponse, StopIDsForAgency } from './stop-ids-for-agency';
export { StopRetrieveResponse, Stop } from './stop';
export {
Expand Down
114 changes: 114 additions & 0 deletions src/resources/schedule-for-stop.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../resource';
import { isRequestOptions } from '../core';
import * as Core from '../core';
import * as ScheduleForStopAPI from './schedule-for-stop';
import * as Shared from './shared';

export class ScheduleForStop extends APIResource {
/**
* Get schedule for a specific stop
*/
retrieve(
stopId: string,
query?: ScheduleForStopRetrieveParams,
options?: Core.RequestOptions,
): Core.APIPromise<ScheduleForStopRetrieveResponse>;
retrieve(stopId: string, options?: Core.RequestOptions): Core.APIPromise<ScheduleForStopRetrieveResponse>;
retrieve(
stopId: string,
query: ScheduleForStopRetrieveParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<ScheduleForStopRetrieveResponse> {
if (isRequestOptions(query)) {
return this.retrieve(stopId, {}, query);
}
return this._client.get(`/api/where/schedule-for-stop/${stopId}.json`, { query, ...options });
}
}

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

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

references: Shared.References;
}

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

stopId: string;

stopRouteSchedules: Array<Entry.StopRouteSchedule>;
}

export namespace Entry {
export interface StopRouteSchedule {
routeId: string;

stopRouteDirectionSchedules: Array<StopRouteSchedule.StopRouteDirectionSchedule>;
}

export namespace StopRouteSchedule {
export interface StopRouteDirectionSchedule {
scheduleStopTimes: Array<StopRouteDirectionSchedule.ScheduleStopTime>;

tripHeadsign: string;

scheduleFrequencies?: Array<StopRouteDirectionSchedule.ScheduleFrequency>;
}

export namespace StopRouteDirectionSchedule {
export interface ScheduleStopTime {
arrivalEnabled: boolean;

arrivalTime: number;

departureEnabled: boolean;

departureTime: number;

serviceId: string;

tripId: string;

stopHeadsign?: string;
}

export interface ScheduleFrequency {
endTime: number;

headway: number;

serviceDate: number;

serviceId: string;

startTime: number;

tripId: string;
}
}
}
}
}
}

export interface ScheduleForStopRetrieveParams {
/**
* The date for which you want to request a schedule in the format YYYY-MM-DD
* (optional, defaults to the current date)
*/
date?: string;
}

export namespace ScheduleForStop {
export import ScheduleForStopRetrieveResponse = ScheduleForStopAPI.ScheduleForStopRetrieveResponse;
export import ScheduleForStopRetrieveParams = ScheduleForStopAPI.ScheduleForStopRetrieveParams;
}
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.29'; // x-release-please-version
export const VERSION = '0.1.0-alpha.30'; // x-release-please-version
36 changes: 36 additions & 0 deletions tests/api-resources/schedule-for-stop.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// 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 scheduleForStop', () => {
test('retrieve', async () => {
const responsePromise = client.scheduleForStop.retrieve('stopID');
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.scheduleForStop.retrieve('stopID', { 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(
client.scheduleForStop.retrieve('stopID', { date: '2019-12-27' }, { path: '/_stainless_unknown_path' }),
).rejects.toThrow(OnebusawaySDK.NotFoundError);
});
});

0 comments on commit b3b4dd2

Please sign in to comment.