Class: MoneyMover::Dwolla::ApiServerResponse
- Inherits:
-
Object
- Object
- MoneyMover::Dwolla::ApiServerResponse
- Defined in:
- lib/money_mover/dwolla/api_server_response.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #body ⇒ Object
- #errors ⇒ Object
-
#initialize(response) ⇒ ApiServerResponse
constructor
A new instance of ApiServerResponse.
- #resource_id ⇒ Object
- #resource_location ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ ApiServerResponse
Returns a new instance of ApiServerResponse.
6 7 8 |
# File 'lib/money_mover/dwolla/api_server_response.rb', line 6 def initialize(response) @response = response end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
4 5 6 |
# File 'lib/money_mover/dwolla/api_server_response.rb', line 4 def response @response end |
Instance Method Details
#body ⇒ Object
10 11 12 |
# File 'lib/money_mover/dwolla/api_server_response.rb', line 10 def body HashWithIndifferentAccess.new @response.body end |
#errors ⇒ Object
14 15 16 |
# File 'lib/money_mover/dwolla/api_server_response.rb', line 14 def errors @errors ||= ErrorHandler.new(body).errors end |
#resource_id ⇒ Object
26 27 28 |
# File 'lib/money_mover/dwolla/api_server_response.rb', line 26 def resource_id resource_location.split('/').last rescue nil end |
#resource_location ⇒ Object
22 23 24 |
# File 'lib/money_mover/dwolla/api_server_response.rb', line 22 def resource_location @response.headers[:location] if @response.headers[:location] end |
#success? ⇒ Boolean
18 19 20 |
# File 'lib/money_mover/dwolla/api_server_response.rb', line 18 def success? @response.status >= 200 && @response.status < 400 end |