module NoaaWeatherClient::RestService
Public Instance Methods
build_request_for_action(action, url, options = {})
click to toggle source
@note Much more to be done here when needed.
# File lib/noaa_weather_client/services/rest_service.rb, line 21 def build_request_for_action(action, url, options = {}) r_class = case action when :get then Net::HTTP::Get end r_class.new url end
object_from_response(action, url, options = {})
click to toggle source
# File lib/noaa_weather_client/services/rest_service.rb, line 8 def object_from_response(action, url, options = {}) response_class = options.fetch(:response_class, Responses::GenericResponse) client = options.fetch(:client) { RestClientFactory.build_client(url: url) } request = build_request_for_action action, url, options response_class.new client.request(request).body rescue Net::HTTPError, Net::HTTPRetriableError, Net::HTTPServerException, Net::HTTPFatalError => e raise Errors::CommunicationError, e.message, e.backtrace end