Module: Chimpster

Defined in:
lib/chimpster.rb,
lib/chimpster/message_extensions/shared.rb

Defined Under Namespace

Modules: SharedMessageExtensions

Constant Summary collapse

MAX_RETRIES =
2

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyObject

Returns the value of attribute api_key.



15
16
17
# File 'lib/chimpster.rb', line 15

def api_key
  @api_key
end

.fromObject

Returns the value of attribute from.



15
16
17
# File 'lib/chimpster.rb', line 15

def from
  @from
end

.loggerObject

Returns the value of attribute logger.



15
16
17
# File 'lib/chimpster.rb', line 15

def logger
  @logger
end

.max_retriesObject

Returns the value of attribute max_retries.



15
16
17
# File 'lib/chimpster.rb', line 15

def max_retries
  @max_retries
end

.sleep_between_retriesObject

Returns the value of attribute sleep_between_retries.



15
16
17
# File 'lib/chimpster.rb', line 15

def sleep_between_retries
  @sleep_between_retries
end

.toObject

Returns the value of attribute to.



15
16
17
# File 'lib/chimpster.rb', line 15

def to
  @to
end

.uakariObject

Returns the value of attribute uakari.



15
16
17
# File 'lib/chimpster.rb', line 15

def uakari
  @uakari
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Chimpster)

    the object that the method was called on



29
30
31
# File 'lib/chimpster.rb', line 29

def configure
  yield self
end

.send(message) ⇒ Object



33
34
35
36
37
# File 'lib/chimpster.rb', line 33

def send (message)
     response = @uakari.send_email(message)

     response
end

.send_through_chimpster(message) ⇒ Object

:nodoc:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/chimpster.rb', line 39

def send_through_chimpster(message) #:nodoc:
  puts 'sending email'
  @retries = 0
  _from =  message['from'].to_s
  _from = @from unless @from == nil
  _to =message['to'].to_s
  _to = @to unless @to == nil
  _html = message.body_html
  _text = message.body_text
  options= {
      :text       => _text,
      :html       => _html,
      :subject    => message.subject,
      :from_email => _from,
      :to_email   => _to.split(','),
      :reply_to   => _from.split(',')
   }
  response = self.send({
    :track_opens => true,
    :track_clicks => true,
    :message => options,
    :tags => (message.tag.to_s if message.tag)
  })
  c=response['status']
  v= ['queued','sent'].include?(c)
  if v == false
    logger.info "ERROR Sending Email via Chimpster #{response.to_s}"
  else
    logger.info "Email Sent via Chimpster #{response.to_s}"
  end
  v
end