Module: MartaApi::Rest::Rail
- Includes:
- Utils
- Included in:
- API
- Defined in:
- lib/marta_api/rest/rail.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_rail_schedule ⇒ Object
12
13
14
15
16
|
# File 'lib/marta_api/rest/rail.rb', line 12
def get_rail_schedule
url = MARTA_API_ROOT + GET_RAIL_SCHEDULE_ENDPOINT + api_key_param
response = RestClient.get url
handle_response(response)
end
|
#handle_response(response) ⇒ Object
18
19
20
21
22
23
24
25
|
# File 'lib/marta_api/rest/rail.rb', line 18
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
|