Class: Mailersend::SMS
- Inherits:
-
Object
- Object
- Mailersend::SMS
- Defined in:
- lib/mailersend/sms/sms.rb
Overview
Send an SMS through MailerSend API
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#from ⇒ Object
Returns the value of attribute from.
-
#personalization ⇒ Object
Returns the value of attribute personalization.
-
#text ⇒ Object
Returns the value of attribute text.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
- #add_from(from) ⇒ Object
- #add_personalization(personalization) ⇒ Object
- #add_text(text) ⇒ Object
- #add_to(to) ⇒ Object
-
#initialize(client = Mailersend::Client.new) ⇒ SMS
constructor
A new instance of SMS.
- #send ⇒ Object
Constructor Details
#initialize(client = Mailersend::Client.new) ⇒ SMS
Returns a new instance of SMS.
12 13 14 15 16 17 18 |
# File 'lib/mailersend/sms/sms.rb', line 12 def initialize(client = Mailersend::Client.new) @client = client @from = {} @to = [] @text = {} @personalization = [] end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
6 7 8 |
# File 'lib/mailersend/sms/sms.rb', line 6 def client @client end |
#from ⇒ Object
Returns the value of attribute from.
6 7 8 |
# File 'lib/mailersend/sms/sms.rb', line 6 def from @from end |
#personalization ⇒ Object
Returns the value of attribute personalization.
6 7 8 |
# File 'lib/mailersend/sms/sms.rb', line 6 def personalization @personalization end |
#text ⇒ Object
Returns the value of attribute text.
6 7 8 |
# File 'lib/mailersend/sms/sms.rb', line 6 def text @text end |
#to ⇒ Object
Returns the value of attribute to.
6 7 8 |
# File 'lib/mailersend/sms/sms.rb', line 6 def to @to end |
Instance Method Details
#add_from(from) ⇒ Object
20 21 22 |
# File 'lib/mailersend/sms/sms.rb', line 20 def add_from(from) @from = from end |
#add_personalization(personalization) ⇒ Object
32 33 34 |
# File 'lib/mailersend/sms/sms.rb', line 32 def add_personalization(personalization) @personalization << personalization end |
#add_text(text) ⇒ Object
28 29 30 |
# File 'lib/mailersend/sms/sms.rb', line 28 def add_text(text) @text = text end |
#add_to(to) ⇒ Object
24 25 26 |
# File 'lib/mailersend/sms/sms.rb', line 24 def add_to(to) @to << to end |
#send ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mailersend/sms/sms.rb', line 36 def send = { 'from' => @from, 'to' => @to, 'text' => @text, 'personalization' => @personalization } response = client.http.post("#{MAILERSEND_API_URL}/sms", json: .delete_if { |_, value| value.to_s.strip == '' || value == [] || value == {} }) puts response end |