Class: ActionTexter::Message
- Inherits:
-
Object
- Object
- ActionTexter::Message
- Defined in:
- lib/action_texter/message.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#from ⇒ Object
Returns the value of attribute from.
-
#reference ⇒ Object
Returns the value of attribute reference.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
- #deliver ⇒ Object
- #deliver! ⇒ Object
-
#initialize(attributes = {}) ⇒ Message
constructor
A new instance of Message.
- #request ⇒ Object
- #to_json ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(attributes = {}) ⇒ Message
Returns a new instance of Message.
9 10 11 12 13 14 |
# File 'lib/action_texter/message.rb', line 9 def initialize(attributes = {}) @from = attributes[:from] @to = attributes[:to] @body = attributes[:body] @reference = attributes[:reference] end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
7 8 9 |
# File 'lib/action_texter/message.rb', line 7 def body @body end |
#from ⇒ Object
Returns the value of attribute from.
7 8 9 |
# File 'lib/action_texter/message.rb', line 7 def from @from end |
#reference ⇒ Object
Returns the value of attribute reference.
7 8 9 |
# File 'lib/action_texter/message.rb', line 7 def reference @reference end |
#to ⇒ Object
Returns the value of attribute to.
7 8 9 |
# File 'lib/action_texter/message.rb', line 7 def to @to end |
Instance Method Details
#deliver ⇒ Object
20 21 22 |
# File 'lib/action_texter/message.rb', line 20 def deliver request.perform if valid? end |
#deliver! ⇒ Object
24 25 26 |
# File 'lib/action_texter/message.rb', line 24 def deliver! deliver if valid? end |
#request ⇒ Object
16 17 18 |
# File 'lib/action_texter/message.rb', line 16 def request Request.new(to_json) end |
#to_json ⇒ Object
32 33 34 35 36 |
# File 'lib/action_texter/message.rb', line 32 def to_json JSON.generate(recipients: to, originator: from, body: body) end |
#valid? ⇒ Boolean
28 29 30 |
# File 'lib/action_texter/message.rb', line 28 def valid? ActionTexter::Validator::Message.new self end |