Class: Kassa24::Result
- Inherits:
-
Object
- Object
- Kassa24::Result
- Defined in:
- lib/kassa24/result.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(response) ⇒ Result
constructor
A new instance of Result.
- #success? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Result
Returns a new instance of Result.
5 6 7 8 9 10 11 |
# File 'lib/kassa24/result.rb', line 5 def initialize(response) body = response.body.gsub(/Field "([a-zA-Z]+)"/, '\"\1\"') # unescape bad json @value = JSON.parse(body, symbolize_names: true) @error = [:bad_credentials, {}] if response.status == 401 @error = [:bad_data, { message: @value[:error] }] if response.status == 400 end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
3 4 5 |
# File 'lib/kassa24/result.rb', line 3 def error @error end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/kassa24/result.rb', line 3 def value @value end |
Instance Method Details
#success? ⇒ Boolean
13 14 15 |
# File 'lib/kassa24/result.rb', line 13 def success? @error.nil? end |