diff --git a/.stats.yml b/.stats.yml index 9e66796..5317e12 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 6 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-eeb222073a0494a75907dcc959ee7840b06adc100de7b798b06dae3ac203d9d0.yml +configured_endpoints: 7 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-fac43338198b86982eb2bf5c7046beda47f432b1fc45a7c8da6537f21478d316.yml diff --git a/api.md b/api.md index cb7eb62..18053eb 100644 --- a/api.md +++ b/api.md @@ -23,7 +23,7 @@ Types: Methods: -- client.agency.retrieve(agencyId) -> AgencyRetrieveResponse +- client.agency.retrieve(agencyId) -> AgencyRetrieveResponse # Config @@ -63,4 +63,14 @@ Types: Methods: -- client.arrivalAndDepartureForStop.retrieve(stopId, { ...params }) -> ArrivalAndDepartureForStopRetrieveResponse +- client.arrivalAndDepartureForStop.retrieve(stopId, { ...params }) -> ArrivalAndDepartureForStopRetrieveResponse + +# ArrivalsAndDeparturesForStop + +Types: + +- ArrivalsAndDeparturesForStopRetrieveResponse + +Methods: + +- client.arrivalsAndDeparturesForStop.retrieve(stopId) -> ArrivalsAndDeparturesForStopRetrieveResponse diff --git a/src/index.ts b/src/index.ts index 8b892f0..e0b85c3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -125,6 +125,7 @@ export class OnebusawaySDK extends Core.APIClient { currentTime: API.CurrentTime = new API.CurrentTime(this); stopsForLocation: API.StopsForLocation = new API.StopsForLocation(this); arrivalAndDepartureForStop: API.ArrivalAndDepartureForStop = new API.ArrivalAndDepartureForStop(this); + arrivalsAndDeparturesForStop: API.ArrivalsAndDeparturesForStop = new API.ArrivalsAndDeparturesForStop(this); protected override defaultQuery(): Core.DefaultQuery | undefined { return { @@ -206,6 +207,9 @@ export namespace OnebusawaySDK { export import ArrivalAndDepartureForStopRetrieveResponse = API.ArrivalAndDepartureForStopRetrieveResponse; export import ArrivalAndDepartureForStopRetrieveParams = API.ArrivalAndDepartureForStopRetrieveParams; + export import ArrivalsAndDeparturesForStop = API.ArrivalsAndDeparturesForStop; + export import ArrivalsAndDeparturesForStopRetrieveResponse = API.ArrivalsAndDeparturesForStopRetrieveResponse; + export import References = API.References; export import ResponseWrapper = API.ResponseWrapper; } diff --git a/src/resources/agency.ts b/src/resources/agency.ts index 007874e..c350296 100644 --- a/src/resources/agency.ts +++ b/src/resources/agency.ts @@ -10,7 +10,7 @@ export class Agency extends APIResource { * Retrieve information for a specific transit agency identified by its unique ID. */ retrieve(agencyId: string, options?: Core.RequestOptions): Core.APIPromise { - return this._client.get(`/api/where/agency/${agencyId}`, options); + return this._client.get(`/api/where/agency/agencyID.json`, options); } } diff --git a/src/resources/arrival-and-departure-for-stop.ts b/src/resources/arrival-and-departure-for-stop.ts index b430a21..e761298 100644 --- a/src/resources/arrival-and-departure-for-stop.ts +++ b/src/resources/arrival-and-departure-for-stop.ts @@ -14,7 +14,7 @@ export class ArrivalAndDepartureForStop extends APIResource { query: ArrivalAndDepartureForStopRetrieveParams, options?: Core.RequestOptions, ): Core.APIPromise { - return this._client.get(`/api/where/arrival-and-departure-for-stop/${stopId}`, { query, ...options }); + return this._client.get(`/api/where/arrival-and-departure-for-stop/stopID.json`, { query, ...options }); } } diff --git a/src/resources/arrivals-and-departures-for-stop.ts b/src/resources/arrivals-and-departures-for-stop.ts new file mode 100644 index 0000000..c08d3d9 --- /dev/null +++ b/src/resources/arrivals-and-departures-for-stop.ts @@ -0,0 +1,184 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../resource'; +import * as Core from '../core'; +import * as ArrivalsAndDeparturesForStopAPI from './arrivals-and-departures-for-stop'; +import * as Shared from './shared'; + +export class ArrivalsAndDeparturesForStop extends APIResource { + /** + * arrivals-and-departures-for-stop + */ + retrieve( + stopId: string, + options?: Core.RequestOptions, + ): Core.APIPromise { + return this._client.get(`/api/where/arrivals-and-departures-for-stop/stopID.json`, options); + } +} + +export interface ArrivalsAndDeparturesForStopRetrieveResponse extends Shared.ResponseWrapper { + data?: ArrivalsAndDeparturesForStopRetrieveResponse.Data; +} + +export namespace ArrivalsAndDeparturesForStopRetrieveResponse { + export interface Data { + entry?: Data.Entry; + } + + export namespace Data { + export interface Entry { + arrivalsAndDepartures?: Array; + + references?: Shared.References; + } + + export namespace Entry { + export interface ArrivalsAndDeparture { + actualTrack?: string; + + arrivalEnabled?: boolean; + + blockTripSequence?: number; + + departureEnabled?: boolean; + + distanceFromStop?: number; + + frequency?: string; + + historicalOccupancy?: string; + + lastUpdateTime?: number; + + numberOfStopsAway?: number; + + occupancyStatus?: string; + + predicted?: boolean; + + predictedArrivalInterval?: string; + + predictedArrivalTime?: number; + + predictedDepartureInterval?: string; + + predictedDepartureTime?: number; + + predictedOccupancy?: string; + + routeId?: string; + + routeLongName?: string; + + routeShortName?: string; + + scheduledArrivalInterval?: string; + + scheduledArrivalTime?: number; + + scheduledDepartureInterval?: string; + + scheduledDepartureTime?: number; + + scheduledTrack?: string; + + serviceDate?: number; + + situationIds?: Array; + + status?: string; + + stopId?: string; + + stopSequence?: number; + + totalStopsInTrip?: number; + + tripHeadsign?: string; + + tripId?: string; + + tripStatus?: ArrivalsAndDeparture.TripStatus; + + vehicleId?: string; + } + + export namespace ArrivalsAndDeparture { + export interface TripStatus { + activeTripId?: string; + + blockTripSequence?: number; + + closestStop?: string; + + closestStopTimeOffset?: number; + + distanceAlongTrip?: number; + + frequency?: string; + + lastKnownDistanceAlongTrip?: number; + + lastKnownLocation?: TripStatus.LastKnownLocation; + + lastKnownOrientation?: number; + + lastLocationUpdateTime?: number; + + lastUpdateTime?: number; + + nextStop?: string; + + nextStopTimeOffset?: number; + + occupancyCapacity?: number; + + occupancyCount?: number; + + occupancyStatus?: string; + + orientation?: number; + + phase?: string; + + position?: TripStatus.Position; + + predicted?: boolean; + + scheduledDistanceAlongTrip?: number; + + scheduleDeviation?: number; + + serviceDate?: number; + + situationIds?: Array; + + status?: string; + + totalDistanceAlongTrip?: number; + + vehicleId?: string; + } + + export namespace TripStatus { + export interface LastKnownLocation { + lat?: number; + + lon?: number; + } + + export interface Position { + lat?: number; + + lon?: number; + } + } + } + } + } +} + +export namespace ArrivalsAndDeparturesForStop { + export import ArrivalsAndDeparturesForStopRetrieveResponse = ArrivalsAndDeparturesForStopAPI.ArrivalsAndDeparturesForStopRetrieveResponse; +} diff --git a/src/resources/index.ts b/src/resources/index.ts index 5e852fb..90f4097 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -8,6 +8,10 @@ export { ArrivalAndDepartureForStopRetrieveParams, ArrivalAndDepartureForStop, } from './arrival-and-departure-for-stop'; +export { + ArrivalsAndDeparturesForStopRetrieveResponse, + ArrivalsAndDeparturesForStop, +} from './arrivals-and-departures-for-stop'; export { ConfigRetrieveResponse, Config } from './config'; export { CurrentTimeRetrieveResponse, CurrentTime } from './current-time'; export { diff --git a/tests/api-resources/arrivals-and-departures-for-stop.test.ts b/tests/api-resources/arrivals-and-departures-for-stop.test.ts new file mode 100644 index 0000000..11fd27a --- /dev/null +++ b/tests/api-resources/arrivals-and-departures-for-stop.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 onebusawaySDK = new OnebusawaySDK({ + apiKey: 'My API Key', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource arrivalsAndDeparturesForStop', () => { + test('retrieve', async () => { + const responsePromise = onebusawaySDK.arrivalsAndDeparturesForStop.retrieve('1_75403'); + 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( + onebusawaySDK.arrivalsAndDeparturesForStop.retrieve('1_75403', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(OnebusawaySDK.NotFoundError); + }); +});