Module: Mailgun::Tracking

Defined in:
lib/mailgun/tracking.rb,
lib/mailgun/tracking/railtie.rb,
lib/mailgun/tracking/version.rb,
lib/mailgun/tracking/listener.rb,
lib/mailgun/tracking/notifier.rb,
lib/mailgun/tracking/signature.rb,
lib/mailgun/tracking/exceptions.rb,
lib/mailgun/tracking/middleware.rb,
lib/mailgun/tracking/subscriber.rb,
lib/mailgun/tracking/subscriber/evented.rb,
lib/mailgun/tracking/subscriber/all_messages.rb,
lib/generators/mailgun/tracking/install_generator.rb

Overview

Namespace for classes and modules that handle Mailgun Webhooks.

Defined Under Namespace

Modules: Subscriber Classes: InstallGenerator, Listener, Middleware, Notifier, Railtie, Signature

Constant Summary collapse

DEFAULT_ENDPOINT =
'/mailgun'.freeze
VERSION =
'0.2.1'.freeze
Error =

A general Mailgun Tracking exception.

Class.new(StandardError)
InvalidSignature =

Raised when signature is invalid.

Class.new(Error)

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyString

Mailgun API public key.

Returns:

  • (String)

20
21
22
# File 'lib/mailgun/tracking.rb', line 20

def api_key
  @api_key
end

.endpointString

Mailgun Webhook API endpoint

Returns:

  • (String)

25
26
27
# File 'lib/mailgun/tracking.rb', line 25

def endpoint
  @endpoint
end

Class Method Details

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

Default way to setup Mailgun Tracking.

Examples:

Mailgun::Tracking.configure do |config|
  config.api_key = ENV['MAILGUN_API_KEY']
  config.endpoint = '/mailgun-tracking'
end

Yields:

  • (_self)

Yield Parameters:


34
35
36
# File 'lib/mailgun/tracking.rb', line 34

def configure
  yield(self)
end

.notifierMailgun::Tracking::Notifier

A Notifier instance.

Examples:

Mailgun::Tracking.configure do |config|
  config.notifier.subscribe :delivered do |payload|
    # Do something with the incoming data.
  end

  config.notifier.subscribe :bounced, Bounced.new

  config.notifier.all do |payload|
    # Handle all event types.
  end
end

Returns:


59
60
61
# File 'lib/mailgun/tracking.rb', line 59

def notifier
  @notifier ||= Notifier.new
end