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.
-
#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.
-
#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 |
# 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 = nil @charset = nil @from_email_address = nil @reply_to = nil @merge_data = MergeDataJson.new = Array.new @custom_headers = 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 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.
73 74 75 76 77 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 73 def (value) if value.instance_of? AttachmentJson .push(value) end end |
#add_custom_header(value) ⇒ Object
Add a CustomHeaderJson to the custom header list
100 101 102 103 104 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 100 def add_custom_header(value) if value.instance_of? CustomHeaderJson @custom_headers.push(value) end end |
#attachments ⇒ Array
Get the list of attachments.
55 56 57 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 55 def end |
#attachments=(value) ⇒ Object
Set the list of AttachmentJson.
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 60 def (value) = Array.new unless value.nil? || value.empty? value.each do |v1| if v1.instance_of? AttachmentJson .push(v1) end end end end |
#bcc_email_address ⇒ Array
Get the BCC email address list
144 145 146 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 144 def bcc_email_address @bcc_email_address end |
#bcc_email_address=(value) ⇒ Object
Set the BCC email address list
149 150 151 152 153 154 155 156 157 158 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 149 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
126 127 128 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 126 def cc_email_address @cc_email_address end |
#cc_email_address=(value) ⇒ Object
Set the CC email address list
131 132 133 134 135 136 137 138 139 140 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 131 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.
82 83 84 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 82 def custom_headers @custom_headers end |
#custom_headers=(value) ⇒ Object
Set the list of CustomHeaderJson.
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 87 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 |
#to_email_address ⇒ Array
Get the To email address list
108 109 110 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 108 def to_email_address @to_email_address end |
#to_email_address=(value) ⇒ Object
Set the To email address list
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 113 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
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 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 |
# File 'lib/socketlabs/injectionapi/core/serialization/message_json.rb', line 162 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 .nil? || .empty? json[:messageId] = 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 .nil? || .length == 0 e = Array.new .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 |