Class: AdyenClient::Response

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, data) ⇒ Response

Returns a new instance of Response.


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

def initialize(code, data)
  @code, @data = code, data
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object


26
27
28
# File 'lib/adyen_client/response.rb', line 26

def method_missing(name, *args, &block)
  @data.fetch(name.to_s) { super(name, *args, &block) }
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code


6
7
8
# File 'lib/adyen_client/response.rb', line 6

def code
  @code
end

#dataObject (readonly) Also known as: to_hash

Returns the value of attribute data


6
7
8
# File 'lib/adyen_client/response.rb', line 6

def data
  @data
end

Class Method Details

.parse(http_response) ⇒ Object


2
3
4
# File 'lib/adyen_client/response.rb', line 2

def self.parse(http_response)
  new(http_response.code, AdyenClient::Utils.massage_response(http_response.parsed_response))
end

Instance Method Details

#authorised?Boolean Also known as: authorized?

Returns:

  • (Boolean)

17
18
19
# File 'lib/adyen_client/response.rb', line 17

def authorised?
  success? && result_code == "Authorised"
end

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)

22
23
24
# File 'lib/adyen_client/response.rb', line 22

def respond_to_missing?(name, include_private = false)
  @data.has_key?(name.to_s) || super
end

#success?Boolean

Returns:

  • (Boolean)

13
14
15
# File 'lib/adyen_client/response.rb', line 13

def success?
  code == 200
end