Class: FieldView::FieldViewResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/fieldview/fieldview_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ FieldViewResponse

Returns a new instance of FieldViewResponse.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fieldview/fieldview_response.rb', line 8

def initialize(response)
  self.http_headers = {}
  response.each_capitalized_name do |n|
    self.http_headers[n] = response[n]
  end
  
  self.http_body = response.body
  if response.body then
    begin
      self.data = JSON.parse(response.body, symbolize_names: true)
    rescue JSON::ParserError
      self.data = nil
    end
  else
    self.data = nil
  end
  self.http_status = response.code.to_i
  self.request_id = self.http_headers[FieldView::REQUEST_ID_HEADER_KEY]
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



7
8
9
# File 'lib/fieldview/fieldview_response.rb', line 7

def data
  @data
end

#http_bodyObject

Returns the value of attribute http_body.



4
5
6
# File 'lib/fieldview/fieldview_response.rb', line 4

def http_body
  @http_body
end

#http_headersObject

Returns the value of attribute http_headers.



5
6
7
# File 'lib/fieldview/fieldview_response.rb', line 5

def http_headers
  @http_headers
end

#http_statusObject

Returns the value of attribute http_status.



6
7
8
# File 'lib/fieldview/fieldview_response.rb', line 6

def http_status
  @http_status
end

#request_idObject

Returns the value of attribute request_id.



3
4
5
# File 'lib/fieldview/fieldview_response.rb', line 3

def request_id
  @request_id
end