Class: Paubox::Message
- Inherits:
-
Object
- Object
- Paubox::Message
- Includes:
- FormatHelper
- Defined in:
- lib/paubox/message.rb
Overview
The Message class is for building a Paubox email message using a hash.
Direct Known Subclasses
Constant Summary
Constants included from FormatHelper
Instance Attribute Summary collapse
-
#allow_non_tls ⇒ Object
Returns the value of attribute allow_non_tls.
-
#bcc ⇒ Object
Returns the value of attribute bcc.
-
#cc ⇒ Object
Returns the value of attribute cc.
-
#force_secure_notification ⇒ Object
Returns the value of attribute force_secure_notification.
-
#from ⇒ Object
Returns the value of attribute from.
-
#html_content ⇒ Object
Returns the value of attribute html_content.
-
#reply_to ⇒ Object
Returns the value of attribute reply_to.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#text_content ⇒ Object
Returns the value of attribute text_content.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
- #add_attachment(file_path) ⇒ Object
- #attachments ⇒ Object
- #attachments=(args) ⇒ Object
-
#initialize(args) ⇒ Message
constructor
A new instance of Message.
- #send_message_payload ⇒ Object
Methods included from FormatHelper
#base64_encode_if_needed, #base64_encoded?, #convert_keys_to_json_version, #ruby_to_json_key, #squish, #string_or_array_to_array
Constructor Details
#initialize(args) ⇒ Message
Returns a new instance of Message.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/paubox/message.rb', line 10 def initialize(args) @from = args[:from] @to = args[:to] @cc = args[:cc] @bcc = args[:bcc] @subject = args[:subject] @reply_to = args[:reply_to] @text_content = args[:text_content] @html_content = args[:html_content] @packaged_attachments = [] @attachments = (args[:attachments]) @allow_non_tls = args.fetch(:allow_non_tls, false) @force_secure_notification = args.fetch(:force_secure_notification, nil) end |
Instance Attribute Details
#allow_non_tls ⇒ Object
Returns the value of attribute allow_non_tls.
7 8 9 |
# File 'lib/paubox/message.rb', line 7 def allow_non_tls @allow_non_tls end |
#bcc ⇒ Object
Returns the value of attribute bcc.
7 8 9 |
# File 'lib/paubox/message.rb', line 7 def bcc @bcc end |
#cc ⇒ Object
Returns the value of attribute cc.
7 8 9 |
# File 'lib/paubox/message.rb', line 7 def cc @cc end |
#force_secure_notification ⇒ Object
Returns the value of attribute force_secure_notification.
7 8 9 |
# File 'lib/paubox/message.rb', line 7 def force_secure_notification @force_secure_notification end |
#from ⇒ Object
Returns the value of attribute from.
7 8 9 |
# File 'lib/paubox/message.rb', line 7 def from @from end |
#html_content ⇒ Object
Returns the value of attribute html_content.
7 8 9 |
# File 'lib/paubox/message.rb', line 7 def html_content @html_content end |
#reply_to ⇒ Object
Returns the value of attribute reply_to.
7 8 9 |
# File 'lib/paubox/message.rb', line 7 def reply_to @reply_to end |
#subject ⇒ Object
Returns the value of attribute subject.
7 8 9 |
# File 'lib/paubox/message.rb', line 7 def subject @subject end |
#text_content ⇒ Object
Returns the value of attribute text_content.
7 8 9 |
# File 'lib/paubox/message.rb', line 7 def text_content @text_content end |
#to ⇒ Object
Returns the value of attribute to.
7 8 9 |
# File 'lib/paubox/message.rb', line 7 def to @to end |
Instance Method Details
#add_attachment(file_path) ⇒ Object
29 30 31 32 33 |
# File 'lib/paubox/message.rb', line 29 def (file_path) @packaged_attachments << { filename: file_path.split('/').last, content_type: `file --b --mime-type #{file_path}`.chomp, content: Base64.encode64(File.read(file_path)) } end |
#attachments ⇒ Object
35 36 37 |
# File 'lib/paubox/message.rb', line 35 def @packaged_attachments end |
#attachments=(args) ⇒ Object
39 40 41 |
# File 'lib/paubox/message.rb', line 39 def (args) @attachments = (args) end |
#send_message_payload ⇒ Object
25 26 27 |
# File 'lib/paubox/message.rb', line 25 def { data: { message: convert_keys_to_json_version(build_parts) } }.to_json end |