Class: MessagebirdTexter::Response::Error
- Inherits:
-
Object
- Object
- MessagebirdTexter::Response::Error
- Defined in:
- lib/messagebird_texter/response/error.rb
Constant Summary collapse
- ERROR_CODES =
{ 2 => 'Request not allowed', 9 => 'Missing params', 10 => 'Invalid params', 20 => 'Not found', 25 => 'Not enough balance', 98 => 'API not found', 99 => 'Internal error' }
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
Instance Method Summary collapse
- #count ⇒ Object
- #errors ⇒ Object
-
#initialize(error) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(error) ⇒ Error
Returns a new instance of Error.
16 17 18 |
# File 'lib/messagebird_texter/response/error.rb', line 16 def initialize(error) @errors = JSON.parse(error, symbolize_names: true)[:errors] end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
4 5 6 |
# File 'lib/messagebird_texter/response/error.rb', line 4 def code @code end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
4 5 6 |
# File 'lib/messagebird_texter/response/error.rb', line 4 def description @description end |
Instance Method Details
#count ⇒ Object
24 25 26 |
# File 'lib/messagebird_texter/response/error.rb', line 24 def count @errors.count end |
#errors ⇒ Object
20 21 22 |
# File 'lib/messagebird_texter/response/error.rb', line 20 def errors @errors.map { |e| e.merge(error_message: ERROR_CODES[e[:code]]) } end |