From d59d0a9a71c626854cd93c4c840ef8085b24ddc8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 10 Aug 2024 21:09:19 +0000 Subject: [PATCH 1/8] release: 0.1.0-alpha.38 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ package-lock.json | 4 ++-- package.json | 2 +- src/version.ts | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 823f924..24fe6d3 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.37" + ".": "0.1.0-alpha.38" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 35af8cf..0eef44f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 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) + +### Features + +* **api:** OpenAPI spec update via Stainless API ([#177](https://github.com/OneBusAway/js-sdk/issues/177)) ([0c8fae7](https://github.com/OneBusAway/js-sdk/commit/0c8fae71d7821a6801a110ea9898a81f6ef70ff0)) + ## 0.1.0-alpha.37 (2024-08-08) Full Changelog: [v0.1.0-alpha.36...v0.1.0-alpha.37](https://github.com/OneBusAway/js-sdk/compare/v0.1.0-alpha.36...v0.1.0-alpha.37) diff --git a/package-lock.json b/package-lock.json index fdf6e5f..7045f51 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "onebusaway-sdk", - "version": "0.1.0-alpha.37", + "version": "0.1.0-alpha.38", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "onebusaway-sdk", - "version": "0.1.0-alpha.37", + "version": "0.1.0-alpha.38", "license": "Apache-2.0", "dependencies": { "@types/node": "^18.11.18", diff --git a/package.json b/package.json index af17d38..47fb6e7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "onebusaway-sdk", - "version": "0.1.0-alpha.37", + "version": "0.1.0-alpha.38", "description": "The official TypeScript library for the Onebusaway SDK API", "author": "Onebusaway SDK ", "types": "dist/index.d.ts", diff --git a/src/version.ts b/src/version.ts index 1d95c35..8750540 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.1.0-alpha.37'; // x-release-please-version +export const VERSION = '0.1.0-alpha.38'; // x-release-please-version From dafecc70113232cdc477b2aecd72786fe42ab0b1 Mon Sep 17 00:00:00 2001 From: Ahmedhossamdev Date: Sun, 11 Aug 2024 00:25:53 +0300 Subject: [PATCH 2/8] feat: Add example for reporting a problem with a trip --- examples/report-problem-with-trip.mjs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 examples/report-problem-with-trip.mjs diff --git a/examples/report-problem-with-trip.mjs b/examples/report-problem-with-trip.mjs new file mode 100644 index 0000000..d6a38ea --- /dev/null +++ b/examples/report-problem-with-trip.mjs @@ -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(); From 890130e2e3a41453804066a313831da79fd27410 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 20:51:44 +0000 Subject: [PATCH 3/8] feat(api): OpenAPI spec update via Stainless API (#183) --- .stats.yml | 4 +- api.md | 10 ++++ src/index.ts | 4 ++ src/resources/block.ts | 87 +++++++++++++++++++++++++++++++ src/resources/index.ts | 1 + tests/api-resources/block.test.ts | 29 +++++++++++ 6 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 src/resources/block.ts create mode 100644 tests/api-resources/block.test.ts diff --git a/.stats.yml b/.stats.yml index f5e154f..4b50dee 100644 --- a/.stats.yml +++ b/.stats.yml @@ -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: 26 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-fbc053e98085f73b2bf9d6a71bd4992c5eec1b582a030fb48b727cc0788ceae7.yml diff --git a/api.md b/api.md index 2e2038f..970353f 100644 --- a/api.md +++ b/api.md @@ -238,3 +238,13 @@ Types: Methods: - client.searchForRoute.retrieve({ ...params }) -> SearchForRouteRetrieveResponse + +# Block + +Types: + +- BlockRetrieveResponse + +Methods: + +- client.block.retrieve(blockId) -> BlockRetrieveResponse diff --git a/src/index.ts b/src/index.ts index 29e7708..fecb8cd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -143,6 +143,7 @@ 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); protected override defaultQuery(): Core.DefaultQuery | undefined { return { @@ -291,6 +292,9 @@ 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 References = API.References; export import ResponseWrapper = API.ResponseWrapper; } diff --git a/src/resources/block.ts b/src/resources/block.ts new file mode 100644 index 0000000..26a0298 --- /dev/null +++ b/src/resources/block.ts @@ -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 { + 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; + } + + export namespace Entry { + export interface Configuration { + activeServiceIds: Array; + + trips: Array; + + inactiveServiceIds?: Array; + } + + export namespace Configuration { + export interface Trip { + accumulatedSlackTime: number; + + blockStopTimes: Array; + + 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; +} diff --git a/src/resources/index.ts b/src/resources/index.ts index 5b4a6af..365c0f8 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -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'; diff --git a/tests/api-resources/block.test.ts b/tests/api-resources/block.test.ts new file mode 100644 index 0000000..62b39f7 --- /dev/null +++ b/tests/api-resources/block.test.ts @@ -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, + ); + }); +}); From 6195222e6b978491c58338e430df0f6cff9e2ae1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 20:52:00 +0000 Subject: [PATCH 4/8] release: 0.1.0-alpha.39 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ package-lock.json | 4 ++-- package.json | 2 +- src/version.ts | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 24fe6d3..ad6a7f0 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.38" + ".": "0.1.0-alpha.39" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d86a7d..1e03d26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # 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)) + ## 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) diff --git a/package-lock.json b/package-lock.json index 7045f51..a7697f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "onebusaway-sdk", - "version": "0.1.0-alpha.38", + "version": "0.1.0-alpha.39", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "onebusaway-sdk", - "version": "0.1.0-alpha.38", + "version": "0.1.0-alpha.39", "license": "Apache-2.0", "dependencies": { "@types/node": "^18.11.18", diff --git a/package.json b/package.json index 47fb6e7..924b524 100644 --- a/package.json +++ b/package.json @@ -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 ", "types": "dist/index.d.ts", diff --git a/src/version.ts b/src/version.ts index 8750540..616ad9c 100644 --- a/src/version.ts +++ b/src/version.ts @@ -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 From 78227aab4bd14b2b3bcd0bb1887f12c86bb10326 Mon Sep 17 00:00:00 2001 From: Ahmedhossamdev Date: Tue, 13 Aug 2024 00:04:51 +0300 Subject: [PATCH 5/8] feat: Add example for retrieving block information --- examples/block.mjs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 examples/block.mjs diff --git a/examples/block.mjs b/examples/block.mjs new file mode 100644 index 0000000..fa3bcc8 --- /dev/null +++ b/examples/block.mjs @@ -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(); From 87faf117774e9835d7c51d1dbdaff4067d07439e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 23:16:50 +0000 Subject: [PATCH 6/8] feat(api): update via SDK Studio (#185) --- .stats.yml | 4 +-- api.md | 10 +++++++ src/index.ts | 4 +++ src/resources/index.ts | 1 + src/resources/shape.ts | 44 +++++++++++++++++++++++++++++++ tests/api-resources/shape.test.ts | 29 ++++++++++++++++++++ 6 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 src/resources/shape.ts create mode 100644 tests/api-resources/shape.test.ts diff --git a/.stats.yml b/.stats.yml index 4b50dee..c040587 100644 --- a/.stats.yml +++ b/.stats.yml @@ -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 diff --git a/api.md b/api.md index 970353f..d53eb6c 100644 --- a/api.md +++ b/api.md @@ -248,3 +248,13 @@ Types: Methods: - client.block.retrieve(blockId) -> BlockRetrieveResponse + +# Shape + +Types: + +- ShapeRetrieveResponse + +Methods: + +- client.shape.retrieve(shapeId) -> ShapeRetrieveResponse diff --git a/src/index.ts b/src/index.ts index fecb8cd..e9e267c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 { @@ -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; } diff --git a/src/resources/index.ts b/src/resources/index.ts index 365c0f8..a66a88d 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -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 { diff --git a/src/resources/shape.ts b/src/resources/shape.ts new file mode 100644 index 0000000..412c03e --- /dev/null +++ b/src/resources/shape.ts @@ -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 { + 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; +} diff --git a/tests/api-resources/shape.test.ts b/tests/api-resources/shape.test.ts new file mode 100644 index 0000000..93bcb87 --- /dev/null +++ b/tests/api-resources/shape.test.ts @@ -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, + ); + }); +}); From a6cf89031c9d046b581acceaaf1012877fbce236 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 23:17:07 +0000 Subject: [PATCH 7/8] release: 0.1.0-alpha.39 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 9 +++++++++ package-lock.json | 4 ++-- package.json | 2 +- src/version.ts | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 24fe6d3..ad6a7f0 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.38" + ".": "0.1.0-alpha.39" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d86a7d..d9fe8e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/package-lock.json b/package-lock.json index 7045f51..a7697f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "onebusaway-sdk", - "version": "0.1.0-alpha.38", + "version": "0.1.0-alpha.39", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "onebusaway-sdk", - "version": "0.1.0-alpha.38", + "version": "0.1.0-alpha.39", "license": "Apache-2.0", "dependencies": { "@types/node": "^18.11.18", diff --git a/package.json b/package.json index 47fb6e7..924b524 100644 --- a/package.json +++ b/package.json @@ -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 ", "types": "dist/index.d.ts", diff --git a/src/version.ts b/src/version.ts index 8750540..616ad9c 100644 --- a/src/version.ts +++ b/src/version.ts @@ -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 From 8d6ddaca81ce361cab74a17141c64125c250b593 Mon Sep 17 00:00:00 2001 From: Ahmedhossamdev Date: Tue, 13 Aug 2024 02:20:53 +0300 Subject: [PATCH 8/8] feat: Add example for retrieving shape information --- examples/shape.mjs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 examples/shape.mjs diff --git a/examples/shape.mjs b/examples/shape.mjs new file mode 100644 index 0000000..dfda1c7 --- /dev/null +++ b/examples/shape.mjs @@ -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();