Class: HeroixApi::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/heroix_api/processor.rb

Class Method Summary collapse

Class Method Details

.get_api_response(query) ⇒ Object

Get an api response catching errors and logging them.



9
10
11
12
13
14
15
16
17
# File 'lib/heroix_api/processor.rb', line 9

def self.get_api_response(query)
  begin
    response = get_api_response!(query)
  rescue => e
    HeroixApi.log_error "Heroix API get_api_response with query #{HeroixApi.root_url}#{query} error: #{e.inspect}"
  end

  return HeroixApi::Data.from_response(response)
end

.get_api_response!(query) ⇒ Object

Get an api response allowing errors to be raised.



21
22
23
24
# File 'lib/heroix_api/processor.rb', line 21

def self.get_api_response!(query)
  query_url =  "#{HeroixApi.root_url}#{query}"
  response = self.request_api_url(query_url)
end