Class: Cellcom::Response
- Inherits:
-
Object
- Object
- Cellcom::Response
- Extended by:
- Forwardable
- Defined in:
- lib/cellcom/response.rb
Constant Summary collapse
- ERRORS =
{ 'ERROR 10' => ['WrongCredentials', 'Wrong client id or password'], 'ERROR 20' => ['WrongGateway', 'Wrong gateway number (GWID)'], 'ERROR 30' => ['NotEnoughCredit', 'Not enough credit left'], 'ERROR 40' => ['WrongDestination', 'Recipient number is wrong, or destination not covered'], 'ERROR 50' => ['SenderIdNotSupported', 'Sender ID not supported'], 'ERROR 60' => ['InvalidMessage', 'Message is too long or invalid'], 'ERROR 70' => ['Timeout', 'Timeout, please retry later'], 'ERROR 80' => ['InternalError', 'Internal error, please contact Cellcom'] }.freeze
Instance Attribute Summary collapse
-
#raw_response ⇒ Object
readonly
Returns the value of attribute raw_response.
Instance Method Summary collapse
-
#initialize(raw_response) ⇒ Response
constructor
A new instance of Response.
- #raise_error(error_key) ⇒ Object
Constructor Details
#initialize(raw_response) ⇒ Response
Returns a new instance of Response.
26 27 28 29 |
# File 'lib/cellcom/response.rb', line 26 def initialize(raw_response) @raw_response = raw_response raise_error(raw_response.body) if ERRORS.keys.include?(raw_response.body) end |
Instance Attribute Details
#raw_response ⇒ Object (readonly)
Returns the value of attribute raw_response.
21 22 23 |
# File 'lib/cellcom/response.rb', line 21 def raw_response @raw_response end |
Instance Method Details
#raise_error(error_key) ⇒ Object
31 32 33 34 |
# File 'lib/cellcom/response.rb', line 31 def raise_error(error_key) error_val = ERRORS.fetch(error_key) fail Response.const_get(error_val[0]), error_val[1] end |