onebusaway-sdk 0.1.0.pre.alpha.203
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +124 -0
- data/lib/onebusaway-sdk/base_client.rb +483 -0
- data/lib/onebusaway-sdk/base_model.rb +1188 -0
- data/lib/onebusaway-sdk/base_page.rb +40 -0
- data/lib/onebusaway-sdk/client.rb +181 -0
- data/lib/onebusaway-sdk/errors.rb +187 -0
- data/lib/onebusaway-sdk/extern.rb +10 -0
- data/lib/onebusaway-sdk/models/agencies_with_coverage_list_params.rb +18 -0
- data/lib/onebusaway-sdk/models/agencies_with_coverage_list_response.rb +84 -0
- data/lib/onebusaway-sdk/models/agency_retrieve_params.rb +18 -0
- data/lib/onebusaway-sdk/models/agency_retrieve_response.rb +151 -0
- data/lib/onebusaway-sdk/models/arrival_and_departure_list_params.rb +51 -0
- data/lib/onebusaway-sdk/models/arrival_and_departure_list_response.rb +767 -0
- data/lib/onebusaway-sdk/models/arrival_and_departure_retrieve_params.rb +60 -0
- data/lib/onebusaway-sdk/models/arrival_and_departure_retrieve_response.rb +751 -0
- data/lib/onebusaway-sdk/models/block_retrieve_params.rb +18 -0
- data/lib/onebusaway-sdk/models/block_retrieve_response.rb +205 -0
- data/lib/onebusaway-sdk/models/config_retrieve_params.rb +18 -0
- data/lib/onebusaway-sdk/models/config_retrieve_response.rb +331 -0
- data/lib/onebusaway-sdk/models/current_time_retrieve_params.rb +18 -0
- data/lib/onebusaway-sdk/models/current_time_retrieve_response.rb +67 -0
- data/lib/onebusaway-sdk/models/references.rb +1071 -0
- data/lib/onebusaway-sdk/models/report_problem_with_stop_retrieve_params.rb +117 -0
- data/lib/onebusaway-sdk/models/report_problem_with_trip_retrieve_params.rb +180 -0
- data/lib/onebusaway-sdk/models/response_wrapper.rb +37 -0
- data/lib/onebusaway-sdk/models/route_ids_for_agency_list_params.rb +18 -0
- data/lib/onebusaway-sdk/models/route_ids_for_agency_list_response.rb +45 -0
- data/lib/onebusaway-sdk/models/route_retrieve_params.rb +18 -0
- data/lib/onebusaway-sdk/models/route_retrieve_response.rb +149 -0
- data/lib/onebusaway-sdk/models/routes_for_agency_list_params.rb +18 -0
- data/lib/onebusaway-sdk/models/routes_for_agency_list_response.rb +156 -0
- data/lib/onebusaway-sdk/models/routes_for_location_list_params.rb +70 -0
- data/lib/onebusaway-sdk/models/routes_for_location_list_response.rb +162 -0
- data/lib/onebusaway-sdk/models/schedule_for_route_retrieve_params.rb +30 -0
- data/lib/onebusaway-sdk/models/schedule_for_route_retrieve_response.rb +453 -0
- data/lib/onebusaway-sdk/models/schedule_for_stop_retrieve_params.rb +30 -0
- data/lib/onebusaway-sdk/models/schedule_for_stop_retrieve_response.rb +244 -0
- data/lib/onebusaway-sdk/models/search_for_route_list_params.rb +36 -0
- data/lib/onebusaway-sdk/models/search_for_route_list_response.rb +166 -0
- data/lib/onebusaway-sdk/models/search_for_stop_list_params.rb +36 -0
- data/lib/onebusaway-sdk/models/search_for_stop_list_response.rb +161 -0
- data/lib/onebusaway-sdk/models/shape_retrieve_params.rb +18 -0
- data/lib/onebusaway-sdk/models/shape_retrieve_response.rb +70 -0
- data/lib/onebusaway-sdk/models/stop_ids_for_agency_list_params.rb +18 -0
- data/lib/onebusaway-sdk/models/stop_ids_for_agency_list_response.rb +45 -0
- data/lib/onebusaway-sdk/models/stop_retrieve_params.rb +18 -0
- data/lib/onebusaway-sdk/models/stop_retrieve_response.rb +144 -0
- data/lib/onebusaway-sdk/models/stops_for_agency_list_params.rb +18 -0
- data/lib/onebusaway-sdk/models/stops_for_agency_list_response.rb +146 -0
- data/lib/onebusaway-sdk/models/stops_for_location_list_params.rb +74 -0
- data/lib/onebusaway-sdk/models/stops_for_location_list_response.rb +161 -0
- data/lib/onebusaway-sdk/models/stops_for_route_list_params.rb +40 -0
- data/lib/onebusaway-sdk/models/stops_for_route_list_response.rb +253 -0
- data/lib/onebusaway-sdk/models/trip_detail_retrieve_params.rb +86 -0
- data/lib/onebusaway-sdk/models/trip_detail_retrieve_response.rb +561 -0
- data/lib/onebusaway-sdk/models/trip_for_vehicle_retrieve_params.rb +65 -0
- data/lib/onebusaway-sdk/models/trip_for_vehicle_retrieve_response.rb +561 -0
- data/lib/onebusaway-sdk/models/trip_retrieve_params.rb +18 -0
- data/lib/onebusaway-sdk/models/trip_retrieve_response.rb +160 -0
- data/lib/onebusaway-sdk/models/trips_for_location_list_params.rb +93 -0
- data/lib/onebusaway-sdk/models/trips_for_location_list_response.rb +572 -0
- data/lib/onebusaway-sdk/models/trips_for_route_list_params.rb +52 -0
- data/lib/onebusaway-sdk/models/trips_for_route_list_response.rb +559 -0
- data/lib/onebusaway-sdk/models/vehicles_for_agency_list_params.rb +29 -0
- data/lib/onebusaway-sdk/models/vehicles_for_agency_list_response.rb +529 -0
- data/lib/onebusaway-sdk/pooled_net_requester.rb +170 -0
- data/lib/onebusaway-sdk/request_options.rb +115 -0
- data/lib/onebusaway-sdk/resources/agencies_with_coverage.rb +31 -0
- data/lib/onebusaway-sdk/resources/agency.rb +32 -0
- data/lib/onebusaway-sdk/resources/arrival_and_departure.rb +71 -0
- data/lib/onebusaway-sdk/resources/block.rb +32 -0
- data/lib/onebusaway-sdk/resources/config.rb +30 -0
- data/lib/onebusaway-sdk/resources/current_time.rb +30 -0
- data/lib/onebusaway-sdk/resources/report_problem_with_stop.rb +44 -0
- data/lib/onebusaway-sdk/resources/report_problem_with_trip.rb +54 -0
- data/lib/onebusaway-sdk/resources/route.rb +32 -0
- data/lib/onebusaway-sdk/resources/route_ids_for_agency.rb +32 -0
- data/lib/onebusaway-sdk/resources/routes_for_agency.rb +32 -0
- data/lib/onebusaway-sdk/resources/routes_for_location.rb +44 -0
- data/lib/onebusaway-sdk/resources/schedule_for_route.rb +37 -0
- data/lib/onebusaway-sdk/resources/schedule_for_stop.rb +37 -0
- data/lib/onebusaway-sdk/resources/search_for_route.rb +36 -0
- data/lib/onebusaway-sdk/resources/search_for_stop.rb +36 -0
- data/lib/onebusaway-sdk/resources/shape.rb +32 -0
- data/lib/onebusaway-sdk/resources/stop.rb +32 -0
- data/lib/onebusaway-sdk/resources/stop_ids_for_agency.rb +32 -0
- data/lib/onebusaway-sdk/resources/stops_for_agency.rb +32 -0
- data/lib/onebusaway-sdk/resources/stops_for_location.rb +44 -0
- data/lib/onebusaway-sdk/resources/stops_for_route.rb +38 -0
- data/lib/onebusaway-sdk/resources/trip.rb +32 -0
- data/lib/onebusaway-sdk/resources/trip_details.rb +47 -0
- data/lib/onebusaway-sdk/resources/trip_for_vehicle.rb +45 -0
- data/lib/onebusaway-sdk/resources/trips_for_location.rb +48 -0
- data/lib/onebusaway-sdk/resources/trips_for_route.rb +41 -0
- data/lib/onebusaway-sdk/resources/vehicles_for_agency.rb +36 -0
- data/lib/onebusaway-sdk/util.rb +512 -0
- data/lib/onebusaway-sdk/version.rb +5 -0
- data/lib/onebusaway-sdk.rb +116 -0
- data/manifest.yaml +13 -0
- data/rbi/lib/onebusaway-sdk/base_client.rbi +162 -0
- data/rbi/lib/onebusaway-sdk/base_model.rbi +478 -0
- data/rbi/lib/onebusaway-sdk/base_page.rbi +39 -0
- data/rbi/lib/onebusaway-sdk/client.rbi +154 -0
- data/rbi/lib/onebusaway-sdk/errors.rbi +145 -0
- data/rbi/lib/onebusaway-sdk/extern.rbi +7 -0
- data/rbi/lib/onebusaway-sdk/models/agencies_with_coverage_list_params.rbi +18 -0
- data/rbi/lib/onebusaway-sdk/models/agencies_with_coverage_list_response.rbi +131 -0
- data/rbi/lib/onebusaway-sdk/models/agency_retrieve_params.rbi +18 -0
- data/rbi/lib/onebusaway-sdk/models/agency_retrieve_response.rbi +210 -0
- data/rbi/lib/onebusaway-sdk/models/arrival_and_departure_list_params.rbi +60 -0
- data/rbi/lib/onebusaway-sdk/models/arrival_and_departure_list_response.rbi +914 -0
- data/rbi/lib/onebusaway-sdk/models/arrival_and_departure_retrieve_params.rbi +87 -0
- data/rbi/lib/onebusaway-sdk/models/arrival_and_departure_retrieve_response.rbi +857 -0
- data/rbi/lib/onebusaway-sdk/models/block_retrieve_params.rbi +18 -0
- data/rbi/lib/onebusaway-sdk/models/block_retrieve_response.rbi +383 -0
- data/rbi/lib/onebusaway-sdk/models/config_retrieve_params.rbi +18 -0
- data/rbi/lib/onebusaway-sdk/models/config_retrieve_response.rbi +389 -0
- data/rbi/lib/onebusaway-sdk/models/current_time_retrieve_params.rbi +18 -0
- data/rbi/lib/onebusaway-sdk/models/current_time_retrieve_response.rbi +95 -0
- data/rbi/lib/onebusaway-sdk/models/references.rbi +1265 -0
- data/rbi/lib/onebusaway-sdk/models/report_problem_with_stop_retrieve_params.rbi +101 -0
- data/rbi/lib/onebusaway-sdk/models/report_problem_with_trip_retrieve_params.rbi +157 -0
- data/rbi/lib/onebusaway-sdk/models/response_wrapper.rbi +47 -0
- data/rbi/lib/onebusaway-sdk/models/route_ids_for_agency_list_params.rbi +18 -0
- data/rbi/lib/onebusaway-sdk/models/route_ids_for_agency_list_response.rbi +68 -0
- data/rbi/lib/onebusaway-sdk/models/route_retrieve_params.rbi +18 -0
- data/rbi/lib/onebusaway-sdk/models/route_retrieve_response.rbi +200 -0
- data/rbi/lib/onebusaway-sdk/models/routes_for_agency_list_params.rbi +18 -0
- data/rbi/lib/onebusaway-sdk/models/routes_for_agency_list_response.rbi +210 -0
- data/rbi/lib/onebusaway-sdk/models/routes_for_location_list_params.rbi +90 -0
- data/rbi/lib/onebusaway-sdk/models/routes_for_location_list_response.rbi +220 -0
- data/rbi/lib/onebusaway-sdk/models/schedule_for_route_retrieve_params.rbi +34 -0
- data/rbi/lib/onebusaway-sdk/models/schedule_for_route_retrieve_response.rbi +675 -0
- data/rbi/lib/onebusaway-sdk/models/schedule_for_stop_retrieve_params.rbi +34 -0
- data/rbi/lib/onebusaway-sdk/models/schedule_for_stop_retrieve_response.rbi +457 -0
- data/rbi/lib/onebusaway-sdk/models/search_for_route_list_params.rbi +43 -0
- data/rbi/lib/onebusaway-sdk/models/search_for_route_list_response.rbi +220 -0
- data/rbi/lib/onebusaway-sdk/models/search_for_stop_list_params.rbi +43 -0
- data/rbi/lib/onebusaway-sdk/models/search_for_stop_list_response.rbi +231 -0
- data/rbi/lib/onebusaway-sdk/models/shape_retrieve_params.rbi +18 -0
- data/rbi/lib/onebusaway-sdk/models/shape_retrieve_response.rbi +103 -0
- data/rbi/lib/onebusaway-sdk/models/stop_ids_for_agency_list_params.rbi +18 -0
- data/rbi/lib/onebusaway-sdk/models/stop_ids_for_agency_list_response.rbi +68 -0
- data/rbi/lib/onebusaway-sdk/models/stop_retrieve_params.rbi +18 -0
- data/rbi/lib/onebusaway-sdk/models/stop_retrieve_response.rbi +211 -0
- data/rbi/lib/onebusaway-sdk/models/stops_for_agency_list_params.rbi +18 -0
- data/rbi/lib/onebusaway-sdk/models/stops_for_agency_list_response.rbi +210 -0
- data/rbi/lib/onebusaway-sdk/models/stops_for_location_list_params.rbi +90 -0
- data/rbi/lib/onebusaway-sdk/models/stops_for_location_list_response.rbi +231 -0
- data/rbi/lib/onebusaway-sdk/models/stops_for_route_list_params.rbi +48 -0
- data/rbi/lib/onebusaway-sdk/models/stops_for_route_list_response.rbi +307 -0
- data/rbi/lib/onebusaway-sdk/models/trip_detail_retrieve_params.rbi +87 -0
- data/rbi/lib/onebusaway-sdk/models/trip_detail_retrieve_response.rbi +702 -0
- data/rbi/lib/onebusaway-sdk/models/trip_for_vehicle_retrieve_params.rbi +76 -0
- data/rbi/lib/onebusaway-sdk/models/trip_for_vehicle_retrieve_response.rbi +704 -0
- data/rbi/lib/onebusaway-sdk/models/trip_retrieve_params.rbi +18 -0
- data/rbi/lib/onebusaway-sdk/models/trip_retrieve_response.rbi +211 -0
- data/rbi/lib/onebusaway-sdk/models/trips_for_location_list_params.rbi +109 -0
- data/rbi/lib/onebusaway-sdk/models/trips_for_location_list_response.rbi +715 -0
- data/rbi/lib/onebusaway-sdk/models/trips_for_route_list_params.rbi +60 -0
- data/rbi/lib/onebusaway-sdk/models/trips_for_route_list_response.rbi +705 -0
- data/rbi/lib/onebusaway-sdk/models/vehicles_for_agency_list_params.rbi +35 -0
- data/rbi/lib/onebusaway-sdk/models/vehicles_for_agency_list_response.rbi +633 -0
- data/rbi/lib/onebusaway-sdk/pooled_net_requester.rbi +36 -0
- data/rbi/lib/onebusaway-sdk/request_options.rbi +84 -0
- data/rbi/lib/onebusaway-sdk/resources/agencies_with_coverage.rbi +18 -0
- data/rbi/lib/onebusaway-sdk/resources/agency.rbi +21 -0
- data/rbi/lib/onebusaway-sdk/resources/arrival_and_departure.rbi +47 -0
- data/rbi/lib/onebusaway-sdk/resources/block.rbi +21 -0
- data/rbi/lib/onebusaway-sdk/resources/config.rbi +18 -0
- data/rbi/lib/onebusaway-sdk/resources/current_time.rbi +18 -0
- data/rbi/lib/onebusaway-sdk/resources/report_problem_with_stop.rbi +34 -0
- data/rbi/lib/onebusaway-sdk/resources/report_problem_with_trip.rbi +44 -0
- data/rbi/lib/onebusaway-sdk/resources/route.rbi +21 -0
- data/rbi/lib/onebusaway-sdk/resources/route_ids_for_agency.rbi +21 -0
- data/rbi/lib/onebusaway-sdk/resources/routes_for_agency.rbi +21 -0
- data/rbi/lib/onebusaway-sdk/resources/routes_for_location.rbi +26 -0
- data/rbi/lib/onebusaway-sdk/resources/schedule_for_route.rbi +22 -0
- data/rbi/lib/onebusaway-sdk/resources/schedule_for_stop.rbi +22 -0
- data/rbi/lib/onebusaway-sdk/resources/search_for_route.rbi +22 -0
- data/rbi/lib/onebusaway-sdk/resources/search_for_stop.rbi +22 -0
- data/rbi/lib/onebusaway-sdk/resources/shape.rbi +21 -0
- data/rbi/lib/onebusaway-sdk/resources/stop.rbi +21 -0
- data/rbi/lib/onebusaway-sdk/resources/stop_ids_for_agency.rbi +21 -0
- data/rbi/lib/onebusaway-sdk/resources/stops_for_agency.rbi +21 -0
- data/rbi/lib/onebusaway-sdk/resources/stops_for_location.rbi +26 -0
- data/rbi/lib/onebusaway-sdk/resources/stops_for_route.rbi +23 -0
- data/rbi/lib/onebusaway-sdk/resources/trip.rbi +21 -0
- data/rbi/lib/onebusaway-sdk/resources/trip_details.rbi +34 -0
- data/rbi/lib/onebusaway-sdk/resources/trip_for_vehicle.rbi +32 -0
- data/rbi/lib/onebusaway-sdk/resources/trips_for_location.rbi +36 -0
- data/rbi/lib/onebusaway-sdk/resources/trips_for_route.rbi +24 -0
- data/rbi/lib/onebusaway-sdk/resources/vehicles_for_agency.rbi +22 -0
- data/rbi/lib/onebusaway-sdk/util.rbi +136 -0
- data/rbi/lib/onebusaway-sdk/version.rbi +5 -0
- data/sig/onebusaway-sdk/base_client.rbs +101 -0
- data/sig/onebusaway-sdk/base_model.rbs +244 -0
- data/sig/onebusaway-sdk/base_page.rbs +20 -0
- data/sig/onebusaway-sdk/client.rbs +80 -0
- data/sig/onebusaway-sdk/errors.rbs +98 -0
- data/sig/onebusaway-sdk/extern.rbs +4 -0
- data/sig/onebusaway-sdk/models/agencies_with_coverage_list_params.rbs +20 -0
- data/sig/onebusaway-sdk/models/agencies_with_coverage_list_response.rbs +85 -0
- data/sig/onebusaway-sdk/models/agency_retrieve_params.rbs +19 -0
- data/sig/onebusaway-sdk/models/agency_retrieve_response.rbs +115 -0
- data/sig/onebusaway-sdk/models/arrival_and_departure_list_params.rbs +38 -0
- data/sig/onebusaway-sdk/models/arrival_and_departure_list_response.rbs +447 -0
- data/sig/onebusaway-sdk/models/arrival_and_departure_retrieve_params.rbs +50 -0
- data/sig/onebusaway-sdk/models/arrival_and_departure_retrieve_response.rbs +427 -0
- data/sig/onebusaway-sdk/models/block_retrieve_params.rbs +19 -0
- data/sig/onebusaway-sdk/models/block_retrieve_response.rbs +201 -0
- data/sig/onebusaway-sdk/models/config_retrieve_params.rbs +19 -0
- data/sig/onebusaway-sdk/models/config_retrieve_response.rbs +227 -0
- data/sig/onebusaway-sdk/models/current_time_retrieve_params.rbs +19 -0
- data/sig/onebusaway-sdk/models/current_time_retrieve_response.rbs +64 -0
- data/sig/onebusaway-sdk/models/references.rbs +732 -0
- data/sig/onebusaway-sdk/models/report_problem_with_stop_retrieve_params.rbs +73 -0
- data/sig/onebusaway-sdk/models/report_problem_with_trip_retrieve_params.rbs +105 -0
- data/sig/onebusaway-sdk/models/response_wrapper.rbs +30 -0
- data/sig/onebusaway-sdk/models/route_ids_for_agency_list_params.rbs +20 -0
- data/sig/onebusaway-sdk/models/route_ids_for_agency_list_response.rbs +49 -0
- data/sig/onebusaway-sdk/models/route_retrieve_params.rbs +19 -0
- data/sig/onebusaway-sdk/models/route_retrieve_response.rbs +113 -0
- data/sig/onebusaway-sdk/models/routes_for_agency_list_params.rbs +20 -0
- data/sig/onebusaway-sdk/models/routes_for_agency_list_response.rbs +117 -0
- data/sig/onebusaway-sdk/models/routes_for_location_list_params.rbs +56 -0
- data/sig/onebusaway-sdk/models/routes_for_location_list_response.rbs +123 -0
- data/sig/onebusaway-sdk/models/schedule_for_route_retrieve_params.rbs +24 -0
- data/sig/onebusaway-sdk/models/schedule_for_route_retrieve_response.rbs +341 -0
- data/sig/onebusaway-sdk/models/schedule_for_stop_retrieve_params.rbs +24 -0
- data/sig/onebusaway-sdk/models/schedule_for_stop_retrieve_response.rbs +215 -0
- data/sig/onebusaway-sdk/models/search_for_route_list_params.rbs +30 -0
- data/sig/onebusaway-sdk/models/search_for_route_list_response.rbs +125 -0
- data/sig/onebusaway-sdk/models/search_for_stop_list_params.rbs +30 -0
- data/sig/onebusaway-sdk/models/search_for_stop_list_response.rbs +123 -0
- data/sig/onebusaway-sdk/models/shape_retrieve_params.rbs +19 -0
- data/sig/onebusaway-sdk/models/shape_retrieve_response.rbs +64 -0
- data/sig/onebusaway-sdk/models/stop_ids_for_agency_list_params.rbs +20 -0
- data/sig/onebusaway-sdk/models/stop_ids_for_agency_list_response.rbs +49 -0
- data/sig/onebusaway-sdk/models/stop_retrieve_params.rbs +19 -0
- data/sig/onebusaway-sdk/models/stop_retrieve_response.rbs +111 -0
- data/sig/onebusaway-sdk/models/stops_for_agency_list_params.rbs +19 -0
- data/sig/onebusaway-sdk/models/stops_for_agency_list_response.rbs +105 -0
- data/sig/onebusaway-sdk/models/stops_for_location_list_params.rbs +56 -0
- data/sig/onebusaway-sdk/models/stops_for_location_list_response.rbs +123 -0
- data/sig/onebusaway-sdk/models/stops_for_route_list_params.rbs +33 -0
- data/sig/onebusaway-sdk/models/stops_for_route_list_response.rbs +206 -0
- data/sig/onebusaway-sdk/models/trip_detail_retrieve_params.rbs +54 -0
- data/sig/onebusaway-sdk/models/trip_detail_retrieve_response.rbs +375 -0
- data/sig/onebusaway-sdk/models/trip_for_vehicle_retrieve_params.rbs +48 -0
- data/sig/onebusaway-sdk/models/trip_for_vehicle_retrieve_response.rbs +377 -0
- data/sig/onebusaway-sdk/models/trip_retrieve_params.rbs +19 -0
- data/sig/onebusaway-sdk/models/trip_retrieve_response.rbs +119 -0
- data/sig/onebusaway-sdk/models/trips_for_location_list_params.rbs +58 -0
- data/sig/onebusaway-sdk/models/trips_for_location_list_response.rbs +379 -0
- data/sig/onebusaway-sdk/models/trips_for_route_list_params.rbs +38 -0
- data/sig/onebusaway-sdk/models/trips_for_route_list_response.rbs +371 -0
- data/sig/onebusaway-sdk/models/vehicles_for_agency_list_params.rbs +24 -0
- data/sig/onebusaway-sdk/models/vehicles_for_agency_list_response.rbs +332 -0
- data/sig/onebusaway-sdk/pooled_net_requester.rbs +28 -0
- data/sig/onebusaway-sdk/request_options.rbs +42 -0
- data/sig/onebusaway-sdk/resources/agencies_with_coverage.rbs +16 -0
- data/sig/onebusaway-sdk/resources/agency.rbs +18 -0
- data/sig/onebusaway-sdk/resources/arrival_and_departure.rbs +37 -0
- data/sig/onebusaway-sdk/resources/block.rbs +18 -0
- data/sig/onebusaway-sdk/resources/config.rbs +16 -0
- data/sig/onebusaway-sdk/resources/current_time.rbs +16 -0
- data/sig/onebusaway-sdk/resources/report_problem_with_stop.rbs +23 -0
- data/sig/onebusaway-sdk/resources/report_problem_with_trip.rbs +28 -0
- data/sig/onebusaway-sdk/resources/route.rbs +18 -0
- data/sig/onebusaway-sdk/resources/route_ids_for_agency.rbs +18 -0
- data/sig/onebusaway-sdk/resources/routes_for_agency.rbs +18 -0
- data/sig/onebusaway-sdk/resources/routes_for_location.rbs +22 -0
- data/sig/onebusaway-sdk/resources/schedule_for_route.rbs +19 -0
- data/sig/onebusaway-sdk/resources/schedule_for_stop.rbs +19 -0
- data/sig/onebusaway-sdk/resources/search_for_route.rbs +18 -0
- data/sig/onebusaway-sdk/resources/search_for_stop.rbs +18 -0
- data/sig/onebusaway-sdk/resources/shape.rbs +18 -0
- data/sig/onebusaway-sdk/resources/stop.rbs +18 -0
- data/sig/onebusaway-sdk/resources/stop_ids_for_agency.rbs +18 -0
- data/sig/onebusaway-sdk/resources/stops_for_agency.rbs +18 -0
- data/sig/onebusaway-sdk/resources/stops_for_location.rbs +22 -0
- data/sig/onebusaway-sdk/resources/stops_for_route.rbs +20 -0
- data/sig/onebusaway-sdk/resources/trip.rbs +18 -0
- data/sig/onebusaway-sdk/resources/trip_details.rbs +23 -0
- data/sig/onebusaway-sdk/resources/trip_for_vehicle.rbs +22 -0
- data/sig/onebusaway-sdk/resources/trips_for_location.rbs +23 -0
- data/sig/onebusaway-sdk/resources/trips_for_route.rbs +21 -0
- data/sig/onebusaway-sdk/resources/vehicles_for_agency.rbs +19 -0
- data/sig/onebusaway-sdk/util.rbs +90 -0
- data/sig/onebusaway-sdk/version.rbs +3 -0
- metadata +350 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: b3972cddd6e4f812ab01dc163dc681f89a9c9cfdac66b7c3e622c70f1078d944
|
|
4
|
+
data.tar.gz: 60794e144c2b2fca12dd3a41d62cea6b4df672df1718ada535bb09f1cb4ab8f1
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 3589ab16c97b353d8cae4574225f06ad6bf225a9049a7432dfb7f6ae2d19bebeafd31c7186603426ac23f3f7002bcd40d58147bb1e1d7f436f770d4b2aee95a1
|
|
7
|
+
data.tar.gz: 348ea1e6a603b47409649f52aa23ef4c0e4a7eec298ea349b00d0739c1d12a4b6a0fab4dedcd87a3d24204177408ec7292e0bb386cc7447ef11f02fb7e7050a7
|
data/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Onebusaway SDK Ruby API library
|
|
2
|
+
|
|
3
|
+
The Onebusaway SDK Ruby library provides convenient access to the Onebusaway SDK REST API from any Ruby 3.0.0+
|
|
4
|
+
application.
|
|
5
|
+
|
|
6
|
+
It is generated with [Stainless](https://www.stainlessapi.com/).
|
|
7
|
+
|
|
8
|
+
## Documentation
|
|
9
|
+
|
|
10
|
+
Documentation for the most recent release of this gem can be found [on RubyDoc](https://gemdocs.org/gems/onebusaway-sdk/latest).
|
|
11
|
+
|
|
12
|
+
The underlying REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org).
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
To use this gem during the beta, install directly from GitHub with Bundler by
|
|
17
|
+
adding the following to your application's `Gemfile`:
|
|
18
|
+
|
|
19
|
+
```ruby
|
|
20
|
+
gem "onebusaway-sdk", git: "https://github.com/OneBusAway/ruby-sdk", branch: "main"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
To fetch an initial copy of the gem:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
bundle install
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
To update the version used by your application when updates are pushed to
|
|
30
|
+
GitHub:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
bundle update onebusaway-sdk
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
```ruby
|
|
39
|
+
require "bundler/setup"
|
|
40
|
+
require "onebusaway-sdk"
|
|
41
|
+
|
|
42
|
+
onebusaway_sdk = OnebusawaySDK::Client.new(
|
|
43
|
+
api_key: "My API Key" # defaults to ENV["ONEBUSAWAY_API_KEY"]
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
current_time = onebusaway_sdk.current_time.retrieve
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Errors
|
|
50
|
+
|
|
51
|
+
When the library is unable to connect to the API, or if the API returns a
|
|
52
|
+
non-success status code (i.e., 4xx or 5xx response), a subclass of
|
|
53
|
+
`OnebusawaySDK::Error` will be thrown:
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
begin
|
|
57
|
+
current_time = onebusaway_sdk.current_time.retrieve
|
|
58
|
+
rescue OnebusawaySDK::Error => e
|
|
59
|
+
puts(e.status) # 400
|
|
60
|
+
end
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Error codes are as followed:
|
|
64
|
+
|
|
65
|
+
| Cause | Error Type |
|
|
66
|
+
| ---------------- | -------------------------- |
|
|
67
|
+
| HTTP 400 | `BadRequestError` |
|
|
68
|
+
| HTTP 401 | `AuthenticationError` |
|
|
69
|
+
| HTTP 403 | `PermissionDeniedError` |
|
|
70
|
+
| HTTP 404 | `NotFoundError` |
|
|
71
|
+
| HTTP 409 | `ConflictError` |
|
|
72
|
+
| HTTP 422 | `UnprocessableEntityError` |
|
|
73
|
+
| HTTP 429 | `RateLimitError` |
|
|
74
|
+
| HTTP >=500 | `InternalServerError` |
|
|
75
|
+
| Other HTTP error | `APIStatusError` |
|
|
76
|
+
| Timeout | `APITimeoutError` |
|
|
77
|
+
| Network error | `APIConnectionError` |
|
|
78
|
+
|
|
79
|
+
### Retries
|
|
80
|
+
|
|
81
|
+
Certain errors will be automatically retried 2 times by default, with a short
|
|
82
|
+
exponential backoff. Connection errors (for example, due to a network
|
|
83
|
+
connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors,
|
|
84
|
+
and timeouts will all be retried by default.
|
|
85
|
+
|
|
86
|
+
You can use the `max_retries` option to configure or disable this:
|
|
87
|
+
|
|
88
|
+
```ruby
|
|
89
|
+
# Configure the default for all requests:
|
|
90
|
+
onebusaway_sdk = OnebusawaySDK::Client.new(
|
|
91
|
+
max_retries: 0 # default is 2
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
# Or, configure per-request:
|
|
95
|
+
onebusaway_sdk.current_time.retrieve(request_options: {max_retries: 5})
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Timeouts
|
|
99
|
+
|
|
100
|
+
By default, requests will time out after 60 seconds.
|
|
101
|
+
Timeouts are applied separately to the initial connection and the overall request time,
|
|
102
|
+
so in some cases a request could wait 2\*timeout seconds before it fails.
|
|
103
|
+
|
|
104
|
+
You can use the `timeout` option to configure or disable this:
|
|
105
|
+
|
|
106
|
+
```ruby
|
|
107
|
+
# Configure the default for all requests:
|
|
108
|
+
onebusaway_sdk = OnebusawaySDK::Client.new(
|
|
109
|
+
timeout: nil # default is 60
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
# Or, configure per-request:
|
|
113
|
+
onebusaway_sdk.current_time.retrieve(request_options: {timeout: 5})
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Versioning
|
|
117
|
+
|
|
118
|
+
This package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the
|
|
119
|
+
library is in initial development and has a major version of `0`, APIs may change
|
|
120
|
+
at any time.
|
|
121
|
+
|
|
122
|
+
## Requirements
|
|
123
|
+
|
|
124
|
+
Ruby 3.0 or higher.
|
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OnebusawaySDK
|
|
4
|
+
# @private
|
|
5
|
+
#
|
|
6
|
+
# @abstract
|
|
7
|
+
#
|
|
8
|
+
class BaseClient
|
|
9
|
+
# from whatwg fetch spec
|
|
10
|
+
MAX_REDIRECTS = 20
|
|
11
|
+
|
|
12
|
+
# rubocop:disable Style/MutableConstant
|
|
13
|
+
PLATFORM_HEADERS = {
|
|
14
|
+
"x-stainless-arch" => OnebusawaySDK::Util.arch,
|
|
15
|
+
"x-stainless-lang" => "ruby",
|
|
16
|
+
"x-stainless-os" => OnebusawaySDK::Util.os,
|
|
17
|
+
"x-stainless-package-version" => OnebusawaySDK::VERSION,
|
|
18
|
+
"x-stainless-runtime" => ::RUBY_ENGINE,
|
|
19
|
+
"x-stainless-runtime-version" => ::RUBY_ENGINE_VERSION
|
|
20
|
+
}
|
|
21
|
+
# rubocop:enable Style/MutableConstant
|
|
22
|
+
|
|
23
|
+
class << self
|
|
24
|
+
# @private
|
|
25
|
+
#
|
|
26
|
+
# @param req [Hash{Symbol=>Object}]
|
|
27
|
+
#
|
|
28
|
+
# @raise [ArgumentError]
|
|
29
|
+
#
|
|
30
|
+
def validate!(req)
|
|
31
|
+
keys = [:method, :path, :query, :headers, :body, :unwrap, :page, :model, :options]
|
|
32
|
+
case req
|
|
33
|
+
in Hash
|
|
34
|
+
req.each_key do |k|
|
|
35
|
+
unless keys.include?(k)
|
|
36
|
+
raise ArgumentError.new("Request `req` keys must be one of #{keys}, got #{k.inspect}")
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
else
|
|
40
|
+
raise ArgumentError.new("Request `req` must be a Hash or RequestOptions, got #{req.inspect}")
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# @private
|
|
45
|
+
#
|
|
46
|
+
# @param status [Integer]
|
|
47
|
+
# @param headers [Hash{String=>String}, Net::HTTPHeader]
|
|
48
|
+
#
|
|
49
|
+
# @return [Boolean]
|
|
50
|
+
#
|
|
51
|
+
def should_retry?(status, headers:)
|
|
52
|
+
coerced = OnebusawaySDK::Util.coerce_boolean(headers["x-should-retry"])
|
|
53
|
+
case [coerced, status]
|
|
54
|
+
in [true | false, _]
|
|
55
|
+
coerced
|
|
56
|
+
in [_, 408 | 409 | 429 | (500..)]
|
|
57
|
+
# retry on:
|
|
58
|
+
# 408: timeouts
|
|
59
|
+
# 409: locks
|
|
60
|
+
# 429: rate limits
|
|
61
|
+
# 500+: unknown errors
|
|
62
|
+
true
|
|
63
|
+
else
|
|
64
|
+
false
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# @private
|
|
69
|
+
#
|
|
70
|
+
# @param request [Hash{Symbol=>Object}] .
|
|
71
|
+
#
|
|
72
|
+
# @option request [Symbol] :method
|
|
73
|
+
#
|
|
74
|
+
# @option request [URI::Generic] :url
|
|
75
|
+
#
|
|
76
|
+
# @option request [Hash{String=>String}] :headers
|
|
77
|
+
#
|
|
78
|
+
# @option request [Object] :body
|
|
79
|
+
#
|
|
80
|
+
# @option request [Integer] :max_retries
|
|
81
|
+
#
|
|
82
|
+
# @option request [Float] :timeout
|
|
83
|
+
#
|
|
84
|
+
# @param status [Integer]
|
|
85
|
+
#
|
|
86
|
+
# @param response_headers [Hash{String=>String}, Net::HTTPHeader]
|
|
87
|
+
#
|
|
88
|
+
# @return [Hash{Symbol=>Object}]
|
|
89
|
+
#
|
|
90
|
+
def follow_redirect(request, status:, response_headers:)
|
|
91
|
+
method, url, headers = request.fetch_values(:method, :url, :headers)
|
|
92
|
+
location =
|
|
93
|
+
Kernel.then do
|
|
94
|
+
URI.join(url, response_headers["location"])
|
|
95
|
+
rescue ArgumentError
|
|
96
|
+
message = "Server responded with status #{status} but no valid location header."
|
|
97
|
+
raise OnebusawaySDK::APIConnectionError.new(url: url, message: message)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
request = {**request, url: location}
|
|
101
|
+
|
|
102
|
+
case [url.scheme, location.scheme]
|
|
103
|
+
in ["https", "http"]
|
|
104
|
+
message = "Tried to redirect to a insecure URL"
|
|
105
|
+
raise OnebusawaySDK::APIConnectionError.new(url: url, message: message)
|
|
106
|
+
else
|
|
107
|
+
nil
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# from whatwg fetch spec
|
|
111
|
+
case [status, method]
|
|
112
|
+
in [301 | 302, :post] | [303, _]
|
|
113
|
+
drop = %w[content-encoding content-language content-length content-location content-type]
|
|
114
|
+
request = {
|
|
115
|
+
**request,
|
|
116
|
+
method: method == :head ? :head : :get,
|
|
117
|
+
headers: headers.except(*drop),
|
|
118
|
+
body: nil
|
|
119
|
+
}
|
|
120
|
+
else
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# from undici
|
|
124
|
+
if OnebusawaySDK::Util.uri_origin(url) != OnebusawaySDK::Util.uri_origin(location)
|
|
125
|
+
drop = %w[authorization cookie host proxy-authorization]
|
|
126
|
+
request = {**request, headers: request.fetch(:headers).except(*drop)}
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
request
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# @private
|
|
134
|
+
#
|
|
135
|
+
# @return [OnebusawaySDK::PooledNetRequester]
|
|
136
|
+
attr_accessor :requester
|
|
137
|
+
|
|
138
|
+
# @private
|
|
139
|
+
#
|
|
140
|
+
# @param base_url [String]
|
|
141
|
+
# @param timeout [Float]
|
|
142
|
+
# @param max_retries [Integer]
|
|
143
|
+
# @param initial_retry_delay [Float]
|
|
144
|
+
# @param max_retry_delay [Float]
|
|
145
|
+
# @param headers [Hash{String=>String, nil}]
|
|
146
|
+
# @param idempotency_header [String, nil]
|
|
147
|
+
#
|
|
148
|
+
def initialize(
|
|
149
|
+
base_url:,
|
|
150
|
+
timeout: 0.0,
|
|
151
|
+
max_retries: 0,
|
|
152
|
+
initial_retry_delay: 0.0,
|
|
153
|
+
max_retry_delay: 0.0,
|
|
154
|
+
headers: {},
|
|
155
|
+
idempotency_header: nil
|
|
156
|
+
)
|
|
157
|
+
@requester = OnebusawaySDK::PooledNetRequester.new
|
|
158
|
+
@headers = OnebusawaySDK::Util.normalized_headers(
|
|
159
|
+
self.class::PLATFORM_HEADERS,
|
|
160
|
+
{
|
|
161
|
+
"accept" => "application/json",
|
|
162
|
+
"content-type" => "application/json"
|
|
163
|
+
},
|
|
164
|
+
headers
|
|
165
|
+
)
|
|
166
|
+
@base_url = OnebusawaySDK::Util.parse_uri(base_url)
|
|
167
|
+
@idempotency_header = idempotency_header&.to_s&.downcase
|
|
168
|
+
@max_retries = max_retries
|
|
169
|
+
@timeout = timeout
|
|
170
|
+
@initial_retry_delay = initial_retry_delay
|
|
171
|
+
@max_retry_delay = max_retry_delay
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# @private
|
|
175
|
+
#
|
|
176
|
+
# @return [Hash{String=>String}]
|
|
177
|
+
#
|
|
178
|
+
private def auth_query = {}
|
|
179
|
+
|
|
180
|
+
# @private
|
|
181
|
+
#
|
|
182
|
+
# @return [String]
|
|
183
|
+
#
|
|
184
|
+
private def generate_idempotency_key = "stainless-ruby-retry-#{SecureRandom.uuid}"
|
|
185
|
+
|
|
186
|
+
# @private
|
|
187
|
+
#
|
|
188
|
+
# @param req [Hash{Symbol=>Object}] .
|
|
189
|
+
#
|
|
190
|
+
# @option req [Symbol] :method
|
|
191
|
+
#
|
|
192
|
+
# @option req [String, Array<String>] :path
|
|
193
|
+
#
|
|
194
|
+
# @option req [Hash{String=>Array<String>, String, nil}, nil] :query
|
|
195
|
+
#
|
|
196
|
+
# @option req [Hash{String=>String, nil}, nil] :headers
|
|
197
|
+
#
|
|
198
|
+
# @option req [Object, nil] :body
|
|
199
|
+
#
|
|
200
|
+
# @option req [Symbol, nil] :unwrap
|
|
201
|
+
#
|
|
202
|
+
# @option req [Class, nil] :page
|
|
203
|
+
#
|
|
204
|
+
# @option req [OnebusawaySDK::Converter, Class, nil] :model
|
|
205
|
+
#
|
|
206
|
+
# @param opts [Hash{Symbol=>Object}] .
|
|
207
|
+
#
|
|
208
|
+
# @option opts [String, nil] :idempotency_key
|
|
209
|
+
#
|
|
210
|
+
# @option opts [Hash{String=>Array<String>, String, nil}, nil] :extra_query
|
|
211
|
+
#
|
|
212
|
+
# @option opts [Hash{String=>String, nil}, nil] :extra_headers
|
|
213
|
+
#
|
|
214
|
+
# @option opts [Hash{Symbol=>Object}, nil] :extra_body
|
|
215
|
+
#
|
|
216
|
+
# @option opts [Integer, nil] :max_retries
|
|
217
|
+
#
|
|
218
|
+
# @option opts [Float, nil] :timeout
|
|
219
|
+
#
|
|
220
|
+
# @return [Hash{Symbol=>Object}]
|
|
221
|
+
#
|
|
222
|
+
private def build_request(req, opts)
|
|
223
|
+
method, uninterpolated_path = req.fetch_values(:method, :path)
|
|
224
|
+
|
|
225
|
+
path = OnebusawaySDK::Util.interpolate_path(uninterpolated_path)
|
|
226
|
+
|
|
227
|
+
query = OnebusawaySDK::Util.deep_merge(auth_query, req[:query].to_h, opts[:extra_query].to_h)
|
|
228
|
+
|
|
229
|
+
headers = OnebusawaySDK::Util.normalized_headers(
|
|
230
|
+
@headers,
|
|
231
|
+
req[:headers].to_h,
|
|
232
|
+
opts[:extra_headers].to_h
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
if @idempotency_header &&
|
|
236
|
+
!headers.key?(@idempotency_header) &&
|
|
237
|
+
!Net::HTTP::IDEMPOTENT_METHODS_.include?(method.to_s.upcase)
|
|
238
|
+
headers[@idempotency_header] = opts.fetch(:idempotency_key) { generate_idempotency_key }
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
unless headers.key?("x-stainless-retry-count")
|
|
242
|
+
headers["x-stainless-retry-count"] = "0"
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
timeout = opts.fetch(:timeout, @timeout).to_f.clamp((0..))
|
|
246
|
+
unless headers.key?("x-stainless-read-timeout") || timeout.zero?
|
|
247
|
+
headers["x-stainless-read-timeout"] = timeout.to_s
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
headers.reject! { |_, v| v.to_s.empty? }
|
|
251
|
+
|
|
252
|
+
body =
|
|
253
|
+
case method
|
|
254
|
+
in :get | :head | :options | :trace
|
|
255
|
+
nil
|
|
256
|
+
else
|
|
257
|
+
OnebusawaySDK::Util.deep_merge(*[req[:body], opts[:extra_body]].compact)
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
headers, encoded = OnebusawaySDK::Util.encode_content(headers, body)
|
|
261
|
+
{
|
|
262
|
+
method: method,
|
|
263
|
+
url: OnebusawaySDK::Util.join_parsed_uri(@base_url, {**req, path: path, query: query}),
|
|
264
|
+
headers: headers,
|
|
265
|
+
body: encoded,
|
|
266
|
+
max_retries: opts.fetch(:max_retries, @max_retries),
|
|
267
|
+
timeout: timeout
|
|
268
|
+
}
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
# @private
|
|
272
|
+
#
|
|
273
|
+
# @param headers [Hash{String=>String}]
|
|
274
|
+
# @param retry_count [Integer]
|
|
275
|
+
#
|
|
276
|
+
# @return [Float]
|
|
277
|
+
#
|
|
278
|
+
private def retry_delay(headers, retry_count:)
|
|
279
|
+
# Non-standard extension
|
|
280
|
+
span = Float(headers["retry-after-ms"], exception: false)&.then { _1 / 1000 }
|
|
281
|
+
return span if span
|
|
282
|
+
|
|
283
|
+
retry_header = headers["retry-after"]
|
|
284
|
+
return span if (span = Float(retry_header, exception: false))
|
|
285
|
+
|
|
286
|
+
span = retry_header&.then do
|
|
287
|
+
Time.httpdate(_1) - Time.now
|
|
288
|
+
rescue ArgumentError
|
|
289
|
+
nil
|
|
290
|
+
end
|
|
291
|
+
return span if span
|
|
292
|
+
|
|
293
|
+
scale = retry_count**2
|
|
294
|
+
jitter = 1 - (0.25 * rand)
|
|
295
|
+
(@initial_retry_delay * scale * jitter).clamp(0, @max_retry_delay)
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
# @private
|
|
299
|
+
#
|
|
300
|
+
# @param request [Hash{Symbol=>Object}] .
|
|
301
|
+
#
|
|
302
|
+
# @option request [Symbol] :method
|
|
303
|
+
#
|
|
304
|
+
# @option request [URI::Generic] :url
|
|
305
|
+
#
|
|
306
|
+
# @option request [Hash{String=>String}] :headers
|
|
307
|
+
#
|
|
308
|
+
# @option request [Object] :body
|
|
309
|
+
#
|
|
310
|
+
# @option request [Integer] :max_retries
|
|
311
|
+
#
|
|
312
|
+
# @option request [Float] :timeout
|
|
313
|
+
#
|
|
314
|
+
# @param redirect_count [Integer]
|
|
315
|
+
#
|
|
316
|
+
# @param retry_count [Integer]
|
|
317
|
+
#
|
|
318
|
+
# @param send_retry_header [Boolean]
|
|
319
|
+
#
|
|
320
|
+
# @raise [OnebusawaySDK::APIError]
|
|
321
|
+
# @return [Array(Net::HTTPResponse, Enumerable)]
|
|
322
|
+
#
|
|
323
|
+
private def send_request(request, redirect_count:, retry_count:, send_retry_header:)
|
|
324
|
+
url, headers, max_retries, timeout = request.fetch_values(:url, :headers, :max_retries, :timeout)
|
|
325
|
+
input = {**request.except(:timeout), deadline: OnebusawaySDK::Util.monotonic_secs + timeout}
|
|
326
|
+
|
|
327
|
+
if send_retry_header
|
|
328
|
+
headers["x-stainless-retry-count"] = retry_count.to_s
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
begin
|
|
332
|
+
response, stream = @requester.execute(input)
|
|
333
|
+
status = Integer(response.code)
|
|
334
|
+
rescue OnebusawaySDK::APIConnectionError => e
|
|
335
|
+
status = e
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
# normally we want to drain the response body and reuse the HTTP session by clearing the socket buffers
|
|
339
|
+
# unless we hit a server error
|
|
340
|
+
srv_fault = (500...).include?(status)
|
|
341
|
+
|
|
342
|
+
case status
|
|
343
|
+
in ..299
|
|
344
|
+
[response, stream]
|
|
345
|
+
in 300..399 if redirect_count >= self.class::MAX_REDIRECTS
|
|
346
|
+
message = "Failed to complete the request within #{self.class::MAX_REDIRECTS} redirects."
|
|
347
|
+
|
|
348
|
+
stream.each { next }
|
|
349
|
+
raise OnebusawaySDK::APIConnectionError.new(url: url, message: message)
|
|
350
|
+
in 300..399
|
|
351
|
+
request = self.class.follow_redirect(request, status: status, response_headers: response)
|
|
352
|
+
|
|
353
|
+
stream.each { next }
|
|
354
|
+
send_request(
|
|
355
|
+
request,
|
|
356
|
+
redirect_count: redirect_count + 1,
|
|
357
|
+
retry_count: retry_count,
|
|
358
|
+
send_retry_header: send_retry_header
|
|
359
|
+
)
|
|
360
|
+
in OnebusawaySDK::APIConnectionError if retry_count >= max_retries
|
|
361
|
+
raise status
|
|
362
|
+
in (400..) if retry_count >= max_retries || (response && !self.class.should_retry?(
|
|
363
|
+
status,
|
|
364
|
+
headers: response
|
|
365
|
+
))
|
|
366
|
+
decoded = OnebusawaySDK::Util.decode_content(response, stream: stream, suppress_error: true)
|
|
367
|
+
|
|
368
|
+
stream.each { srv_fault ? break : next }
|
|
369
|
+
raise OnebusawaySDK::APIStatusError.for(
|
|
370
|
+
url: url,
|
|
371
|
+
status: status,
|
|
372
|
+
body: decoded,
|
|
373
|
+
request: nil,
|
|
374
|
+
response: response
|
|
375
|
+
)
|
|
376
|
+
in (400..) | OnebusawaySDK::APIConnectionError
|
|
377
|
+
delay = retry_delay(response, retry_count: retry_count)
|
|
378
|
+
|
|
379
|
+
stream&.each { srv_fault ? break : next }
|
|
380
|
+
sleep(delay)
|
|
381
|
+
|
|
382
|
+
send_request(
|
|
383
|
+
request,
|
|
384
|
+
redirect_count: redirect_count,
|
|
385
|
+
retry_count: retry_count + 1,
|
|
386
|
+
send_retry_header: send_retry_header
|
|
387
|
+
)
|
|
388
|
+
end
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
# @private
|
|
392
|
+
#
|
|
393
|
+
# @param req [Hash{Symbol=>Object}] .
|
|
394
|
+
#
|
|
395
|
+
# @option req [Symbol] :method
|
|
396
|
+
#
|
|
397
|
+
# @option req [String, Array<String>] :path
|
|
398
|
+
#
|
|
399
|
+
# @option req [Hash{String=>Array<String>, String, nil}, nil] :query
|
|
400
|
+
#
|
|
401
|
+
# @option req [Hash{String=>String, nil}, nil] :headers
|
|
402
|
+
#
|
|
403
|
+
# @option req [Object, nil] :body
|
|
404
|
+
#
|
|
405
|
+
# @option req [Symbol, nil] :unwrap
|
|
406
|
+
#
|
|
407
|
+
# @option req [Class, nil] :page
|
|
408
|
+
#
|
|
409
|
+
# @option req [OnebusawaySDK::Converter, Class, nil] :model
|
|
410
|
+
#
|
|
411
|
+
# @option req [OnebusawaySDK::RequestOptions, Hash{Symbol=>Object}, nil] :options
|
|
412
|
+
#
|
|
413
|
+
# @param headers [Hash{String=>String}, Net::HTTPHeader]
|
|
414
|
+
#
|
|
415
|
+
# @param stream [Enumerable]
|
|
416
|
+
#
|
|
417
|
+
# @return [Object]
|
|
418
|
+
#
|
|
419
|
+
private def parse_response(req, headers:, stream:)
|
|
420
|
+
decoded = OnebusawaySDK::Util.decode_content(headers, stream: stream)
|
|
421
|
+
unwrapped = OnebusawaySDK::Util.dig(decoded, req[:unwrap])
|
|
422
|
+
|
|
423
|
+
case [req[:page], req.fetch(:model, OnebusawaySDK::Unknown)]
|
|
424
|
+
in [Class => page, _]
|
|
425
|
+
page.new(client: self, req: req, headers: headers, unwrapped: unwrapped)
|
|
426
|
+
in [nil, Class | OnebusawaySDK::Converter => model]
|
|
427
|
+
OnebusawaySDK::Converter.coerce(model, unwrapped)
|
|
428
|
+
in [nil, nil]
|
|
429
|
+
unwrapped
|
|
430
|
+
end
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
# Execute the request specified by `req`. This is the method that all resource
|
|
434
|
+
# methods call into.
|
|
435
|
+
#
|
|
436
|
+
# @param req [Hash{Symbol=>Object}] .
|
|
437
|
+
#
|
|
438
|
+
# @option req [Symbol] :method
|
|
439
|
+
#
|
|
440
|
+
# @option req [String, Array<String>] :path
|
|
441
|
+
#
|
|
442
|
+
# @option req [Hash{String=>Array<String>, String, nil}, nil] :query
|
|
443
|
+
#
|
|
444
|
+
# @option req [Hash{String=>String, nil}, nil] :headers
|
|
445
|
+
#
|
|
446
|
+
# @option req [Object, nil] :body
|
|
447
|
+
#
|
|
448
|
+
# @option req [Symbol, nil] :unwrap
|
|
449
|
+
#
|
|
450
|
+
# @option req [Class, nil] :page
|
|
451
|
+
#
|
|
452
|
+
# @option req [OnebusawaySDK::Converter, Class, nil] :model
|
|
453
|
+
#
|
|
454
|
+
# @option req [OnebusawaySDK::RequestOptions, Hash{Symbol=>Object}, nil] :options
|
|
455
|
+
#
|
|
456
|
+
# @raise [OnebusawaySDK::APIError]
|
|
457
|
+
# @return [Object]
|
|
458
|
+
#
|
|
459
|
+
def request(req)
|
|
460
|
+
self.class.validate!(req)
|
|
461
|
+
opts = req[:options].to_h
|
|
462
|
+
OnebusawaySDK::RequestOptions.validate!(opts)
|
|
463
|
+
request = build_request(req.except(:options), opts)
|
|
464
|
+
|
|
465
|
+
# Don't send the current retry count in the headers if the caller modified the header defaults.
|
|
466
|
+
send_retry_header = request.fetch(:headers)["x-stainless-retry-count"] == "0"
|
|
467
|
+
response, stream = send_request(
|
|
468
|
+
request,
|
|
469
|
+
redirect_count: 0,
|
|
470
|
+
retry_count: 0,
|
|
471
|
+
send_retry_header: send_retry_header
|
|
472
|
+
)
|
|
473
|
+
parse_response(req, headers: response, stream: stream)
|
|
474
|
+
end
|
|
475
|
+
|
|
476
|
+
# @return [String]
|
|
477
|
+
#
|
|
478
|
+
def inspect
|
|
479
|
+
base_url = OnebusawaySDK::Util.unparse_uri(@base_url)
|
|
480
|
+
"#<#{self.class.name}:0x#{object_id.to_s(16)} base_url=#{base_url} max_retries=#{@max_retries} timeout=#{@timeout}>"
|
|
481
|
+
end
|
|
482
|
+
end
|
|
483
|
+
end
|