Class: SocketLabs::InjectionApi::Message::MessageBase
- Inherits:
-
Object
- Object
- SocketLabs::InjectionApi::Message::MessageBase
- Defined in:
- lib/socketlabs/injectionapi/message/message_base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#amp_body ⇒ Object
the AMP portion of the message body.
-
#api_template ⇒ Object
the Api Template for the message.
-
#charset ⇒ Object
the optional character set.
-
#html_body ⇒ Object
the HTML portion of the message body.
-
#mailing_id ⇒ Object
the custom MailingId for the message.
-
#message_id ⇒ Object
the custom MessageId for the message.
-
#plain_text_body ⇒ Object
the plain text portion of the message body.
-
#subject ⇒ Object
the message Subject.
Instance Method Summary collapse
-
#add_attachment(value) ⇒ Object
Add an attachment to the attachments list.
-
#add_custom_header(header, value = nil) ⇒ Object
Add a CustomHeader to the message.
-
#add_metadata(key, value = nil) ⇒ Object
Add a Metadata to the message.
-
#add_tag(value = nil) ⇒ Object
Add a Tag to the message.
-
#attachments ⇒ Object
Get the list of attachments.
-
#attachments=(value) ⇒ Object
Set the list of attachments.
-
#custom_headers ⇒ Object
Get the list of custom message headers added to the message.
-
#custom_headers=(value) ⇒ Object
Set the list of custom message headers added to the message.
-
#from_email_address ⇒ Object
Get the From email address.
-
#from_email_address=(value) ⇒ Object
Set the From email address.
-
#initialize(arguments = nil) ⇒ MessageBase
constructor
A new instance of MessageBase.
-
#metadata ⇒ Object
Get the list of metadata added to the message.
-
#metadata=(value) ⇒ Object
Set the list of metadata added to the message.
-
#reply_to_email_address ⇒ Object
Get the optional reply to email address for the message.
-
#reply_to_email_address=(value) ⇒ Object
Set the optional reply to address for the message.
-
#tags ⇒ Object
Get the list of tags added to the message.
-
#tags=(value) ⇒ Object
Set the list of tags added to the message.
Constructor Details
#initialize(arguments = nil) ⇒ MessageBase
Returns a new instance of MessageBase.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 33 def initialize(arguments = nil) unless arguments.nil? || arguments.empty? unless arguments[:subject].nil? || arguments[:subject].empty? @subject = arguments[:subject] end unless arguments[:plain_text_body].nil? || arguments[:plain_text_body].empty? @plain_text_body = arguments[:plain_text_body] end unless arguments[:html_body].nil? || arguments[:html_body].empty? @html_body = arguments[:html_body] end unless arguments[:amp_body].nil? || arguments[:amp_body].empty? @amp_body = arguments[:amp_body] end unless arguments[:api_template].nil? || arguments[:api_template].empty? @api_template = arguments[:api_template] end unless arguments[:mailing_id].nil? || arguments[:mailing_id].empty? @mailing_id = arguments[:mailing_id] end unless arguments[:message_id].nil? || arguments[:message_id].empty? = arguments[:message_id] end unless arguments[:charset].nil? || arguments[:charset].empty? @charset = arguments[:charset] end unless arguments[:charset].nil? || arguments[:charset].empty? @charset = arguments[:charset] end end @from_email_address = nil @reply_to_email_address = nil = Array.new @custom_headers = Array.new = Array.new = Array.new end |
Instance Attribute Details
#amp_body ⇒ Object
the AMP portion of the message body. (Optional) Either TextBody or HtmlBody must be used with the AmpBody or use a ApiTemplate
18 19 20 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 18 def amp_body @amp_body end |
#api_template ⇒ Object
the Api Template for the message. (Optional) Either TextBody or HtmlBody must be used with the AmpBody or use a ApiTemplate
21 22 23 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 21 def api_template @api_template end |
#charset ⇒ Object
the optional character set. Default is UTF-8
31 32 33 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 31 def charset @charset end |
#html_body ⇒ Object
the HTML portion of the message body. (Optional) Either TextBody or HtmlBody must be used with the AmpBody or use a ApiTemplate
15 16 17 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 15 def html_body @html_body end |
#mailing_id ⇒ Object
the custom MailingId for the message. See www.socketlabs.com/blog/best-practices-for-using-custom-mailingids-and-messageids/ for more information.
25 26 27 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 25 def mailing_id @mailing_id end |
#message_id ⇒ Object
the custom MessageId for the message. See www.socketlabs.com/blog/best-practices-for-using-custom-mailingids-and-messageids/ for more information.
29 30 31 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 29 def end |
#plain_text_body ⇒ Object
the plain text portion of the message body. (Optional) Either TextBody or HtmlBody must be used with the AmpBody or use a ApiTemplate
12 13 14 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 12 def plain_text_body @plain_text_body end |
#subject ⇒ Object
the message Subject.
9 10 11 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 9 def subject @subject end |
Instance Method Details
#add_attachment(value) ⇒ Object
Add an attachment to the attachments list.
137 138 139 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 137 def (value) .push(value) end |
#add_custom_header(header, value = nil) ⇒ Object
Add a CustomHeader to the message.
163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 163 def add_custom_header(header, value = nil) if header.kind_of? CustomHeader @custom_headers.push(header) elsif header.kind_of? String @custom_headers.push(CustomHeader.new(header, value)) end end |
#add_metadata(key, value = nil) ⇒ Object
Add a Metadata to the message.
197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 197 def (key, value = nil) if key.kind_of? Metadata .push(key) elsif key.kind_of? String .push(Metadata.new(key, value)) end end |
#add_tag(value = nil) ⇒ Object
Add a Tag to the message.
230 231 232 233 234 235 236 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 230 def add_tag(value = nil) if value.kind_of? String .push(value) end end |
#attachments ⇒ Object
Get the list of attachments.
120 121 122 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 120 def end |
#attachments=(value) ⇒ Object
Set the list of attachments.
124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 124 def (value) = Array.new unless value.nil? || value.empty? value.each do |v1| if v1.instance_of? Attachment .push(v1) else raise StandardError("Invalid type for attachments, type of 'Attachment' was expected") end end end end |
#custom_headers ⇒ Object
Get the list of custom message headers added to the message.
142 143 144 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 142 def custom_headers @custom_headers end |
#custom_headers=(value) ⇒ Object
Set the list of custom message headers added to the message.
147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 147 def custom_headers=(value) @custom_headers = Array.new unless value.nil? || value.empty? value.each do |v1| if v1.instance_of? CustomHeader @custom_headers.push(v1) else raise StandardError("Invalid type for custom_headers, type of 'CustomHeader' was expected") end end end end |
#from_email_address ⇒ Object
Get the From email address.
86 87 88 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 86 def from_email_address @from_email_address end |
#from_email_address=(value) ⇒ Object
Set the From email address.
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 90 def from_email_address=(value) unless value.nil? if value.kind_of? EmailAddress @from_email_address = value elsif value.kind_of? String @from_email_address = EmailAddress.new(value) else raise StandardError("Invalid type for reply_to_email_address, type of 'EmailAddress' or 'String' was expected") end end end |
#metadata ⇒ Object
Get the list of metadata added to the message.
176 177 178 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 176 def end |
#metadata=(value) ⇒ Object
Set the list of metadata added to the message.
181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 181 def (value) = Array.new unless value.nil? || value.empty? value.each do |v1| if v1.instance_of? Metadata .push(v1) else raise StandardError("Invalid type for metadata, type of 'Metadata' was expected") end end end end |
#reply_to_email_address ⇒ Object
Get the optional reply to email address for the message.
103 104 105 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 103 def reply_to_email_address @reply_to_email_address end |
#reply_to_email_address=(value) ⇒ Object
Set the optional reply to address for the message.
107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 107 def reply_to_email_address=(value) unless value.nil? if value.kind_of?(EmailAddress) @reply_to_email_address = value elsif value.kind_of? String @from_email_address = EmailAddress.new(value) else raise StandardError("Invalid type for reply_to_email_address, type of 'EmailAddress' or 'String' was expected") end end end |
#tags ⇒ Object
Get the list of tags added to the message.
210 211 212 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 210 def end |
#tags=(value) ⇒ Object
Set the list of tags added to the message.
215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/socketlabs/injectionapi/message/message_base.rb', line 215 def (value) = Array.new unless value.nil? || value.empty? value.each do |v1| if v1.kind_of? String .push(v1) else raise StandardError("Invalid type for tag, type of 'String' was expected") end end end end |