evendis / mandrill-rails

Webhook processing and event decoration to make using Mandrill with Rails just that much easier
MIT License
288 stars 36 forks source link

Allow configuration of callback host from Rails controller #47

Open AMHOL opened 5 years ago

AMHOL commented 5 years ago

Intention

Allow for configuration of a custom callback host from Rails controller, this means we can decouple the handler methods from the controller.

Usage

class MyCustomCallbackHost
  def handle_hard_bounce(payload)
    # Do stuff with payload
  end
end

module Mandrill
  module Webhooks
    class InboxController < ApplicationController
      include Mandrill::Rails::WebHookProcessor

      ignore_unhandled_events!
      authenticate_with_mandrill_keys! 'YOUR_MANDRILL_WEBHOOK_KEY'
      callback_host(MyCustomCallbackHost.new)
    end
  end
end