Class: OperationResult
- Inherits:
-
Object
- Object
- OperationResult
- Defined in:
- lib/maropost_api/custom_types/operation_result.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#success ⇒ Object
Returns the value of attribute success.
Instance Method Summary collapse
-
#initialize(result) ⇒ OperationResult
constructor
A new instance of OperationResult.
Constructor Details
#initialize(result) ⇒ OperationResult
Returns a new instance of OperationResult.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/maropost_api/custom_types/operation_result.rb', line 3 def initialize(result) if (200..206).to_a.include? result.code @success = true @errors = nil @data = JSON.parse([result.body].to_json).first @data = JSON.parse(@data) if @data.kind_of? String and @data.start_with?("{", "[") @data = nil if @data == "" else @success = false @errors = JSON.parse(JSON.parse([result.body].to_json).first) if result.code != 404 @errors = nil if @errors == "" @errors['message'] = 'Page not found!' if result.code == 404 end end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
2 3 4 |
# File 'lib/maropost_api/custom_types/operation_result.rb', line 2 def data @data end |
#errors ⇒ Object
Returns the value of attribute errors.
2 3 4 |
# File 'lib/maropost_api/custom_types/operation_result.rb', line 2 def errors @errors end |
#success ⇒ Object
Returns the value of attribute success.
2 3 4 |
# File 'lib/maropost_api/custom_types/operation_result.rb', line 2 def success @success end |