Class: Smess::Sms
- Inherits:
-
Object
- Object
- Smess::Sms
- Defined in:
- lib/smess/sms.rb
Instance Attribute Summary collapse
-
#callback_params ⇒ Object
Returns the value of attribute callback_params.
-
#message ⇒ Object
Returns the value of attribute message.
-
#originator ⇒ Object
Returns the value of attribute originator.
-
#output ⇒ Object
Returns the value of attribute output.
-
#results ⇒ Object
Returns the value of attribute results.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
- #check(code) ⇒ Object
- #deliver ⇒ Object
- #delivered? ⇒ Boolean
-
#initialize(*args) ⇒ Sms
constructor
A new instance of Sms.
- #send_feedback(to, message_sid) ⇒ Object
- #verify(using: 'sms') ⇒ Object
Constructor Details
#initialize(*args) ⇒ Sms
Returns a new instance of Sms.
6 7 8 9 10 11 12 13 |
# File 'lib/smess/sms.rb', line 6 def initialize(*args) opts = args.first || {} @to = opts.fetch(:to, nil) @message = opts.fetch(:message, "") @originator = opts.fetch(:originator, nil) @output = opts.fetch(:output, :auto).to_sym @callback_params = opts.fetch(:callback_params, nil) end |
Instance Attribute Details
#callback_params ⇒ Object
Returns the value of attribute callback_params.
4 5 6 |
# File 'lib/smess/sms.rb', line 4 def callback_params @callback_params end |
#message ⇒ Object
Returns the value of attribute message.
4 5 6 |
# File 'lib/smess/sms.rb', line 4 def @message end |
#originator ⇒ Object
Returns the value of attribute originator.
4 5 6 |
# File 'lib/smess/sms.rb', line 4 def originator @originator end |
#output ⇒ Object
Returns the value of attribute output.
4 5 6 |
# File 'lib/smess/sms.rb', line 4 def output @output end |
#results ⇒ Object
Returns the value of attribute results.
4 5 6 |
# File 'lib/smess/sms.rb', line 4 def results @results end |
#to ⇒ Object
Returns the value of attribute to.
4 5 6 |
# File 'lib/smess/sms.rb', line 4 def to @to end |
Instance Method Details
#check(code) ⇒ Object
27 28 29 30 31 |
# File 'lib/smess/sms.rb', line 27 def check(code) out = Smess.named_output_instance(output) out.sms = self self.results = {sent_with: output}.merge(out.check(code)) end |
#deliver ⇒ Object
15 16 17 18 19 |
# File 'lib/smess/sms.rb', line 15 def deliver out = Smess.named_output_instance(output) out.sms = self self.results = {sent_with: output}.merge(out.deliver) end |
#delivered? ⇒ Boolean
33 34 35 |
# File 'lib/smess/sms.rb', line 33 def delivered? results[:response_code] == "0" end |
#send_feedback(to, message_sid) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/smess/sms.rb', line 37 def send_feedback(to, ) out = Smess.named_output_instance(output) @to = to out.sms = self out.send_feedback() end |
#verify(using: 'sms') ⇒ Object
21 22 23 24 25 |
# File 'lib/smess/sms.rb', line 21 def verify(using: 'sms') out = Smess.named_output_instance(output) out.sms = self self.results = {sent_with: output}.merge(out.verify(using: using)) end |