Class: MailchimpSes

Inherits:
MonsterMash::Base
  • Object
show all
Defined in:
lib/mailchimp_ses.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{ :autogen_html => true }
OPTIONAL_MESSAGE_FIELDS =
[:to_name, :reply_to, :cc_email, :cc_name, :bcc_email, :bcc_name]

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyObject

Returns the value of attribute api_key.



12
13
14
# File 'lib/mailchimp_ses.rb', line 12

def api_key
  @api_key
end

Class Method Details

.parse_message_options(message_options) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/mailchimp_ses.rb', line 55

def self.parse_message_options(message_options)
  message = {
    :html => extract_param(message_options, :html),
    :text => message_options[:text],
    :subject => extract_param(message_options, :subject),
    :from_name => extract_param(message_options, :from_name),
    :from_email => extract_param(message_options, :from_email),
    :to_email => convert_to_hash_array(extract_param(message_options, :to_email))
  }

  OPTIONAL_MESSAGE_FIELDS.each do |field|
    set_optional_field!(message, message_options, field)
  end

  # Check lengths of arrays.
  check_recipients!(message, :to_email, :to_name)
  check_recipients!(message, :cc_email, :cc_name)
  check_recipients!(message, :bcc_email, :bcc_name)

  message
end

.parse_options(options) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/mailchimp_ses.rb', line 36

def self.parse_options(options)
  options = DEFAULT_OPTIONS.merge(options)

  # Handle tags.
  tags = nil
  if options[:tags] && options[:tags].size > 0
    tags = convert_to_hash_array(options[:tags])
  end

  {
    :message => parse_message_options(options[:message]),
    :track_opens => extract_param(options, :track_opens).to_s,
    :track_clicks => extract_param(options, :track_clicks).to_s,
    :autogen_html => extract_param(options, :autogen_html).to_s,
    :tags => tags
  }
end