Class: Agents::MailgunAgent

Inherits:
Agent
  • Object
show all
Includes:
FormConfigurable
Defined in:
lib/huginn_mailgun_agent/mailgun_agent.rb

Instance Method Summary collapse

Instance Method Details

#checkObject



89
90
91
# File 'lib/huginn_mailgun_agent/mailgun_agent.rb', line 89

def check
  handle(interpolated)
end

#default_optionsObject



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/huginn_mailgun_agent/mailgun_agent.rb', line 51

def default_options
  {
    'connection_url' => 'mysql2://user:pass@localhost/database',
    'sql' => 'select email, name from emails order by id desc',
    'merge_event' => 'false',
    'mailgun_apikey' => '',
    'from_address' => '[email protected]',
    'testing_mode' => 'false',
    'mailgun_domain' => '',
    'mailgun_tracking' => 'false',
  }
end

#receive(incoming_events) ⇒ Object



93
94
95
96
97
# File 'lib/huginn_mailgun_agent/mailgun_agent.rb', line 93

def receive(incoming_events)
  incoming_events.each do |event|
      handle(interpolated(event), event.payload)
  end
end

#validate_optionsObject



74
75
76
77
78
79
80
81
82
83
# File 'lib/huginn_mailgun_agent/mailgun_agent.rb', line 74

def validate_options

  if options['merge_event'].present? && !%[true false].include?(options['merge_event'].to_s)
    errors.add(:base, "Oh no!!! if provided, merge_event must be 'true' or 'false'")
  end
  errors.add(:base, "Mailgun API Key Missing") unless options['mailgun_apikey'].present?
  errors.add(:base, "Missing From Address") unless options['from_address'].present?
  errors.add(:base, "Missing Mailgun Domain") unless options['mailgun_domain'].present?
    
end

#working?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/huginn_mailgun_agent/mailgun_agent.rb', line 85

def working?
  !recent_error_logs?
end