Class: UniOne::Mail

Inherits:
Object
  • Object
show all
Defined in:
lib/unione/helpers/mail/mail.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMail

Returns a new instance of Mail.



7
8
9
10
11
12
13
14
15
# File 'lib/unione/helpers/mail/mail.rb', line 7

def initialize
  @template = {}
  @from = {}
  @track = {}
  @global_substitutions = {}
  @recipients = []
  @attachments = []
  @inline_attachments = []
end

Instance Attribute Details

#attachmentsObject

Returns the value of attribute attachments.



3
4
5
# File 'lib/unione/helpers/mail/mail.rb', line 3

def attachments
  @attachments
end

#bodyObject

Returns the value of attribute body.



3
4
5
# File 'lib/unione/helpers/mail/mail.rb', line 3

def body
  @body
end

#force_sendObject

Returns the value of attribute force_send.



3
4
5
# File 'lib/unione/helpers/mail/mail.rb', line 3

def force_send
  @force_send
end

#fromObject

Returns the value of attribute from.



3
4
5
# File 'lib/unione/helpers/mail/mail.rb', line 3

def from
  @from
end

#global_metadataObject

Returns the value of attribute global_metadata.



3
4
5
# File 'lib/unione/helpers/mail/mail.rb', line 3

def 
  @global_metadata
end

#global_substitutionsObject

Returns the value of attribute global_substitutions.



3
4
5
# File 'lib/unione/helpers/mail/mail.rb', line 3

def global_substitutions
  @global_substitutions
end

#headersObject

Returns the value of attribute headers.



3
4
5
# File 'lib/unione/helpers/mail/mail.rb', line 3

def headers
  @headers
end

#inline_attachmentsObject

Returns the value of attribute inline_attachments.



3
4
5
# File 'lib/unione/helpers/mail/mail.rb', line 3

def inline_attachments
  @inline_attachments
end

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/unione/helpers/mail/mail.rb', line 3

def options
  @options
end

#recipientsObject

Returns the value of attribute recipients.



3
4
5
# File 'lib/unione/helpers/mail/mail.rb', line 3

def recipients
  @recipients
end

#reply_toObject

Returns the value of attribute reply_to.



3
4
5
# File 'lib/unione/helpers/mail/mail.rb', line 3

def reply_to
  @reply_to
end

#skip_unsubscribeObject

Returns the value of attribute skip_unsubscribe.



3
4
5
# File 'lib/unione/helpers/mail/mail.rb', line 3

def skip_unsubscribe
  @skip_unsubscribe
end

#subjectObject

Returns the value of attribute subject.



3
4
5
# File 'lib/unione/helpers/mail/mail.rb', line 3

def subject
  @subject
end

#templateObject

Returns the value of attribute template.



3
4
5
# File 'lib/unione/helpers/mail/mail.rb', line 3

def template
  @template
end

#trackObject

Returns the value of attribute track.



3
4
5
# File 'lib/unione/helpers/mail/mail.rb', line 3

def track
  @track
end

Instance Method Details

#to_jsonObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/unione/helpers/mail/mail.rb', line 20

def to_json(*)
  {
    message: {
      global_substitutions: self.global_substitutions,
      body: self.body,
      subject: self.subject,
      reply_to: self.reply_to,
      recipients: self.recipients,
      global_metadata: self.,
      headers: self.headers,
      attachments: self.attachments,
      inline_attachments: self.inline_attachments,
      options: self.options,
      skip_unsubscribe: self.skip_unsubscribe,
      force_send: self.force_send
    }.merge(self.template)
     .merge(self.from)
     .merge(self.track)
     .delete_if { |_, value| value.to_s.strip == '' || value == [] || value == {}}
  }
end