class SocketLabs::InjectionApi::Core::Serialization::MessageJson

Attributes

amp_body[RW]

the AMP portion of the message body.

api_template[RW]

the api template.

charset[RW]

the optional character set. Default is UTF-8

from_email_address[RW]

the from email address.

html_body[RW]

the HTML portion of the message body.

mailing_id[RW]

the custom mailing id.

merge_data[RW]

the the MergeDataJson for the message

message_id[RW]

the custom message id.

plain_text_body[RW]

the plain text portion of the message body.

reply_to[RW]

the optional reply to email address.

subject[RW]

the message subject.

Public Class Methods

new() click to toggle source
# 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_attachments(value) click to toggle source

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_custom_header(value) click to toggle source

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
attachments() click to toggle source

Get the list of attachments. @return [Array]

# File lib/socketlabs/injectionapi/core/serialization/message_json.rb, line 55
def attachments
  @attachments
end
attachments=(value) click to toggle source

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
bcc_email_address() click to toggle source

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
bcc_email_address=(value) click to toggle source

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
cc_email_address() click to toggle source

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
cc_email_address=(value) click to toggle source

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
custom_headers() click to toggle source

custom_headers

Get the list of CustomHeaderJson.
@return [Array]
# File lib/socketlabs/injectionapi/core/serialization/message_json.rb, line 82
def custom_headers
  @custom_headers
end
custom_headers=(value) click to toggle source

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
to_email_address() click to toggle source

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
to_email_address=(value) click to toggle source

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
to_hash() click to toggle source

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