Class: DigitSend::Message
- Inherits:
-
Object
- Object
- DigitSend::Message
- Defined in:
- lib/digitsend/message.rb
Class Method Summary collapse
Instance Method Summary collapse
- #attach(filename, data = nil) ⇒ Object
- #body(text) ⇒ Object
- #cc(email, phone = nil) ⇒ Object
-
#initialize ⇒ Message
constructor
A new instance of Message.
- #send ⇒ Object
- #subject(text) ⇒ Object
- #to(email, phone = nil) ⇒ Object
Constructor Details
#initialize ⇒ Message
Returns a new instance of Message.
3 4 5 6 7 8 |
# File 'lib/digitsend/message.rb', line 3 def initialize @to = [] @cc = [] @attachments = [] @phone_numbers = {} end |
Class Method Details
.send(&block) ⇒ Object
10 11 12 |
# File 'lib/digitsend/message.rb', line 10 def self.send(&block) new.tap { |m| yield(m) }.send end |
Instance Method Details
#attach(filename, data = nil) ⇒ Object
32 33 34 |
# File 'lib/digitsend/message.rb', line 32 def attach(filename, data = nil) @attachments << [ filename, data ] end |
#body(text) ⇒ Object
28 29 30 |
# File 'lib/digitsend/message.rb', line 28 def body(text) @body = text end |
#cc(email, phone = nil) ⇒ Object
19 20 21 22 |
# File 'lib/digitsend/message.rb', line 19 def cc(email, phone = nil) @cc << email @phone_numbers[email] = phone if phone end |
#send ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/digitsend/message.rb', line 36 def send Client.call '/messages', message: { to: @to.join(', '), cc: @cc.join(', '), subject: @subject, body: @body, s3_file_uuids: s3_file_uuids, phone_numbers: @phone_numbers } end |
#subject(text) ⇒ Object
24 25 26 |
# File 'lib/digitsend/message.rb', line 24 def subject(text) @subject = text end |
#to(email, phone = nil) ⇒ Object
14 15 16 17 |
# File 'lib/digitsend/message.rb', line 14 def to(email, phone = nil) @to << email @phone_numbers[email] = phone if phone end |