Module: MartaApi::Rest::Bus
- Includes:
- Utils
- Included in:
- API
- Defined in:
- lib/marta_api/rest/bus.rb
Constant Summary
Constants included
from Utils
Utils::API_KEY_SUFFIX, Utils::GET_ALL_BUS_SCHEDULES_ENDPOINT, Utils::GET_BUS_SCHEDULE_BY_ROUTE_ENDPOINT, Utils::GET_RAIL_SCHEDULE_ENDPOINT, Utils::MARTA_API_KEY, Utils::MARTA_API_ROOT
Instance Method Summary
collapse
Methods included from Utils
#api_key_param
Instance Method Details
#get_bus_schedule ⇒ Object
#get_bus_schedule_by_route(route_id) ⇒ Object
16
17
18
19
20
|
# File 'lib/marta_api/rest/bus.rb', line 16
def get_bus_schedule_by_route(route_id)
url = MARTA_API_ROOT + (GET_BUS_SCHEDULE_BY_ROUTE_ENDPOINT % route_id) + api_key_param
response = RestClient.get url
handle_response(response)
end
|
#handle_response(response) ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'lib/marta_api/rest/bus.rb', line 22
def handle_response(response)
status_code = response.code
unless (status_code > 199) && (status_code < 299)
raise MartaApiError, "Unexpected response code (#{status_code}) received from MARTA API."
end
JSON.parse(response.body) unless response.body.empty?
end
|