0.01
No release in over 3 years
Low commit activity in last 3 years
Rails engine that receives Hubspot webhooks, authenticates them, and passes them to the application for further processing.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 12.0
~> 3.0

Runtime

 Project Readme

HubspotEvent

HubspotEvent is based on StripeEvent and uses the ActiveSupport::Notifications API to process events. Subscribe to event types to process Hubspot events.

Installation

Add this line to your application's Gemfile:

gem 'hubspot_event'

And then execute:

$ bundle

Or install it yourself as:

$ gem install hubspot_event

Usage

# config/initializers/hubspot.rb
HubspotEvent.client_secret = ENV["HUBSPOT_CLIENT_SECRET"]

HubspotEvent.configure do |events|
  events.subscribe 'company.propertyChange' do |event|
    event["subscriptionType"]   #=> "company.propertyChange"
    event["portalId"]           #=> 123456
    event["objectId"]           #=> 182393
    event["propertyName"]       #=> "hubspot_owner_id"
    event["propertyValue"]      #=> 123
  end

  events.all do |event|
    # Handle all event types
  end
end

Subscriber objects that respond to #call

class HubspotCustomer
  def call(event)
    case event["subscriptionType"]
    when "customer.propertyChange"
      property_change(event)
    end
  end

  def property_change(event)
    # Handle property change event
  end
end
HubspotEvent.configure do |events|
  events.subscribe 'customer', HubspotCustomer.new
end

Webhook Signatures

Hubspot webhooks requests are signed with a SHA-256 signature, generated from the client secret and the payload body. The request signature is cryptographically verified before processing any of the events in the webhook. Any requests with an invalid signature will be rejected with a 404 response.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/huntresslabs/hubspot_event. 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.

License

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

Code of Conduct

Everyone interacting in the HubspotEvent project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.