Class: InteltechSms::Response
- Inherits:
-
Object
- Object
- InteltechSms::Response
- Defined in:
- lib/inteltech_sms.rb
Instance Attribute Summary collapse
-
#response_code ⇒ Object
readonly
Returns the value of attribute response_code.
-
#sms ⇒ Object
readonly
Returns the value of attribute sms.
Class Method Summary collapse
Instance Method Summary collapse
- #==(another) ⇒ Object
-
#initialize(sms, response_code = '') ⇒ Response
constructor
A new instance of Response.
- #to_s ⇒ Object
Constructor Details
#initialize(sms, response_code = '') ⇒ Response
Returns a new instance of Response.
40 41 42 43 |
# File 'lib/inteltech_sms.rb', line 40 def initialize(sms, response_code = '') @sms = sms.strip @response_code = response_code.strip end |
Instance Attribute Details
#response_code ⇒ Object (readonly)
Returns the value of attribute response_code.
38 39 40 |
# File 'lib/inteltech_sms.rb', line 38 def response_code @response_code end |
#sms ⇒ Object (readonly)
Returns the value of attribute sms.
37 38 39 |
# File 'lib/inteltech_sms.rb', line 37 def sms @sms end |
Class Method Details
.factory(sms, response_code) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/inteltech_sms.rb', line 45 def self.factory(sms, response_code) case response_code.strip when SUCCESS_RESPONSE_CODE Success.new(sms, response_code) when UNAUTHORIZED_RESPONSE_CODE Unauthorized.new(sms, response_code) when INVALID_NUMBER_RESPONSE_CODE BadRequest.new(sms, response_code) when DUPLICATE_RESPONSE_CODE Duplicate.new(sms, response_code) when NO_CREDIT_RESPONSE_CODE NoCredit.new(sms, response_code) when UNAUTHORIZED_KEY_RESPONSE_CODE Unauthorized.new(sms, response_code) when EMPTY_MESSAGE_RESPONSE_CODE BadRequest.new(sms, response_code) when TOO_MANY_RECIPIENTS_RESPONSE_CODE BadRequest.new(sms, response_code) when ACCOUNT_NOT_ACTIVATED_RESPONSE_CODE Unauthorized.new(sms, response_code) else Failure.new(sms, response_code) end end |
Instance Method Details
#==(another) ⇒ Object
70 71 72 |
# File 'lib/inteltech_sms.rb', line 70 def ==(another) self.sms == another.sms and self.response_code == another.response_code end |
#to_s ⇒ Object
74 75 76 |
# File 'lib/inteltech_sms.rb', line 74 def to_s "#{self.class.name} sms: #{@sms}, response_code: #{@response_code}" end |