Class: Esa::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/esa/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(faraday_response) ⇒ Response

Returns a new instance of Response.



3
4
5
6
7
# File 'lib/esa/response.rb', line 3

def initialize(faraday_response)
  @raw_body    = faraday_response.body
  @raw_headers = faraday_response.headers
  @raw_status  = faraday_response.status
end

Instance Method Details

#bodyObject



9
10
11
# File 'lib/esa/response.rb', line 9

def body
  @raw_body
end

#headersObject



13
14
15
16
17
# File 'lib/esa/response.rb', line 13

def headers
  @headers ||= @raw_headers.inject({}) do |result, (key, value)|
    result.merge(key.split("-").map(&:capitalize).join("-") => value)
  end
end

#statusObject



19
20
21
# File 'lib/esa/response.rb', line 19

def status
  @raw_status
end