Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Jun 22, 2024
1 parent 89a076c commit bc7fb99
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 7
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-2243a7233ce0fdfe90a6a1730f6a735432cd55037ac60b32c613fa7b6838b432.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-3c09ec2f8c094abffea8b1f8d2f410de855fd69e855be9f4823fb7b9eda7a3db.yml
2 changes: 1 addition & 1 deletion 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}.json">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, { ...params }) -> AgencyRetrieveResponse</code>

# Config

Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export namespace OnebusawaySDK {

export import Agency = API.Agency;
export import AgencyRetrieveResponse = API.AgencyRetrieveResponse;
export import AgencyRetrieveParams = API.AgencyRetrieveParams;

export import Config = API.Config;
export import ConfigRetrieveResponse = API.ConfigRetrieveResponse;
Expand Down
18 changes: 15 additions & 3 deletions src/resources/agency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import * as Shared from './shared';

export class Agency extends APIResource {
/**
* Retrieve info for a specific transit agency identified by id
* 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.json`, options);
retrieve(
agencyId: string,
query: AgencyRetrieveParams,
options?: Core.RequestOptions,
): Core.APIPromise<AgencyRetrieveResponse> {
return this._client.get(`/api/where/agency/agencyID.json`, { query, ...options });
}
}

Expand Down Expand Up @@ -50,6 +54,14 @@ export namespace AgencyRetrieveResponse {
}
}

export interface AgencyRetrieveParams {
/**
* API key for authentication.
*/
key: string;
}

export namespace Agency {
export import AgencyRetrieveResponse = AgencyAPI.AgencyRetrieveResponse;
export import AgencyRetrieveParams = AgencyAPI.AgencyRetrieveParams;
}
2 changes: 1 addition & 1 deletion src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

export * from './shared';
export { AgenciesWithCoverageRetrieveResponse, AgenciesWithCoverage } from './agencies-with-coverage';
export { AgencyRetrieveResponse, Agency } from './agency';
export { AgencyRetrieveResponse, AgencyRetrieveParams, Agency } from './agency';
export {
ArrivalAndDepartureForStopRetrieveResponse,
ArrivalAndDepartureForStopRetrieveParams,
Expand Down
11 changes: 4 additions & 7 deletions tests/api-resources/agency.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const onebusawaySDK = new OnebusawaySDK({
});

describe('resource agency', () => {
test('retrieve', async () => {
const responsePromise = onebusawaySDK.agency.retrieve('string');
test('retrieve: only required params', async () => {
const responsePromise = onebusawaySDK.agency.retrieve('string', { key: 'string' });
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -20,10 +20,7 @@ describe('resource agency', () => {
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.agency.retrieve('string', { path: '/_stainless_unknown_path' }),
).rejects.toThrow(OnebusawaySDK.NotFoundError);
test('retrieve: required and optional params', async () => {
const response = await onebusawaySDK.agency.retrieve('string', { key: 'string' });
});
});

0 comments on commit bc7fb99

Please sign in to comment.