Class: Payoneer::Response
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Payoneer::Response
- Defined in:
- lib/payoneer/response.rb
Constant Summary collapse
- OK_STATUS_CODE =
'000'
Instance Method Summary collapse
- #convert_hash_keys(value) ⇒ Object
-
#initialize(name, hash) ⇒ Response
constructor
A new instance of Response.
- #ok? ⇒ Boolean
Constructor Details
#initialize(name, hash) ⇒ Response
Returns a new instance of Response.
5 6 7 8 |
# File 'lib/payoneer/response.rb', line 5 def initialize(name, hash) super(convert_hash_keys(hash)) self.response_name = name end |
Instance Method Details
#convert_hash_keys(value) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/payoneer/response.rb', line 10 def convert_hash_keys(value) case value when Array value.map { |v| convert_hash_keys(v) } when Hash Hash[value.map { |k, v| [k.underscore, convert_hash_keys(v)] }] else value end end |
#ok? ⇒ Boolean
21 22 23 24 25 26 27 |
# File 'lib/payoneer/response.rb', line 21 def ok? if self.response_name == 'GetPaymentStatus' self.result == OK_STATUS_CODE else self.status == OK_STATUS_CODE end end |