EasyHubspot
Stable:
Latest:

This is a lightweight wrapper for the Hubspot API. It is designed to be easy to use and to provide a simple setup for the most common use cases.
This gem utilizes the v3
hubspot-api
CRM Objects
Dependencies
Compatibility
ruby >= 2.6.10
rails >= 6.0
Installation
Add this line to your application's Gemfile:
gem 'easy_hubspot'
Usage
Add the following to your config/initializers/easy_hubspot.rb
file:
EasyHubspot.config do |c|
c.access_token = 'YOUR API KEY'
c.base_url = 'https://api.hubapi.com/'
end
Or run the generator:
rails g easy_hubspot:install
Contacts
Please refrence the hubspot docs
EasyHubspot::Contact.create_contact(properties: { email: '', firstname: '', lastname: '' , etc: ''})
EasyHubspot::Contact.update_contact(123, properties: { email: '', firstname: '', lastname: '' , etc: ''})
EasyHubspot::Contact.get_contact(123)
EasyHubspot::Contact.get_contact('test@gmail.com')
EasyHubspot::Contact.get_contacts
EasyHubspot::Contact.delete_contact(123)
EasyHubspot::Contact.delete_contact('test@gmail.com')
EasyHubspot::Contact.update_or_create_contact(properties: { email: '', firstname: '', lastname: '' , etc: ''})
{:id=>"701",
:properties=>
{:createdate=>"2023-02-08T20:10:36.858Z",
:email=>"amber_becker@quigley.io",
:firstname=>"Amber",
:hs_content_membership_status=>"inactive",
:hs_is_contact=>"true",
:hs_is_unworked=>"true",
:hs_object_id=>"701",
:hs_pipeline=>"contacts-lifecycle-pipeline",
:lastmodifieddate=>"2023-02-14T18:24:07.654Z",
:lastname=>"Quigley",
:lifecyclestage=>"lead"},
:createdAt=>"2023-02-08T20:10:36.858Z",
:updatedAt=>"2023-02-14T18:24:07.654Z",
:archived=>false}
Deals
EasyHubspot::Deal.create_deal(properties: { dealname: '', amount: '', etc: ''})
EasyHubspot::Deal.update_deal(123, properties: { dealname: '', amount: '', etc: ''})
EasyHubspot::Deal.get_deal(123)
EasyHubspot::Deal.get_deals
EasyHubspot::Deal.delete_deal(123)
Products
Please refrence the hubspot docs
EasyHubspot::Product.create_product(properties: { name: '', price: '', etc: ''})
EasyHubspot::Product.update_product(123, properties: { name: '', price: '', etc: ''})
EasyHubspot::Product.get_product(123)
EasyHubspot::Product.get_products
EasyHubspot::Product.delete_product(123)
Line Items
Please refrence the hubspot docs
EasyHubspot::LineItem.create_line_item(properties: { quantity: '', hs_product_id: '', etc: ''})
EasyHubspot::LineItem.update_line_item(123, properties: { quantity: '', etc: ''})
EasyHubspot::LineItem.get_line_item(123)
EasyHubspot::LineItem.get_line_items
EasyHubspot::LineItem.delete_line_item(123)
Error Handling
def call
begin
EasyHubspot::Contact.create_contact(body)
rescue EasyHubspot::HubspotApiError => e
Rails.logger.info(e.message)
end
end
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 the created tag, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/oroth8/easy_hubspot.
License
The gem is available as open source under the terms of the MIT License.