easy_hubspot 0.1.6 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15bcc6ca4b7e8b160927aad5170f22efd765358612e65c91b21d80071d5c6d6d
4
- data.tar.gz: 9be1296e8f614c6ef77bfe25d14aad9ffaaa714ccf18f4cb549ed49ecf467737
3
+ metadata.gz: 8afd7c12ba165b752df83f2a711ad3220f0efb7f9fef8a73340ae9dd9c95adeb
4
+ data.tar.gz: dcd135320a2274849e576f7b2c5497a74323c1713b330f275c6c4f6dfa3cedef
5
5
  SHA512:
6
- metadata.gz: cc9087d34a7f1d10728fe8eb3c5aeca654655cda1a8cc938eb804c21c40f0fa3b8073988cb2776bc538d3d4ce86dfea49e594198ea602487aeefaaa5a453e183
7
- data.tar.gz: 9274936c9c512e5627702a5aaa63e7253c3ce6e1c72ec858d722a3376d412c3abbcf96c916437322c0f779e0c0d717ff169098663db396c34c3bd390feed237f
6
+ metadata.gz: 4b5da8b90ae02f92056d2af35dea0cbbe8207e84d486345dd89fd7d155b75a13680b735788f2e4b64ba3c9acc617830c8fe29feb3a5b3156c5ceb3cab3b2f724
7
+ data.tar.gz: c90fb31a0954a82c9bdfbf7c3b0c5df4fde0e4f5c40da12fa09f32afad0f8ca5c7679ae561ca52196b016bebf06bcdeb93edb6d14c57ed354b99b2faf5a75f95
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
- ## [Unreleased]
1
+ ## [Official Release]
2
+ - [0.1.7] - 2023-02-10
2
3
 
3
- ## [0.1.0] - 2023-02-08
4
+ ## [Unreleased]
4
5
 
5
- - Initial release
6
+ ## [Initial releases]
7
+ - [0.1.0] - 2023-02-08
8
+ - [0.1.1] - 2023-02-09
9
+ - [0.1.2] - 2023-02-09
10
+ - [0.1.3] - 2023-02-09
11
+ - [0.1.4] - 2023-02-09
12
+ - [0.1.5] - 2023-02-09
13
+ - [0.1.6] - 2023-02-09
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ gemspec
7
7
 
8
8
  group :development, :test do
9
9
  gem 'bundler', '~> 2.2'
10
- gem 'pry', '~> 0.13.1'
10
+ gem 'pry', '~> 0.14.2'
11
11
  gem 'rake', '~> 13.0'
12
12
  gem 'rspec', '~> 3.0'
13
13
  gem 'rubocop', '~> 1.21'
data/README.md CHANGED
@@ -1,24 +1,61 @@
1
1
  # EasyHubspot
