SimpleHubspot

Gem Version Build Status Code Climate

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:install

Without Rails

SimpleHubspot.configure do |config|
  config.hapikey= "YOUR API KEY"
end

Create Or Update Contact

SimpleHubspot::Contact.create_or_update "[email protected]", { name: "John", age: 14, country: 'BRAZIL' }

Find by e-mail

SimpleHubspot::Contact.find_by_email "[email protected]"

Update Contact

SimpleHubspot::Contact.update 1234,  { email: "[email protected]" }

Submit a Form

payload = { email: '[email protected]',
            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', payload

Development

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

  1. Fork it ( https://github.com/[my-github-username]/simple_hubspot/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request