easy_hubspot 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bef656e656d43c62805e65e2b97270ae0ccfdadb3ab8bd596c4af603826180c8
4
+ data.tar.gz: 0ee5e504c9241d8734ad6a137c9c5d801badcebd40d897dcc313e9a7a16504cf
5
+ SHA512:
6
+ metadata.gz: a8b01fb617431a4ec0d757e03f5a827e0516d7683622c416ec540f8c5c4e5ea35f7840f37c04fde5774706399ee7973ef143e9804b26b70824d61b0c10bf634a
7
+ data.tar.gz: ba9050128e709bd9dbd202f890899de1f70ea18da5363049f20bfd0f89720d446b22d710d82f0ad450ff9815e646d7bc8f1b0c6cf8dbd2375cc16ef3b7de5f8c
data/.DS_Store ADDED
Binary file
data/.rspec_status ADDED
@@ -0,0 +1,12 @@
1
+ example_id | status | run_time |
2
+ -------------------------------------------- | ------ | --------------- |
3
+ ./spec/easy_hubspot/contact_spec.rb[1:1:1:1] | passed | 0.01469 seconds |
4
+ ./spec/easy_hubspot/contact_spec.rb[1:1:2:1] | passed | 0.00086 seconds |
5
+ ./spec/easy_hubspot/contact_spec.rb[1:2:1:1] | passed | 0.0008 seconds |
6
+ ./spec/easy_hubspot/contact_spec.rb[1:3:1] | passed | 0.00059 seconds |
7
+ ./spec/easy_hubspot/contact_spec.rb[1:4:1:1] | passed | 0.0008 seconds |
8
+ ./spec/easy_hubspot/contact_spec.rb[1:4:2:1] | passed | 0.00078 seconds |
9
+ ./spec/easy_hubspot/contact_spec.rb[1:5:1:1] | passed | 0.00034 seconds |
10
+ ./spec/easy_hubspot/contact_spec.rb[1:5:2:1] | passed | 0.00038 seconds |
11
+ ./spec/easy_hubspot_spec.rb[1:1:1] | passed | 0.00008 seconds |
12
+ ./spec/easy_hubspot_spec.rb[1:1:2] | passed | 0.00004 seconds |
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-02-08
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in easy_hubspot.gemspec
6
+ gemspec
7
+
8
+ group :development, :test do
9
+ gem "bundler", "~> 2.2"
10
+ gem "rake", "~> 13.0"
11
+ gem "rspec", "~> 3.0"
12
+ gem "rubocop", "~> 1.21"
13
+ gem 'pry', '~> 0.13.1'
14
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,103 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ easy_hubspot (0.1.0)
5
+ httparty (~> 0.17.3)
6
+ json (~> 2.6.0)
7
+ uri (~> 0.12.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ addressable (2.8.1)
13
+ public_suffix (>= 2.0.2, < 6.0)
14
+ ast (2.4.2)
15
+ capybara (2.18.0)
16
+ addressable
17
+ mini_mime (>= 0.1.3)
18
+ nokogiri (>= 1.3.3)
19
+ rack (>= 1.0.0)
20
+ rack-test (>= 0.5.4)
21
+ xpath (>= 2.0, < 4.0)
22
+ coderay (1.1.3)
23
+ crack (0.4.5)
24
+ rexml
25
+ diff-lcs (1.5.0)
26
+ hashdiff (1.0.1)
27
+ httparty (0.17.3)
28
+ mime-types (~> 3.0)
29
+ multi_xml (>= 0.5.2)
30
+ json (2.6.3)
31
+ method_source (1.0.0)
32
+ mime-types (3.4.1)
33
+ mime-types-data (~> 3.2015)
34
+ mime-types-data (3.2022.0105)
35
+ mini_mime (1.1.2)
36
+ multi_xml (0.6.0)
37
+ nokogiri (1.14.1-arm64-darwin)
38
+ racc (~> 1.4)
39
+ parallel (1.22.1)
40
+ parser (3.2.0.0)
41
+ ast (~> 2.4.1)
42
+ pry (0.13.1)
43
+ coderay (~> 1.1)
44
+ method_source (~> 1.0)
45
+ public_suffix (5.0.1)
46
+ racc (1.6.2)
47
+ rack (3.0.4.1)
48
+ rack-test (2.0.2)
49
+ rack (>= 1.3)
50
+ rainbow (3.1.1)
51
+ rake (13.0.6)
52
+ regexp_parser (2.7.0)
53
+ rexml (3.2.5)
54
+ rspec (3.12.0)
55
+ rspec-core (~> 3.12.0)
56
+ rspec-expectations (~> 3.12.0)
57
+ rspec-mocks (~> 3.12.0)
58
+ rspec-core (3.12.1)
59
+ rspec-support (~> 3.12.0)
60
+ rspec-expectations (3.12.2)
61
+ diff-lcs (>= 1.2.0, < 2.0)
62
+ rspec-support (~> 3.12.0)
63
+ rspec-mocks (3.12.3)
64
+ diff-lcs (>= 1.2.0, < 2.0)
65
+ rspec-support (~> 3.12.0)
66
+ rspec-support (3.12.0)
67
+ rubocop (1.45.1)
68
+ json (~> 2.3)
69
+ parallel (~> 1.10)
70
+ parser (>= 3.2.0.0)
71
+ rainbow (>= 2.2.2, < 4.0)
72
+ regexp_parser (>= 1.8, < 3.0)
73
+ rexml (>= 3.2.5, < 4.0)
74
+ rubocop-ast (>= 1.24.1, < 2.0)
75
+ ruby-progressbar (~> 1.7)
76
+ unicode-display_width (>= 2.4.0, < 3.0)
77
+ rubocop-ast (1.24.1)
78
+ parser (>= 3.1.1.0)
79
+ ruby-progressbar (1.11.0)
80
+ unicode-display_width (2.4.2)
81
+ uri (0.12.0)
82
+ webmock (3.18.1)
83
+ addressable (>= 2.8.0)
84
+ crack (>= 0.3.2)
85
+ hashdiff (>= 0.4.0, < 2.0.0)
86
+ xpath (3.2.0)
87
+ nokogiri (~> 1.8)
88
+
89
+ PLATFORMS
90
+ arm64-darwin-21
91
+
92
+ DEPENDENCIES
93
+ bundler (~> 2.2)
94
+ capybara (~> 2.7)
95
+ easy_hubspot!
96
+ pry (~> 0.13.1)
97
+ rake (~> 13.0)
98
+ rspec (~> 3.0)
99
+ rubocop (~> 1.21)
100
+ webmock (~> 3.14)
101
+
102
+ BUNDLED WITH
103
+ 2.4.5
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Owen Roth
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # EasyHubspot
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
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.
6
+
7
+ ## Installation
8
+
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.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Development
24
+
25
+ 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.
26
+
27
+ 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](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/easy_hubspot.
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,19 @@
1
+ module EasyHubspot
2
+ # class EasyHubspot::Base
3
+ class Base
4
+ class << self
5
+ def headers
6
+ { "Content-Type": 'application/json',
7
+ "Authorization": "Bearer #{EasyHubspot.configuration.access_token}" }
8
+ end
9
+
10
+ def email?(string)
11
+ URI::MailTo::EMAIL_REGEXP.match?(string)
12
+ end
13
+
14
+ def merge_path(path)
15
+ EasyHubspot.configuration.base_url + path
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,53 @@
1
+ module EasyHubspot
2
+ class Client
3
+ class << self
4
+ def do_get(path = nil, headers = {}, format_plain: true)
5
+ if format_plain
6
+ response = HTTParty.get("#{EasyHubspot.configuration.base_url}#{path}", headers:,
7
+ format: :plain)
8
+ parse_response(response)
9
+ else
10
+ HTTParty.get("#{EasyHubspot.configuration.base_url}#{path}", headers:)
11
+ end
12
+ end
13
+
14
+ def do_post(path = nil, body = {}, headers = {}, format_plain: true)
15
+ if format_plain
16
+ response = HTTParty.post("#{EasyHubspot.configuration.base_url}#{path}", body:, headers:,
17
+ format: :plain)
18
+ parse_response(response)
19
+ else
20
+ HTTParty.post("#{EasyHubspot.configuration.base_url}#{path}", body:, headers:)
21
+ end
22
+ end
23
+
24
+ def do_patch(path = nil, body = {}, headers = {}, format_plain: true)
25
+ if format_plain
26
+ response = HTTParty.patch("#{EasyHubspot.configuration.base_url}#{path}", body:, headers:,
27
+ format: :plain)
28
+ parse_response(response)
29
+ else
30
+ HTTParty.patch("#{EasyHubspot.configuration.base_url}#{path}", body:, headers:)
31
+ end
32
+ end
33
+
34
+ def do_delete(path = nil, headers = {}, format_plain: true)
35
+ if format_plain
36
+ response = HTTParty.delete("#{EasyHubspot.configuration.base_url}#{path}", headers:,
37
+ format: :plain)
38
+ parse_response(response)
39
+ else
40
+ HTTParty.delete("#{EasyHubspot.configuration.base_url}#{path}", headers:)
41
+ end
42
+ end
43
+
44
+ private
45
+
46
+ def parse_response(res)
47
+ return if res.body.nil?
48
+
49
+ JSON.parse res, symbolize_names: true
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,49 @@
1
+ module EasyHubspot
2
+ # class EasyHubspot::Contact
3
+ class Contact < EasyHubspot::Base
4
+ class << self
5
+ CONTACT_ENDPOINT = 'crm/v3/objects/contacts'.freeze
6
+
7
+ def get_contact(contact_id)
8
+ path = merge_path(determine_endpoint(contact_id))
9
+ Client.do_get(path, headers)
10
+ end
11
+
12
+ def get_contacts
13
+ Client.do_get(contact_path, headers)
14
+ end
15
+
16
+ def create_contact(body)
17
+ Client.do_post(contact_path, body, headers)
18
+ end
19
+
20
+ def update_contact(contact_id, body)
21
+ path = merge_path(determine_endpoint(contact_id))
22
+ Client.do_patch(path, body, headers)
23
+ end
24
+
25
+ def delete_contact(contact_id)
26
+ path = merge_path(determine_endpoint(contact_id))
27
+ Client.do_delete(path, headers)
28
+ end
29
+
30
+ def get_associated_contacts(contact_id, object_type, object_id, association_id)
31
+ # TODO: Error handling arguments
32
+ path = merge_path("#{CONTACT_ENDPOINT}/#{contact_id}/associations/#{object_type}/#{object_id}/#{association_id}")
33
+ Client.do_get(path, headers)
34
+ end
35
+
36
+ private
37
+
38
+ def contact_path
39
+ merge_path(CONTACT_ENDPOINT)
40
+ end
41
+
42
+ def determine_endpoint(value)
43
+ email_endpoint = "#{CONTACT_ENDPOINT}/#{value}?idProperty=email"
44
+ id_endpoint = "#{CONTACT_ENDPOINT}/#{value}"
45
+ email?(value.to_s) ? email_endpoint : id_endpoint
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EasyHubspot
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'easy_hubspot/base'
4
+ require 'easy_hubspot/client'
5
+ require 'easy_hubspot/contact'
6
+ require 'easy_hubspot/version'
7
+
8
+ require 'httparty'
9
+ require 'json'
10
+ require 'uri'
11
+
12
+ module EasyHubspot
13
+ class << self
14
+ attr_accessor :configuration
15
+ end
16
+
17
+ def self.config
18
+ self.configuration ||= Configuration.new
19
+ yield(configuration)
20
+ end
21
+
22
+ class Configuration
23
+ attr_accessor :access_token, :base_url
24
+
25
+ def initialize
26
+ @access_token = ''
27
+ @base_url = 'https://api.hubapi.com'
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,4 @@
1
+ module EasyHubspot
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,198 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: easy_hubspot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Owen Roth
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-02-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.6.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.6.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: uri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.12.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.12.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: httparty
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.17.3
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.17.3
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.13.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.13.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '13.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '13.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 3.4.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 3.4.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.2'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.2'
125
+ - !ruby/object:Gem::Dependency
126
+ name: webmock
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '3.14'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '3.14'
139
+ - !ruby/object:Gem::Dependency
140
+ name: capybara
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '2.7'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '2.7'
153
+ description: This gem is designed to make it easier to integrate with the Hubspot
154
+ API
155
+ email:
156
+ - rothowen27@gmail.com
157
+ executables: []
158
+ extensions: []
159
+ extra_rdoc_files: []
160
+ files:
161
+ - ".DS_Store"
162
+ - ".rspec_status"
163
+ - CHANGELOG.md
164
+ - Gemfile
165
+ - Gemfile.lock
166
+ - LICENSE.txt
167
+ - README.md
168
+ - Rakefile
169
+ - lib/easy_hubspot.rb
170
+ - lib/easy_hubspot/base.rb
171
+ - lib/easy_hubspot/client.rb
172
+ - lib/easy_hubspot/contact.rb
173
+ - lib/easy_hubspot/version.rb
174
+ - sig/easy_hubspot.rbs
175
+ homepage: https://github.com/oroth8/easy-hubspot
176
+ licenses:
177
+ - MIT
178
+ metadata: {}
179
+ post_install_message:
180
+ rdoc_options: []
181
+ require_paths:
182
+ - lib
183
+ required_ruby_version: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: 2.6.0
188
+ required_rubygems_version: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ requirements: []
194
+ rubygems_version: 3.3.26
195
+ signing_key:
196
+ specification_version: 4
197
+ summary: An easier way to integrate with the Hubspot API
198
+ test_files: []