UNPKG

@hasadna/open-bus-api-client

Version:

A client library for interacting with the Open-Bus API.

332 lines (274 loc) 18.6 kB
/* tslint:disable */ /* eslint-disable */ /** * Open Bus Stride API * ### Follow planned and real-time bus statistics 🚌 Welcome to The Public Knowledge Workshop\'s Stride project. We provide usable and accurate data about the Israeli public transportation system. For background on the project and some more detailed documentation and usage guides, see [STRIDE.md](https://github.com/hasadna/open-bus-pipelines/blob/main/STRIDE.md). Looking for a specific use-case? * Take a look at the **user cases** APIs below. * Try one of our existing [jupyter notebooks](https://github.com/hasadna/open-bus-stride-client/blob/main/README.md#using-the-interactive-jupyter-notebooks). * Don\'t see your use-case covered here? Please [open us a ticket](https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fhasadna%2Fopen-bus%2Fissues%2Fnew)! Queries are by default limited to 100 results per query, this limit can be increased up to 500,000 results. Please try to set appropriate query parameters to limit the results to reduce load on our DB. If you do need to get large number of results (up to 500,000) it\'s recommended to use one of these methods: 1. Use HTTP streaming and JSON streaming decoder, this method is most efficient and provide accurate results. Our [Stride Python Client iterate method](https://github.com/hasadna/open-bus-stride-client#usage) uses this method. 2. Use combination of limit / offset parameters to get results by page. This method may be less accurate because it depends on data remaining unchanged between requests. For more advanced usage- * Use **gtfs** for data about the planned lines timetables. * Use **siri** for data about lines real-time * See [Open Bus Stride Data Model](https://github.com/hasadna/open-bus-stride-db/blob/main/DATA_MODEL.md) for description of field and table names. * See [Open Bus Stride ETL Processes](https://github.com/hasadna/open-bus-pipelines/blob/main/STRIDE_ETL_PROCESSES.md) for description of the ETL processes which fetch and aggregate the data. * See [MOT Developer Information](https://www.gov.il/BlobFolder/generalpage/gtfs_general_transit_feed_specifications/he/GTFS%20-%20Developer%20Information.pdf) for description of the source fields as published by the Israel Ministry of Transportation. * * The version of the OpenAPI document: f2d4fa609b8a0b4607f9b72aa4cd7bc143334baa * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import * as runtime from '../runtime'; import type { HTTPValidationError, RideExecutionPydanticModel, RouteTimetablePydanticModel, StopArrivalPydanticModel, } from '../models/index'; import { HTTPValidationErrorFromJSON, HTTPValidationErrorToJSON, RideExecutionPydanticModelFromJSON, RideExecutionPydanticModelToJSON, RouteTimetablePydanticModelFromJSON, RouteTimetablePydanticModelToJSON, StopArrivalPydanticModelFromJSON, StopArrivalPydanticModelToJSON, } from '../models/index'; export interface RidesExecutionListGetRequest { dateFrom: Date; dateTo: Date; operatorRef: number; lineRef: number; limit?: number; offset?: number; getCount?: boolean; } export interface RouteTimetableListGetRequest { limit?: number; offset?: number; getCount?: boolean; plannedStartTimeDateFrom?: Date; plannedStartTimeDateTo?: Date; lineRefs?: string; } export interface StopArrivalsListGetRequest { limit?: number; offset?: number; getCount?: boolean; gtfsStopId?: number; gtfsRideIds?: string; } /** * UserCasesApi - interface * * @export * @interface UserCasesApiInterface */ export interface UserCasesApiInterface { /** * List of A comparison between the planned and actual rides of a specific route between the given dates. Currently, the \"actual_rides_count\", will be either None (no actual ride) or equal to the \"planned_rides_count. * @summary List * @param {Date} dateFrom Filter by date. Only return items which have a date after or equals to given value. Format: \&quot;YYYY-MM-DD\&quot;, e.g. \&quot;2021-11-03\&quot;. * @param {Date} dateTo Filter by date. Only return items which have a date before or equals to given value. Format: \&quot;YYYY-MM-DD\&quot;, e.g. \&quot;2021-11-03\&quot;. * @param {number} operatorRef Line operator ref. Filter by operator_ref. Only return items which exactly match given string. * @param {number} lineRef Line ref. Filter by line_ref. Only return items which exactly match given string. * @param {number} [limit] Limit the number of returned results. If not specified will limit to 100 results. To get more results, you can either use the offset param, alternatively - set the limit to -1 and use http streaming with compatible json streaming decoder to get all results, this method can fetch up to a maximum of 500000 results. * @param {number} [offset] Item number to start returning results from. Use in combination with limit for pagination, alternatively, don\&#39;t set offset, set limit to -1 and use http streaming with compatible json streaming decoder to get all results up to a maximum of 500000 results. * @param {boolean} [getCount] Set to \&quot;true\&quot; to only get the total number of results for given filters. limit/offset/order parameters will be ignored. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserCasesApiInterface */ ridesExecutionListGetRaw(requestParameters: RidesExecutionListGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<RideExecutionPydanticModel>>>; /** * List of A comparison between the planned and actual rides of a specific route between the given dates. Currently, the \"actual_rides_count\", will be either None (no actual ride) or equal to the \"planned_rides_count. * List */ ridesExecutionListGet(requestParameters: RidesExecutionListGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<RideExecutionPydanticModel>>; /** * List of the stops timetable of a given bus. Currently, only planned time (gtfs) is returned for every stop. * @summary List * @param {number} [limit] Limit the number of returned results. If not specified will limit to 100 results. To get more results, you can either use the offset param, alternatively - set the limit to -1 and use http streaming with compatible json streaming decoder to get all results, this method can fetch up to a maximum of 500000 results. * @param {number} [offset] Item number to start returning results from. Use in combination with limit for pagination, alternatively, don\&#39;t set offset, set limit to -1 and use http streaming with compatible json streaming decoder to get all results up to a maximum of 500000 results. * @param {boolean} [getCount] Set to \&quot;true\&quot; to only get the total number of results for given filters. limit/offset/order parameters will be ignored. * @param {Date} [plannedStartTimeDateFrom] Set a time range to get the timetable of a specific ride Filter by planned_start_time. Only return items which have date/time after or equals to given value. Format: \&quot;YYYY-MM-DDTHH:MM:SS+Z\&quot;, e.g. \&quot;2021-11-03T15:48:49+02:00\&quot;. Note that all date/times must have a timezone specification. * @param {Date} [plannedStartTimeDateTo] Set a time range to get the time table of a specific ride Filter by planned_start_time. Only return items which have date/time before or equals to given value. Format: \&quot;YYYY-MM-DDTHH:MM:SS+Z\&quot;, e.g. \&quot;2021-11-03T15:48:49+02:00\&quot;. Note that all date/times must have a timezone specification. * @param {string} [lineRefs] To get a line ref, first query gtfs_routes Filter by line_ref. Comma-separated list of values. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserCasesApiInterface */ routeTimetableListGetRaw(requestParameters: RouteTimetableListGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<RouteTimetablePydanticModel>>>; /** * List of the stops timetable of a given bus. Currently, only planned time (gtfs) is returned for every stop. * List */ routeTimetableListGet(requestParameters: RouteTimetableListGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<RouteTimetablePydanticModel>>; /** * List of the actual arrival times to a specific stop. Currently, only planned time (gtfs) is returned for every stop. * @summary List * @param {number} [limit] Limit the number of returned results. If not specified will limit to 100 results. To get more results, you can either use the offset param, alternatively - set the limit to -1 and use http streaming with compatible json streaming decoder to get all results, this method can fetch up to a maximum of 500000 results. * @param {number} [offset] Item number to start returning results from. Use in combination with limit for pagination, alternatively, don\&#39;t set offset, set limit to -1 and use http streaming with compatible json streaming decoder to get all results up to a maximum of 500000 results. * @param {boolean} [getCount] Set to \&quot;true\&quot; to only get the total number of results for given filters. limit/offset/order parameters will be ignored. * @param {number} [gtfsStopId] To get a line ref, first query gtfs_routes Filter by gtfs_stop_id. Only return items which exactly match given string. * @param {string} [gtfsRideIds] To get a line ref, first query gtfs_routes Filter by line_ref. Comma-separated list of values. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserCasesApiInterface */ stopArrivalsListGetRaw(requestParameters: StopArrivalsListGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<StopArrivalPydanticModel>>>; /** * List of the actual arrival times to a specific stop. Currently, only planned time (gtfs) is returned for every stop. * List */ stopArrivalsListGet(requestParameters: StopArrivalsListGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<StopArrivalPydanticModel>>; } /** * */ export class UserCasesApi extends runtime.BaseAPI implements UserCasesApiInterface { /** * List of A comparison between the planned and actual rides of a specific route between the given dates. Currently, the \"actual_rides_count\", will be either None (no actual ride) or equal to the \"planned_rides_count. * List */ async ridesExecutionListGetRaw(requestParameters: RidesExecutionListGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<RideExecutionPydanticModel>>> { if (requestParameters['dateFrom'] == null) { throw new runtime.RequiredError( 'dateFrom', 'Required parameter "dateFrom" was null or undefined when calling ridesExecutionListGet().' ); } if (requestParameters['dateTo'] == null) { throw new runtime.RequiredError( 'dateTo', 'Required parameter "dateTo" was null or undefined when calling ridesExecutionListGet().' ); } if (requestParameters['operatorRef'] == null) { throw new runtime.RequiredError( 'operatorRef', 'Required parameter "operatorRef" was null or undefined when calling ridesExecutionListGet().' ); } if (requestParameters['lineRef'] == null) { throw new runtime.RequiredError( 'lineRef', 'Required parameter "lineRef" was null or undefined when calling ridesExecutionListGet().' ); } const queryParameters: any = {}; if (requestParameters['limit'] != null) { queryParameters['limit'] = requestParameters['limit']; } if (requestParameters['offset'] != null) { queryParameters['offset'] = requestParameters['offset']; } if (requestParameters['getCount'] != null) { queryParameters['get_count'] = requestParameters['getCount']; } if (requestParameters['dateFrom'] != null) { queryParameters['date_from'] = (requestParameters['dateFrom'] as any).toISOString().substring(0,10); } if (requestParameters['dateTo'] != null) { queryParameters['date_to'] = (requestParameters['dateTo'] as any).toISOString().substring(0,10); } if (requestParameters['operatorRef'] != null) { queryParameters['operator_ref'] = requestParameters['operatorRef']; } if (requestParameters['lineRef'] != null) { queryParameters['line_ref'] = requestParameters['lineRef']; } const headerParameters: runtime.HTTPHeaders = {}; let urlPath = `/rides_execution/list`; const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(RideExecutionPydanticModelFromJSON)); } /** * List of A comparison between the planned and actual rides of a specific route between the given dates. Currently, the \"actual_rides_count\", will be either None (no actual ride) or equal to the \"planned_rides_count. * List */ async ridesExecutionListGet(requestParameters: RidesExecutionListGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<RideExecutionPydanticModel>> { const response = await this.ridesExecutionListGetRaw(requestParameters, initOverrides); return await response.value(); } /** * List of the stops timetable of a given bus. Currently, only planned time (gtfs) is returned for every stop. * List */ async routeTimetableListGetRaw(requestParameters: RouteTimetableListGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<RouteTimetablePydanticModel>>> { const queryParameters: any = {}; if (requestParameters['limit'] != null) { queryParameters['limit'] = requestParameters['limit']; } if (requestParameters['offset'] != null) { queryParameters['offset'] = requestParameters['offset']; } if (requestParameters['getCount'] != null) { queryParameters['get_count'] = requestParameters['getCount']; } if (requestParameters['plannedStartTimeDateFrom'] != null) { queryParameters['planned_start_time_date_from'] = (requestParameters['plannedStartTimeDateFrom'] as any).toISOString(); } if (requestParameters['plannedStartTimeDateTo'] != null) { queryParameters['planned_start_time_date_to'] = (requestParameters['plannedStartTimeDateTo'] as any).toISOString(); } if (requestParameters['lineRefs'] != null) { queryParameters['line_refs'] = requestParameters['lineRefs']; } const headerParameters: runtime.HTTPHeaders = {}; let urlPath = `/route_timetable/list`; const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(RouteTimetablePydanticModelFromJSON)); } /** * List of the stops timetable of a given bus. Currently, only planned time (gtfs) is returned for every stop. * List */ async routeTimetableListGet(requestParameters: RouteTimetableListGetRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<RouteTimetablePydanticModel>> { const response = await this.routeTimetableListGetRaw(requestParameters, initOverrides); return await response.value(); } /** * List of the actual arrival times to a specific stop. Currently, only planned time (gtfs) is returned for every stop. * List */ async stopArrivalsListGetRaw(requestParameters: StopArrivalsListGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<StopArrivalPydanticModel>>> { const queryParameters: any = {}; if (requestParameters['limit'] != null) { queryParameters['limit'] = requestParameters['limit']; } if (requestParameters['offset'] != null) { queryParameters['offset'] = requestParameters['offset']; } if (requestParameters['getCount'] != null) { queryParameters['get_count'] = requestParameters['getCount']; } if (requestParameters['gtfsStopId'] != null) { queryParameters['gtfs_stop_id'] = requestParameters['gtfsStopId']; } if (requestParameters['gtfsRideIds'] != null) { queryParameters['gtfs_ride_ids'] = requestParameters['gtfsRideIds']; } const headerParameters: runtime.HTTPHeaders = {}; let urlPath = `/stop_arrivals/list`; const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(StopArrivalPydanticModelFromJSON)); } /** * List of the actual arrival times to a specific stop. Currently, only planned time (gtfs) is returned for every stop. * List */ async stopArrivalsListGet(requestParameters: StopArrivalsListGetRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<StopArrivalPydanticModel>> { const response = await this.stopArrivalsListGetRaw(requestParameters, initOverrides); return await response.value(); } }