Class: PayLane::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body) ⇒ Response

Returns a new instance of Response.



5
6
7
# File 'lib/paylane/response.rb', line 5

def initialize(body)
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



3
4
5
# File 'lib/paylane/response.rb', line 3

def body
  @body
end

Instance Method Details

#attributesObject



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

def attributes
  hash = (@body[:ok] || @body[:error])
  has_data? ? hash.merge(@body[:data]) : hash
end

#error_descriptionObject



21
22
23
# File 'lib/paylane/response.rb', line 21

def error_description
   @body[:error][:error_description] if has_error?
end

#has_data?Boolean

Returns:

  • (Boolean)


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

def has_data?
  @body.include?(:data)
end

#has_error?Boolean

Returns:

  • (Boolean)


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

def has_error?
  !has_ok?
end

#has_ok?Boolean

Returns:

  • (Boolean)


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

def has_ok?
  @body.include?(:ok)
end