2
+ ![version](https://img.shields.io/badge/version-0.1.7-green)
3
+ [![CI](https://github.com/oroth8/easy_hubspot/actions/workflows/ci.yml/badge.svg)](https://github.com/oroth8/easy_hubspot/actions/workflows/ci.yml)
4
+ [![Code Climate](https://codeclimate.com/github/oroth8/easy_hubspot/badges/gpa.svg)](https://codeclimate.com/github/oroth8/easy_hubspot)
2
5
 
3
- TODO: Delete this and the text below, and describe your gem
6
+ 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.
4
7
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/easy_hubspot`. To experiment with that code, run `bin/console` for an interactive prompt.
8
+ This gem utilizes the `v3` hubspot-api
6
9
 
7
10
  ## Installation
8
11
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
12
+ Add this line to your application's Gemfile:
10
13
 
11
- Install the gem and add to the application's Gemfile by executing:
14
+ ```ruby
15
+ gem 'easy_hubspot'
16
+ ```
12
17
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
18
+ ## Usage
14
19
 
15
- If bundler is not being used to manage dependencies, install the gem by executing:
20
+ Add the following to your `config/initializers/easy_hubspot.rb` file:
16
21
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
22
+ ```ruby
23
+ EasyHubspot.config do |c|
24
+ c.access_token = 'YOUR API KEY'
25
+ c.base_url = 'https://api.hubapi.com/'
26
+ end
27
+ ```
18
28
 
19
- ## Usage
29
+ Or run the generator:
30
+
31
+ ```bash
32
+ rails g easy_hubspot:install
33
+ ```
34
+
35
+ ### Contacts
36
+
37
+ Please refrence the [hubspot docs](https://developers.hubspot.com/docs/api/crm/contacts)
38
+
39
+ ```ruby
40
+ # Create a contact
41
+ EasyHubspot::Contact.create_contact(properties: { email: '', firstname: '', lastname: '' , etc: ''})
42
+
43
+ # Update a contact
44
+ EasyHubspot::Contact.update_contact(123, properties: { email: '', firstname: '', lastname: '' , etc: ''})
45
+
46
+ # Get a contact
47
+ EasyHubspot::Contact.get_contact(123)
48
+ # or
49
+ EasyHubspot::Contact.get_contact('test@gmail.com')
50
+
51
+ # Get all contacts
52
+ EasyHubspot::Contact.get_contacts
20
53
 
21
- TODO: Write usage instructions here
54
+ # Delete a contact
55
+ EasyHubspot::Contact.delete_contact(123)
56
+ # or
57
+ EasyHubspot::Contact.delete_contact('test@gmail.com')
58
+ ```
22
59
 
23
60
  ## Development
24
61
 
@@ -28,7 +65,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
28
65
 
29
66
  ## Contributing
30
67
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/easy_hubspot.
68
+ Bug reports and pull requests are welcome on GitHub at https://github.com/oroth8/easy_hubspot.
32
69
 
33
70
  ## License
34
71
 
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ EasyHubspot.config do |c|
4
+ c.access_token = 'YOUR API KEY'
5
+ c.base_url = 'https://api.hubapi.com/'
6
+ end
data/easy_hubspot.gemspec CHANGED
@@ -36,11 +36,11 @@ Gem::Specification.new do |spec|
36
36
 
37
37
  # development dependencies
38
38
  spec.add_development_dependency 'bundler', '~> 2.0'
39
- spec.add_development_dependency 'capybara', '~> 2.7'
39
+ spec.add_development_dependency 'capybara', '~> 3.36'
40
40
  spec.add_development_dependency 'generator_spec', '~> 0.9.4'
41
- spec.add_development_dependency 'pry', '~> 0.13.1'
41
+ spec.add_development_dependency 'pry', '~> 0.14.2'
42
42
  spec.add_development_dependency 'rake', '~> 13.0'
43
- spec.add_development_dependency 'rspec', '~> 3.4.0'
43
+ spec.add_development_dependency 'rspec', '~> 3.12.0'
44
44
  spec.add_development_dependency 'rubocop', '~> 1.2'
45
45
  spec.add_development_dependency 'rubocop-rake', '~> 0.6.0'
46
46
  spec.add_development_dependency 'rubocop-rspec', '~> 2.18.1'
@@ -4,44 +4,28 @@ module EasyHubspot
4
4
  # EasyHubspot::Client
5
5
  class Client
6
6
  class << self
7
- def do_get(path = nil, headers = {}, format_plain: true)
8
- if format_plain
9
- response = HTTParty.get("#{EasyHubspot.configuration.base_url}#{path}", headers: headers,
10
- format: :plain)
11
- parse_response(response)
12
- else
13
- HTTParty.get("#{EasyHubspot.configuration.base_url}#{path}", headers: headers)
14
- end
7
+ def do_get(path = nil, headers = {})
8
+ response = HTTParty.get("#{EasyHubspot.configuration.base_url}#{path}", headers: headers,
9
+ format: :plain)
10
+ parse_response(response)
15
11
  end
16
12
 
17
- def do_post(path = nil, body = {}, headers = {}, format_plain: true)
18
- if format_plain
19
- response = HTTParty.post("#{EasyHubspot.configuration.base_url}#{path}", body: body, headers: headers,
20
- format: :plain)
21
- parse_response(response)
22
- else
23
- HTTParty.post("#{EasyHubspot.configuration.base_url}#{path}", body: body, headers: headers)
24
- end
13
+ def do_post(path = nil, body = {}, headers = {})
14
+ response = HTTParty.post("#{EasyHubspot.configuration.base_url}#{path}", body: body, headers: headers,
15
+ format: :plain)
16
+ parse_response(response)
25
17
  end
26
18
 
27
- def do_patch(path = nil, body = {}, headers = {}, format_plain: true)
28
- if format_plain
29
- response = HTTParty.patch("#{EasyHubspot.configuration.base_url}#{path}", body: body, headers: headers,
30
- format: :plain)
31
- parse_response(response)
32
- else
33
- HTTParty.patch("#{EasyHubspot.configuration.base_url}#{path}", body: body, headers: headers)
34
- end
19
+ def do_patch(path = nil, body = {}, headers = {})
20
+ response = HTTParty.patch("#{EasyHubspot.configuration.base_url}#{path}", body: body, headers: headers,
21
+ format: :plain)
22
+ parse_response(response)
35
23
  end
36
24
 
37
- def do_delete(path = nil, headers = {}, format_plain: true)
38
- if format_plain
39
- response = HTTParty.delete("#{EasyHubspot.configuration.base_url}#{path}", headers: headers,
40
- format: :plain)
41
- parse_response(response)
42
- else
43
- HTTParty.delete("#{EasyHubspot.configuration.base_url}#{path}", headers: headers)
44
- end
25
+ def do_delete(path = nil, headers = {})
26
+ response = HTTParty.delete("#{EasyHubspot.configuration.base_url}#{path}", headers: headers,
27
+ format: :plain)
28
+ parse_response(response)
45
29
  end
46
30
 
47
31
  private
@@ -49,7 +33,10 @@ module EasyHubspot
49
33
  def parse_response(res)
50
34
  return if res.body.nil?
51
35
 
52
- JSON.parse res, symbolize_names: true
36
+ parsed_res = JSON.parse res, symbolize_names: true
37
+ raise EasyHubspot::HubspotApiError, parsed_res[:message] if parsed_res[:status] == 'error'
38
+
39
+ parsed_res
53
40
  end
54
41
  end
55
42
  end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EasyHubspot
4
+ class Error < StandardError; end
5
+ class HubspotApiError < Error; end
6
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators'
4
+
5
+ module EasyHubspot
6
+ module Generators
7
+ # InstallGenerator
8
+ class InstallGenerator < Rails::Generators::Base
9
+ source_root File.expand_path('templates', __dir__)
10
+ desc 'This generator creates an initializer file at config/initializers'
11
+ def copy_initializer
12
+ copy_file 'easy_hubspot.rb', 'config/initializers/easy_hubspot.rb'
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ EasyHubspot.config do |c|
4
+ c.access_token = 'YOUR API KEY'
5
+ c.base_url = 'https://api.hubapi.com/'
6
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EasyHubspot
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.8'
5
5
  end
data/lib/easy_hubspot.rb CHANGED
@@ -5,6 +5,7 @@ require 'easy_hubspot/client'
5
5
  require 'easy_hubspot/contact'
6
6
  require 'easy_hubspot/version'
7
7
  require 'easy_hubspot/generators/install_generator'
8
+ require 'easy_hubspot/exceptions'
8
9
 
9
10
  require 'httparty'
10
11
  require 'json'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_hubspot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Owen Roth
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.7'
47
+ version: '3.36'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.7'
54
+ version: '3.36'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: generator_spec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.13.1
75
+ version: 0.14.2
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.13.1
82
+ version: 0.14.2
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 3.4.0
103
+ version: 3.12.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 3.4.0
110
+ version: 3.12.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rubocop
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -178,11 +178,15 @@ files:
178
178
  - LICENSE.txt
179
179
  - README.md
180
180
  - Rakefile
181
+ - config/initializers/easy_hubspot.rb
181
182
  - easy_hubspot.gemspec
182
183
  - lib/easy_hubspot.rb
183
184
  - lib/easy_hubspot/base.rb
184
185
  - lib/easy_hubspot/client.rb
185
186
  - lib/easy_hubspot/contact.rb
187
+ - lib/easy_hubspot/exceptions.rb
188
+ - lib/easy_hubspot/generators/install_generator.rb
189
+ - lib/easy_hubspot/generators/templates/easy_hubspot.rb
186
190
  - lib/easy_hubspot/version.rb
187
191
  - sig/easy_hubspot.rbs
188
192
  homepage: https://github.com/oroth8/easy-hubspot