Webhookr::Vero
This gem is a plugin for Webhookr that enables your application to accept webhooks from vero.
Installation
Add this line to your application's Gemfile:
gem 'webhookr-vero'
Or install it yourself:
$ gem install webhookr-vero
webhookr is installed as a dependency of webhookr-vero. If you have not setup Webhookr, do so now:
rails g webhookr:add_route
Usage
Once you have the gem installed run the generator to add the code to your initializer. An initializer will be created if you do not have one.
rails g webhookr:vero:init *initializer_name* -s
Run the generator to create an example file to handle vero webhooks.
rails g webhookr:vero:example_hooks
Or create a vero handler class for any event that you want to handle. For example to handle unsubscribes you would create a class as follows:
class VeroHooks
def on_unsubscribed(incoming)
# Your custom logic goes here.
user = incoming.payload.user
puts("User unsubscribed: (#{user.email})")
end
end
For a complete list of events, and the payload format, see below.
Edit config/initializers/initializer_name and change the commented line to point to your custom vero event handling class. If your class was called VeroHooks the configuration line would look like this:
Webhookr::Vero::Adapter.config.callback = VeroHooks
To see the list of vero URLs your application can use when you configure vero webhooks, run the provided webhookr rake task:
rake webhookr:services
Example output:
vero:
GET /webhooks/events/vero/19xl64emxvn
POST /webhooks/events/vero/19xl64emxvn
Vero Events & Payload
Events
All webhook events are supported. For further information on these events, see the vero documentation.
Vero Event | Event Handler |
---|---|
Email Sent | on_sent(incoming) |
Email Delivered | on_delivered(incoming) |
Email Opened | on_opened(incoming) |
Email Clicked | on_clicked(incoming) |
Email Bounced | on_bounced(incoming) |
User Unsubscribed | on_unsubscribed(incoming) |
User Updated | on_user_updated(incoming) |
Payload
The payload is the full payload data from as per the vero documentation, converted to an OpenStruct for ease of access. Examples can be found in the example hook file.
- [http://www.getvero.com/help/reporting/setting-up-veros-webhooks/](vero - version: 2015-09-29)
webhookr-vero works with Rails 3.1, 3.2 and 4.0
Versioning
This library aims to adhere to Semantic Versioning 2.0.0. Violations of this scheme should be reported as bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, that version should be immediately yanked and/or a new version should be immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new major versions. As a result of this policy, once this gem reaches a 1.0 release, you can (and should) specify a dependency on this gem using the Pessimistic Version Constraint with two digits of precision. For example:
spec.add_dependency 'webhookr-vero', '~> 1.0'
While this gem is currently a 0.x release, suggestion is to require the exact version that works for your code:
spec.add_dependency 'webhookr-vero', '0.0.1'
License
webhookr-vero is released under the MIT license.