watermarkchurch / wcc-contentful

An alternative to Contentful's contentful.rb ruby client, contentful_model, and contentful_rails gems all in one.
MIT License
2 stars 1 forks source link

Facilitate attaching jobs to be run whenever a webhook is received #46

Closed gburgett closed 6 years ago

gburgett commented 6 years ago

The gem can now be configured with additional jobs to be run whenever the mounted engine receives a webhook at /webhooks/receive. If the job is an ActiveJob class, then perform_later will be called with the raw event JSON as it's only parameter. Otherwise if the job responds to call, it will be immediately invoked with the raw event JSON.

Syntax:

# initializers/wcc_contentful.rb
WCC::Contentful.configure do |config|
  # ...
  config.webhook_jobs << MyJobClass
  config.webhook_jobs << ->(event) { ... }
end

The gem now automatically configures a webhook to point to the correct URL on the app, if given a management_token and app_url.

fixes #39

gburgett commented 6 years ago

Ready for review