Class: OnebusawaySDK::Client
Constant Summary
collapse
- DEFAULT_MAX_RETRIES =
Default max number of retries to attempt after a failed retryable request.
2
- DEFAULT_TIMEOUT_IN_SECONDS =
Default per-request timeout.
60.0
- DEFAULT_INITIAL_RETRY_DELAY =
Default initial retry delay in seconds. Overall delay is calculated using exponential backoff + jitter.
0.5
- DEFAULT_MAX_RETRY_DELAY =
Default max retry delay in seconds.
8.0
Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS
Instance Attribute Summary collapse
#base_url, #headers, #idempotency_header, #initial_retry_delay, #max_retries, #max_retry_delay, #requester, #timeout
Instance Method Summary
collapse
follow_redirect, #inspect, reap_connection!, #request, #send_request, should_retry?, validate!
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize(api_key: ENV["ONEBUSAWAY_API_KEY"], base_url: ENV["ONEBUSAWAY_SDK_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
Creates and returns a new client for interacting with the API.
‘“api.example.com/v2/”`. Defaults to `ENV`
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
# File 'lib/onebusaway_sdk/client.rb', line 126
def initialize(
api_key: ENV["ONEBUSAWAY_API_KEY"],
base_url: ENV["ONEBUSAWAY_SDK_BASE_URL"],
max_retries: self.class::DEFAULT_MAX_RETRIES,
timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY,
max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY
)
base_url ||= "https://api.pugetsound.onebusaway.org"
if api_key.nil?
raise ArgumentError.new("api_key is required, and can be set via environ: \"ONEBUSAWAY_API_KEY\"")
end
@api_key = api_key.to_s
super(
base_url: base_url,
timeout: timeout,
max_retries: max_retries,
initial_retry_delay: initial_retry_delay,
max_retry_delay: max_retry_delay
)
@agencies_with_coverage = OnebusawaySDK::Resources::AgenciesWithCoverage.new(client: self)
@agency = OnebusawaySDK::Resources::Agency.new(client: self)
@vehicles_for_agency = OnebusawaySDK::Resources::VehiclesForAgency.new(client: self)
@config = OnebusawaySDK::Resources::Config.new(client: self)
@current_time = OnebusawaySDK::Resources::CurrentTime.new(client: self)
@stops_for_location = OnebusawaySDK::Resources::StopsForLocation.new(client: self)
@stops_for_route = OnebusawaySDK::Resources::StopsForRoute.new(client: self)
@stops_for_agency = OnebusawaySDK::Resources::StopsForAgency.new(client: self)
@stop = OnebusawaySDK::Resources::Stop.new(client: self)
@stop_ids_for_agency = OnebusawaySDK::Resources::StopIDsForAgency.new(client: self)
@schedule_for_stop = OnebusawaySDK::Resources::ScheduleForStop.new(client: self)
@route = OnebusawaySDK::Resources::Route.new(client: self)
@route_ids_for_agency = OnebusawaySDK::Resources::RouteIDsForAgency.new(client: self)
@routes_for_location = OnebusawaySDK::Resources::RoutesForLocation.new(client: self)
@routes_for_agency = OnebusawaySDK::Resources::RoutesForAgency.new(client: self)
@schedule_for_route = OnebusawaySDK::Resources::ScheduleForRoute.new(client: self)
@arrival_and_departure = OnebusawaySDK::Resources::ArrivalAndDeparture.new(client: self)
@trip = OnebusawaySDK::Resources::Trip.new(client: self)
@trips_for_location = OnebusawaySDK::Resources::TripsForLocation.new(client: self)
@trip_details = OnebusawaySDK::Resources::TripDetails.new(client: self)
@trip_for_vehicle = OnebusawaySDK::Resources::TripForVehicle.new(client: self)
@trips_for_route = OnebusawaySDK::Resources::TripsForRoute.new(client: self)
@report_problem_with_stop = OnebusawaySDK::Resources::ReportProblemWithStop.new(client: self)
@report_problem_with_trip = OnebusawaySDK::Resources::ReportProblemWithTrip.new(client: self)
@search_for_stop = OnebusawaySDK::Resources::SearchForStop.new(client: self)
@search_for_route = OnebusawaySDK::Resources::SearchForRoute.new(client: self)
@block = OnebusawaySDK::Resources::Block.new(client: self)
@shape = OnebusawaySDK::Resources::Shape.new(client: self)
end
|
Instance Attribute Details
22
23
24
|
# File 'lib/onebusaway_sdk/client.rb', line 22
def agencies_with_coverage
@agencies_with_coverage
end
|
25
26
27
|
# File 'lib/onebusaway_sdk/client.rb', line 25
def agency
@agency
end
|
#api_key ⇒ String
19
20
21
|
# File 'lib/onebusaway_sdk/client.rb', line 19
def api_key
@api_key
end
|
70
71
72
|
# File 'lib/onebusaway_sdk/client.rb', line 70
def arrival_and_departure
@arrival_and_departure
end
|
100
101
102
|
# File 'lib/onebusaway_sdk/client.rb', line 100
def block
@block
end
|
31
32
33
|
# File 'lib/onebusaway_sdk/client.rb', line 31
def config
@config
end
|
34
35
36
|
# File 'lib/onebusaway_sdk/client.rb', line 34
def current_time
@current_time
end
|
88
89
90
|
# File 'lib/onebusaway_sdk/client.rb', line 88
def report_problem_with_stop
@report_problem_with_stop
end
|
91
92
93
|
# File 'lib/onebusaway_sdk/client.rb', line 91
def report_problem_with_trip
@report_problem_with_trip
end
|
55
56
57
|
# File 'lib/onebusaway_sdk/client.rb', line 55
def route
@route
end
|
58
59
60
|
# File 'lib/onebusaway_sdk/client.rb', line 58
def route_ids_for_agency
@route_ids_for_agency
end
|
64
65
66
|
# File 'lib/onebusaway_sdk/client.rb', line 64
def routes_for_agency
@routes_for_agency
end
|
61
62
63
|
# File 'lib/onebusaway_sdk/client.rb', line 61
def routes_for_location
@routes_for_location
end
|
67
68
69
|
# File 'lib/onebusaway_sdk/client.rb', line 67
def schedule_for_route
@schedule_for_route
end
|
52
53
54
|
# File 'lib/onebusaway_sdk/client.rb', line 52
def schedule_for_stop
@schedule_for_stop
end
|
97
98
99
|
# File 'lib/onebusaway_sdk/client.rb', line 97
def search_for_route
@search_for_route
end
|
94
95
96
|
# File 'lib/onebusaway_sdk/client.rb', line 94
def search_for_stop
@search_for_stop
end
|
103
104
105
|
# File 'lib/onebusaway_sdk/client.rb', line 103
def shape
@shape
end
|
46
47
48
|
# File 'lib/onebusaway_sdk/client.rb', line 46
def stop
@stop
end
|
49
50
51
|
# File 'lib/onebusaway_sdk/client.rb', line 49
def stop_ids_for_agency
@stop_ids_for_agency
end
|
43
44
45
|
# File 'lib/onebusaway_sdk/client.rb', line 43
def stops_for_agency
@stops_for_agency
end
|
37
38
39
|
# File 'lib/onebusaway_sdk/client.rb', line 37
def stops_for_location
@stops_for_location
end
|
40
41
42
|
# File 'lib/onebusaway_sdk/client.rb', line 40
def stops_for_route
@stops_for_route
end
|
73
74
75
|
# File 'lib/onebusaway_sdk/client.rb', line 73
def trip
@trip
end
|
79
80
81
|
# File 'lib/onebusaway_sdk/client.rb', line 79
def trip_details
@trip_details
end
|
82
83
84
|
# File 'lib/onebusaway_sdk/client.rb', line 82
def trip_for_vehicle
@trip_for_vehicle
end
|
76
77
78
|
# File 'lib/onebusaway_sdk/client.rb', line 76
def trips_for_location
@trips_for_location
end
|
85
86
87
|
# File 'lib/onebusaway_sdk/client.rb', line 85
def trips_for_route
@trips_for_route
end
|
28
29
30
|
# File 'lib/onebusaway_sdk/client.rb', line 28
def vehicles_for_agency
@vehicles_for_agency
end
|