All Projects â†’ esbanarango â†’ zapier-REST-hooks

esbanarango / zapier-REST-hooks

Licence: MIT, MIT licenses found Licenses found MIT LICENSE.txt MIT MIT-LICENSE
Rails engine that provides all the functionality/structure for Zapier REST hooks pattern.

Programming Languages

ruby
36898 projects - #4 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to zapier-REST-hooks

google docs-ruby
A library which allows you to edit your spreadsheets with pleasure
Stars: ✭ 18 (-21.74%)
Mutual labels:  gem
jsonapi-serializer-formats
💎 Gem to enrich jsonapi-serializer with multiple formats
Stars: ✭ 20 (-13.04%)
Mutual labels:  gem
secs4java8
This library is SEMI-SECS-communicate implementation on Java8.
Stars: ✭ 46 (+100%)
Mutual labels:  gem
rspec-json matchers
A collection of RSpec matchers for testing JSON data.
Stars: ✭ 23 (+0%)
Mutual labels:  gem
activerecord-shard for
Database Sharding Library for ActiveRecord
Stars: ✭ 16 (-30.43%)
Mutual labels:  gem
ascii85gem
A simple gem that provides methods for encoding/decoding Adobe’s binary-to-text encoding of the same name.
Stars: ✭ 18 (-21.74%)
Mutual labels:  gem
colorama
A Gem for extracting the most prevalent colors from an image
Stars: ✭ 20 (-13.04%)
Mutual labels:  gem
icodi
Deterministic Random SVG Icon Generator
Stars: ✭ 18 (-21.74%)
Mutual labels:  gem
modular routes
Dedicated controllers for each of your Rails route actions.
Stars: ✭ 45 (+95.65%)
Mutual labels:  gem
sixarm ruby unaccent
SixArm.com » Ruby » Unaccent replaces a string's accented characters with ASCII characters.
Stars: ✭ 15 (-34.78%)
Mutual labels:  gem
make model searchable
Adds simlpe search functionality to models
Stars: ✭ 27 (+17.39%)
Mutual labels:  gem
zengin-rb
💎 The ruby implementation of ZenginCode.
Stars: ✭ 83 (+260.87%)
Mutual labels:  gem
annoy.rb
annoy-rb provides Ruby bindings for the Annoy (Approximate Nearest Neighbors Oh Yeah).
Stars: ✭ 23 (+0%)
Mutual labels:  gem
delayed job worker pool
Worker process pooling for Delayed Job
Stars: ✭ 32 (+39.13%)
Mutual labels:  gem
best buy ruby
Ruby library for the BestBuy API. https://www.bestbuy.com
Stars: ✭ 21 (-8.7%)
Mutual labels:  gem
perf check
PERRRFFF CHERRRRK!
Stars: ✭ 16 (-30.43%)
Mutual labels:  gem
capybara-json
No description or website provided.
Stars: ✭ 61 (+165.22%)
Mutual labels:  gem
profiling
Non-discriminatory profiling of Ruby code leveraging the ruby-prof gem
Stars: ✭ 12 (-47.83%)
Mutual labels:  gem
rails cursor pagination
Add cursor pagination to your ActiveRecord backed application
Stars: ✭ 21 (-8.7%)
Mutual labels:  gem
webpay rails
WebpayRails is an easy solution for integrate Transbank Webpay in Rails applications
Stars: ✭ 16 (-30.43%)
Mutual labels:  gem

ZapierRestHooks

Gem Version Build Status Code Climate Test Coverage

Rails engine that provides functionality for Zapier REST hooks pattern.

Installation

Add this line to your application's Gemfile:

gem 'zapier_rest_hooks'

After you've added ZapierRestHooks to your gemfile, you can install it with:

rails generate zapier_rest_hooks:install

The generator will mount ZapierRestHooks in your config/routes.rb at the path /hooks.

Now run rake db:migrate

Usage

By adding ZapierRestHooks engine to your Rails app, you will have access to ZapierRestHooks::Hook model. This model maps the Hook object described on Zapier REST Hooks pattern.

Here's an example on how you can integrate hooks into your existing models.

Note:

This is simple example, in real life you should wrap ZapierRestHooks::Hook.trigger inside a Job.

A hook can be scoped to an owner. By default it's nil but you can specify it if you need it.

class Candidate < ActiveRecord::Base
  # Relations
  belongs_to :organization

  # Callbacks
  after_create :trigger_hooks_with_owner, if: :organization
  after_create :trigger_hooks_without_owner, unless: :organization

  private

  def trigger_hooks_with_owner
    return unless ZapierRestHooks::Hook.hooks_exist?('new_candidate', organization)
    # Scoped event.
    ZapierRestHooks::Hook.trigger('new_candidate', self.to_json, organization)
  end

  def trigger_hooks_without_owner
    return unless ZapierRestHooks::Hook.hooks_exist?('new_candidate')
    # Global event.
    ZapierRestHooks::Hook.trigger('new_candidate', self.to_json)
  end
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/esbanarango/zapier-REST-hooks. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Author

This was written by Esteban Arango Medina, based on Ryan Alyn Porter initial solution.

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].