Class: Twilito::Result
- Inherits:
-
Object
- Object
- Twilito::Result
- Defined in:
- lib/twilito/result.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#sid ⇒ Object
readonly
Returns the value of attribute sid.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
Class Method Summary collapse
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(success:, errors: [], sid: nil, response: nil) ⇒ Result
constructor
A new instance of Result.
- #success? ⇒ Boolean
Constructor Details
#initialize(success:, errors: [], sid: nil, response: nil) ⇒ Result
Returns a new instance of Result.
7 8 9 10 11 12 |
# File 'lib/twilito/result.rb', line 7 def initialize(success:, errors: [], sid: nil, response: nil) @success = success @errors = errors @sid = sid @response = response end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
5 6 7 |
# File 'lib/twilito/result.rb', line 5 def errors @errors end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/twilito/result.rb', line 5 def response @response end |
#sid ⇒ Object (readonly)
Returns the value of attribute sid.
5 6 7 |
# File 'lib/twilito/result.rb', line 5 def sid @sid end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
5 6 7 |
# File 'lib/twilito/result.rb', line 5 def success @success end |
Class Method Details
.failure(response:, errors:) ⇒ Object
18 19 20 |
# File 'lib/twilito/result.rb', line 18 def self.failure(response:, errors:) new(success: false, response: response, errors: errors) end |
.success(response:, sid:) ⇒ Object
14 15 16 |
# File 'lib/twilito/result.rb', line 14 def self.success(response:, sid:) new(success: true, response: response, sid: sid) end |
Instance Method Details
#data ⇒ Object
22 23 24 |
# File 'lib/twilito/result.rb', line 22 def data JSON.parse(response_body || '{}') end |
#success? ⇒ Boolean
26 27 28 |
# File 'lib/twilito/result.rb', line 26 def success? success || false end |