SimpleHubspot
SimpleHubspot Gem is a pure light-weight implementation for Hubspot API
Installation
Add this line to your application's Gemfile:
gem 'simple_hubspot'And then execute:
$ bundle
Or install it yourself as:
$ gem install simple_hubspot
Usage
Basic Usage
require 'simple_hubspot'Setting your hapikey you can create a new file in initializers from Rails
rails g simple_hubspot:installWithout Rails
SimpleHubspot.configure do |config|
config.hapikey= "YOUR API KEY"
endCreate Or Update Contact
SimpleHubspot::Contact.create_or_update "email@email.com", { name: "John", age: 14, country: 'BRAZIL' }Find by e-mail
SimpleHubspot::Contact.find_by_email "email@email.com"Update Contact
SimpleHubspot::Contact.update 1234, { email: "email@email.com" }Submit a Form
payload = { email: 'test@example.com',
property_one: 'value 1',
property_two: 'value 2',
hs_context: { hutk: '60c2ccdfe4892f0fa0593940b12c11aa',
ipAddress: '127.0.0.10',
pageUrl: 'http://demo.hubapi.com/contact/',
pageName: 'Contact Us' } }
SimpleHubspot::Form.submit_form 'FORM_GUID', payloadDevelopment
After checking out the repo, run bin/setup to install dependencies. Then, 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 to create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.
Contributing
- Fork it ( https://github.com/[my-github-username]/simple_hubspot/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request