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

feat(api): update via SDK Studio #51

Merged
merged 1 commit into from
Jun 26, 2024
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
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 12 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Types:

Methods:

- <code title="get /api/where/agency/{agencyID}">client.agency.<a href="./src/resources/agency.ts">retrieve</a>(agencyId) -> AgencyRetrieveResponse</code>
- <code title="get /api/where/agency/{agencyID}.json">client.agency.<a href="./src/resources/agency.ts">retrieve</a>(agencyId) -> AgencyRetrieveResponse</code>

# Config

Expand Down Expand Up @@ -63,4 +63,14 @@ Types:

Methods:

- <code title="get /api/where/arrival-and-departure-for-stop/{stopID}">client.arrivalAndDepartureForStop.<a href="./src/resources/arrival-and-departure-for-stop.ts">retrieve</a>(stopId, { ...params }) -> ArrivalAndDepartureForStopRetrieveResponse</code>
- <code title="get /api/where/arrival-and-departure-for-stop/{stopID}.json">client.arrivalAndDepartureForStop.<a href="./src/resources/arrival-and-departure-for-stop.ts">retrieve</a>(stopId, { ...params }) -> ArrivalAndDepartureForStopRetrieveResponse</code>

# ArrivalsAndDeparturesForStop

Types:

- <code><a href="./src/resources/arrivals-and-departures-for-stop.ts">ArrivalsAndDeparturesForStopRetrieveResponse</a></code>

Methods:

- <code title="get /api/where/arrivals-and-departures-for-stop/{stopID}.json">client.arrivalsAndDeparturesForStop.<a href="./src/resources/arrivals-and-departures-for-stop.ts">retrieve</a>(stopId) -> ArrivalsAndDeparturesForStopRetrieveResponse</code>
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/resources/agency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AgencyRetrieveResponse> {
return this._client.get(`/api/where/agency/${agencyId}`, options);
return this._client.get(`/api/where/agency/agencyID.json`, options);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/resources/arrival-and-departure-for-stop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class ArrivalAndDepartureForStop extends APIResource {
query: ArrivalAndDepartureForStopRetrieveParams,
options?: Core.RequestOptions,
): Core.APIPromise<ArrivalAndDepartureForStopRetrieveResponse> {
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 });
}
}

Expand Down
184 changes: 184 additions & 0 deletions src/resources/arrivals-and-departures-for-stop.ts
Original file line number Diff line number Diff line change
@@ -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<ArrivalsAndDeparturesForStopRetrieveResponse> {
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<Entry.ArrivalsAndDeparture>;

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<string>;

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<string>;

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;
}
4 changes: 4 additions & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
29 changes: 29 additions & 0 deletions tests/api-resources/arrivals-and-departures-for-stop.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 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);
});
});