Class: SocketLabs::InjectionApi::Core::Serialization::MessageJson
- Inherits:
-
Object
- Object
- SocketLabs::InjectionApi::Core::Serialization::MessageJson
- Defined in:
- lib/socketlabs/injectionapi/core/serialization/message_json.rb
Instance Attribute Summary collapse
-
#amp_body ⇒ Object
the AMP portion of the message body.
-
#api_template ⇒ Object
the api template.
-
#charset ⇒ Object
the optional character set.
-
#from_email_address ⇒ Object
the from email address.
-
#html_body ⇒ Object
the HTML portion of the message body.
-
#mailing_id ⇒ Object
the custom mailing id.
-
#merge_data ⇒ Object
the the MergeDataJson for the message.
-
#message_id ⇒ Object
the custom message id.
-
#plain_text_body ⇒ Object
the plain text portion of the message body.
-
#reply_to ⇒ Object
the optional reply to email address.
-
#subject ⇒ Object
the message subject.
Instance Method Summary collapse
-
#add_attachments(value) ⇒ Object
Add an AttachmentJson to the attachments list.
-
#add_custom_header(value) ⇒ Object
Add a CustomHeaderJson to the custom header list.
-
#add_metadata(value = nil) ⇒ Object
Add a Tag to the message.
-
#attachments ⇒ Array
Get the list of attachments.
-
#attachments=(value) ⇒ Object
Set the list of AttachmentJson.
-
#bcc_email_address ⇒ Array
Get the BCC email address list.
-
#bcc_email_address=(value) ⇒ Object
Set the BCC email address list.
-
#cc_email_address ⇒ Array
Get the CC email address list.
-
#cc_email_address=(value) ⇒ Object
Set the CC email address list.
-
#custom_headers ⇒ Array
custom_headers Get the list of CustomHeaderJson.
-
#custom_headers=(value) ⇒ Object
Set the list of CustomHeaderJson.
-
#initialize ⇒ MessageJson
constructor
A new instance of MessageJson.
-
#metadata ⇒ Array
metadata Get the list of MetadataJson.
-
#metadata=(value) ⇒ Object
Set the list of MetadataJson.
-
#tags ⇒ Object
Get the list of tags added to the message.
-
#tags=(value) ⇒ Object
Set the list of tags added to the message.
-
#to_email_address ⇒ Array
Get the To email address list.
-
#to_email_address=(value) ⇒ Object
Set the To email address list.
-
#to_hash ⇒ hash
build json hash for MessageJson.
Constructor Details
#initialize ⇒ MessageJson
Returns a new instance of MessageJson.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 32 def initialize @subject = nil @plain_text_body = nil @html_body = nil @amp_body = nil @api_template = nil @mailing_id = nil @message_id = nil @charset = nil @from_email_address = nil @reply_to = nil @merge_data = MergeDataJson.new @attachments = Array.new @custom_headers = Array.new @metadata = Array.new @tags = Array.new @to_email_address = Array.new @cc_email_address = Array.new @bcc_email_address = Array.new end |
Instance Attribute Details
#amp_body ⇒ Object
the AMP portion of the message body.
15 16 17 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 15 def amp_body @amp_body end |
#api_template ⇒ Object
the api template.
17 18 19 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 17 def api_template @api_template end |
#charset ⇒ Object
the optional character set. Default is UTF-8
23 24 25 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 23 def charset @charset end |
#from_email_address ⇒ Object
the from email address.
25 26 27 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 25 def from_email_address @from_email_address end |
#html_body ⇒ Object
the HTML portion of the message body.
13 14 15 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 13 def html_body @html_body end |
#mailing_id ⇒ Object
the custom mailing id.
19 20 21 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 19 def mailing_id @mailing_id end |
#merge_data ⇒ Object
the the MergeDataJson for the message
29 30 31 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 29 def merge_data @merge_data end |
#message_id ⇒ Object
the custom message id.
21 22 23 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 21 def @message_id end |
#plain_text_body ⇒ Object
the plain text portion of the message body.
11 12 13 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 11 def plain_text_body @plain_text_body end |
#reply_to ⇒ Object
the optional reply to email address.
27 28 29 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 27 def reply_to @reply_to end |
#subject ⇒ Object
the message subject.
9 10 11 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 9 def subject @subject end |
Instance Method Details
#add_attachments(value) ⇒ Object
Add an AttachmentJson to the attachments list.
75 76 77 78 79 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 75 def (value) if value.instance_of? AttachmentJson @attachments.push(value) end end |
#add_custom_header(value) ⇒ Object
Add a CustomHeaderJson to the custom header list
103 104 105 106 107 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 103 def add_custom_header(value) if value.instance_of? CustomHeaderJson @custom_headers.push(value) end end |
#add_metadata(value = nil) ⇒ Object
Add a Tag to the message.
131 132 133 134 135 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 131 def (value) if value.instance_of? MetadataJson @metadata.push(value) end end |
#attachments ⇒ Array
Get the list of attachments.
57 58 59 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 57 def @attachments end |
#attachments=(value) ⇒ Object
Set the list of AttachmentJson.
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 62 def (value) @attachments = Array.new unless value.nil? || value.empty? value.each do |v1| if v1.instance_of? AttachmentJson @attachments.push(v1) end end end end |
#bcc_email_address ⇒ Array
Get the BCC email address list
204 205 206 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 204 def bcc_email_address @bcc_email_address end |
#bcc_email_address=(value) ⇒ Object
Set the BCC email address list
209 210 211 212 213 214 215 216 217 218 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 209 def bcc_email_address=(value) @bcc_email_address = Array.new unless value.nil? || value.empty? value.each do |v1| if v1.instance_of? AddressJson @bcc_email_address.push(v1) end end end end |
#cc_email_address ⇒ Array
Get the CC email address list
186 187 188 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 186 def cc_email_address @cc_email_address end |
#cc_email_address=(value) ⇒ Object
Set the CC email address list
191 192 193 194 195 196 197 198 199 200 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 191 def cc_email_address=(value) @cc_email_address = Array.new unless value.nil? || value.empty? value.each do |v1| if v1.instance_of? AddressJson @cc_email_address.push(v1) end end end end |
#custom_headers ⇒ Array
custom_headers Get the list of CustomHeaderJson.
84 85 86 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 84 def custom_headers @custom_headers end |
#custom_headers=(value) ⇒ Object
Set the list of CustomHeaderJson.
90 91 92 93 94 95 96 97 98 99 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 90 def custom_headers=(value) @custom_headers = Array.new unless value.nil? || value.empty? value.each do |v1| if v1.instance_of? CustomHeaderJson @custom_headers.push(v1) end end end end |
#metadata ⇒ Array
metadata Get the list of MetadataJson.
112 113 114 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 112 def @metadata end |
#metadata=(value) ⇒ Object
Set the list of MetadataJson.
118 119 120 121 122 123 124 125 126 127 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 118 def (value) @metadata = Array.new unless value.nil? || value.empty? value.each do |v1| if v1.instance_of? MetadataJson @metadata.push(v1) end end end end |
#tags ⇒ Object
Get the list of tags added to the message.
138 139 140 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 138 def @tags end |
#tags=(value) ⇒ Object
Set the list of tags added to the message.
143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 143 def (value) @tags = Array.new unless value.nil? || value.empty? value.each do |v1| if v1.kind_of? String @tags.push(v1) else raise StandardError("Invalid type for tag, type of 'String' was expected") end end end end |
#to_email_address ⇒ Array
Get the To email address list
168 169 170 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 168 def to_email_address @to_email_address end |
#to_email_address=(value) ⇒ Object
Set the To email address list
173 174 175 176 177 178 179 180 181 182 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 173 def to_email_address=(value) @to_email_address = Array.new unless value.nil? || value.empty? value.each do |v1| if v1.instance_of? AddressJson @to_email_address.push(v1) end end end end |
#to_hash ⇒ hash
build json hash for MessageJson
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 222 def to_hash json = { :from => @from_email_address.to_hash } unless @subject.nil? || @subject.empty? json[:subject] = @subject end unless @html_body.nil? || @html_body.empty? json[:htmlBody] = @html_body end unless @amp_body.nil? || @amp_body.empty? json[:ampBody] = @amp_body end unless @plain_text_body.nil? || @plain_text_body.empty? json[:textBody] = @plain_text_body end unless @api_template.nil? json[:apiTemplate] = @api_template end unless @mailing_id.nil? || @mailing_id.empty? json[:mailingId] = @mailing_id end unless @message_id.nil? || @message_id.empty? json[:messageId] = @message_id end unless @reply_to.nil? json[:replyTo] = @reply_to.to_hash end unless @charset.nil? || @charset.empty? json[:charSet] = @charset end unless @to_email_address.nil? || @to_email_address.length == 0 e = Array.new @to_email_address.each do |value| e.push(value.to_hash) end json[:to] = e end unless @cc_email_address.nil? || @cc_email_address.length == 0 e = Array.new @cc_email_address.each do |value| e.push(value.to_hash) end json[:cc] = e end unless @bcc_email_address.nil? || @bcc_email_address.length == 0 e = Array.new @bcc_email_address.each do |value| e.push(value.to_hash) end json[:bcc] = e end unless @custom_headers.nil? || @custom_headers.length == 0 e = Array.new @custom_headers.each do |value| e.push(value.to_hash) end json[:customHeaders] = e end unless @metadata.nil? || @metadata.length == 0 e = Array.new @metadata.each do |value| e.push(value.to_hash) end json[:metadata] = e end unless @tags.nil? || @tags.length == 0 json[:tags] = @tags end unless @attachments.nil? || @attachments.length == 0 e = Array.new @attachments.each do |value| e.push(value.to_hash) end json[:attachments] = e end unless @merge_data.nil? || @merge_data.empty json[:mergeData] = @merge_data.to_hash end json end |