Class: Bambora::Response

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

Overview

Parses a response into a Hash. Uses JSON to parse by default.

Direct Known Subclasses

JSONResponse, QueryStringResponse

Constant Summary collapse

DEFAULT_PARSER =
JSON

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



11
12
13
# File 'lib/bambora/adapters/response.rb', line 11

def initialize(response)
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

Instance Method Details

#to_hObject



15
16
17
18
19
# File 'lib/bambora/adapters/response.rb', line 15

def to_h
  deep_transform_keys_in_object(parser.parse(response.body.to_s), &:to_sym)
rescue JSON::ParserError
  error_response
end