Class: MoneyMover::Dwolla::ApiServerResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/money_mover/dwolla/api_server_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#responseObject (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

#bodyObject



10
11
12
# File 'lib/money_mover/dwolla/api_server_response.rb', line 10

def body
  HashWithIndifferentAccess.new @response.body
end

#errorsObject



14
15
16
# File 'lib/money_mover/dwolla/api_server_response.rb', line 14

def errors
  @errors ||= ErrorHandler.new(body).errors
end

#resource_idObject



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_locationObject



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

Returns:

  • (Boolean)


18
19
20
# File 'lib/money_mover/dwolla/api_server_response.rb', line 18

def success?
  @response.status >= 200 && @response.status < 400
end