class SocketLabs::InjectionApi::Core::Serialization::MessageJson
Attributes
the AMP portion of the message body.
the api template.
the optional character set. Default is UTF-8
the from email address.
the HTML portion of the message body.
the custom mailing id.
the the MergeDataJson
for the message
the custom message id.
the plain text portion of the message body.
the optional reply to email address.
the message subject.
Public Class Methods
# 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 @to_email_address = Array.new @cc_email_address = Array.new @bcc_email_address = Array.new end
Public Instance Methods
Add an AttachmentJson
to the attachments list. @param [AttachmentJson] value
# File lib/socketlabs/injectionapi/core/serialization/message_json.rb, line 73 def add_attachments(value) if value.instance_of? AttachmentJson @attachments.push(value) end end
Add a CustomHeaderJson
to the custom header list @param [CustomHeaderJson] value
# 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
Get the list of attachments. @return [Array]
# File lib/socketlabs/injectionapi/core/serialization/message_json.rb, line 55 def attachments @attachments end
Set the list of AttachmentJson
. @param [Array] value
# File lib/socketlabs/injectionapi/core/serialization/message_json.rb, line 60 def attachments=(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
Get the BCC email address list @return [Array]
# File lib/socketlabs/injectionapi/core/serialization/message_json.rb, line 144 def bcc_email_address @bcc_email_address end
Set the BCC email address list @param [Array] value
# 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
Get the CC email address list @return [Array]
# File lib/socketlabs/injectionapi/core/serialization/message_json.rb, line 126 def cc_email_address @cc_email_address end
Set the CC email address list @param [Array] value
# 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
Get the list of CustomHeaderJson. @return [Array]
# File lib/socketlabs/injectionapi/core/serialization/message_json.rb, line 82 def custom_headers @custom_headers end
Set the list of CustomHeaderJson
. @param [Array] value
# 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
Get the To email address list @return [Array]
# File lib/socketlabs/injectionapi/core/serialization/message_json.rb, line 108 def to_email_address @to_email_address end
Set the To email address list @param [Array] value
# 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
build json hash for MessageJson
@return [hash]
# 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 @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 @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