hubspot_client 0.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/rspec_and_rubocop.yml +41 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +88 -0
- data/README.md +86 -0
- data/bin/console +16 -0
- data/hubspot_client.gemspec +44 -0
- data/lib/hubspot_client/client/company.rb +52 -0
- data/lib/hubspot_client/client/contact.rb +69 -0
- data/lib/hubspot_client/client/properties.rb +24 -0
- data/lib/hubspot_client/configuration.rb +7 -0
- data/lib/hubspot_client/model/company.rb +42 -0
- data/lib/hubspot_client/model/contact.rb +52 -0
- data/lib/hubspot_client/version.rb +5 -0
- data/lib/hubspot_client.rb +28 -0
- metadata +194 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 12f80ed6afbfbb4fc8561616156762128e77defcca1c53bc4f07b93affaebd18
|
4
|
+
data.tar.gz: eaf249fb97115e5178e4785e3824574973817b78e9cc2713af81b46e4f3833af
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b2f43fe74c400cc82d075ff771392431a55294418195a8514018d9b09a4dce169a0986d829967a0c7653b197ed744afff4267d013702bad2371b40f32bd4a59f
|
7
|
+
data.tar.gz: edd7430e6c3cb224a56fbea5e4e59042c3bb752ac6c3616fbe5763f24f94fbf2cbd8e6cfb82015b49b03fa283c875582ba3f4beb12986125f9f9b8ba31ee8eeb
|
@@ -0,0 +1,41 @@
|
|
1
|
+
name: Rspec and Rubocop
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches-ignore:
|
6
|
+
- 'main'
|
7
|
+
jobs:
|
8
|
+
rspec:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
matrix:
|
12
|
+
ruby: ['3.0', '3.1']
|
13
|
+
name: "ruby ${{ matrix.ruby }}"
|
14
|
+
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v3
|
17
|
+
- uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: ${{ matrix.ruby }}
|
20
|
+
- name: Bundle install
|
21
|
+
run: |
|
22
|
+
gem install bundler
|
23
|
+
bundle install
|
24
|
+
- name: Run RSpec
|
25
|
+
run: |
|
26
|
+
bundle exec rspec
|
27
|
+
|
28
|
+
rubocop:
|
29
|
+
runs-on: ubuntu-latest
|
30
|
+
steps:
|
31
|
+
- uses: actions/checkout@v3
|
32
|
+
- uses: ruby/setup-ruby@v1
|
33
|
+
with:
|
34
|
+
ruby-version: 3.1
|
35
|
+
- name: Bundle install
|
36
|
+
run: |
|
37
|
+
gem install bundler
|
38
|
+
bundle install
|
39
|
+
- name: Run rubocop
|
40
|
+
run: |
|
41
|
+
bundle exec rubocop
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
hubspot_client (0.1.0.beta1)
|
5
|
+
httparty (~> 0.20.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.8.1)
|
11
|
+
public_suffix (>= 2.0.2, < 6.0)
|
12
|
+
ast (2.4.2)
|
13
|
+
coderay (1.1.3)
|
14
|
+
crack (0.4.5)
|
15
|
+
rexml
|
16
|
+
diff-lcs (1.5.0)
|
17
|
+
dotenv (2.8.1)
|
18
|
+
hashdiff (1.0.1)
|
19
|
+
httparty (0.20.0)
|
20
|
+
mime-types (~> 3.0)
|
21
|
+
multi_xml (>= 0.5.2)
|
22
|
+
json (2.6.2)
|
23
|
+
method_source (1.0.0)
|
24
|
+
mime-types (3.4.1)
|
25
|
+
mime-types-data (~> 3.2015)
|
26
|
+
mime-types-data (3.2022.0105)
|
27
|
+
multi_xml (0.6.0)
|
28
|
+
parallel (1.22.1)
|
29
|
+
parser (3.1.2.1)
|
30
|
+
ast (~> 2.4.1)
|
31
|
+
pry (0.14.1)
|
32
|
+
coderay (~> 1.1)
|
33
|
+
method_source (~> 1.0)
|
34
|
+
public_suffix (5.0.0)
|
35
|
+
rainbow (3.1.1)
|
36
|
+
regexp_parser (2.6.1)
|
37
|
+
rexml (3.2.5)
|
38
|
+
rspec (3.12.0)
|
39
|
+
rspec-core (~> 3.12.0)
|
40
|
+
rspec-expectations (~> 3.12.0)
|
41
|
+
rspec-mocks (~> 3.12.0)
|
42
|
+
rspec-core (3.12.0)
|
43
|
+
rspec-support (~> 3.12.0)
|
44
|
+
rspec-expectations (3.12.0)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.12.0)
|
47
|
+
rspec-mocks (3.12.0)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.12.0)
|
50
|
+
rspec-support (3.12.0)
|
51
|
+
rubocop (1.39.0)
|
52
|
+
json (~> 2.3)
|
53
|
+
parallel (~> 1.10)
|
54
|
+
parser (>= 3.1.2.1)
|
55
|
+
rainbow (>= 2.2.2, < 4.0)
|
56
|
+
regexp_parser (>= 1.8, < 3.0)
|
57
|
+
rexml (>= 3.2.5, < 4.0)
|
58
|
+
rubocop-ast (>= 1.23.0, < 2.0)
|
59
|
+
ruby-progressbar (~> 1.7)
|
60
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
61
|
+
rubocop-ast (1.23.0)
|
62
|
+
parser (>= 3.1.1.0)
|
63
|
+
rubocop-rspec (2.15.0)
|
64
|
+
rubocop (~> 1.33)
|
65
|
+
ruby-progressbar (1.11.0)
|
66
|
+
unicode-display_width (2.3.0)
|
67
|
+
vcr (6.1.0)
|
68
|
+
webmock (3.18.1)
|
69
|
+
addressable (>= 2.8.0)
|
70
|
+
crack (>= 0.3.2)
|
71
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
72
|
+
|
73
|
+
PLATFORMS
|
74
|
+
arm64-darwin-21
|
75
|
+
|
76
|
+
DEPENDENCIES
|
77
|
+
bundler (~> 2.3.26)
|
78
|
+
dotenv (~> 2.8, >= 2.8.1)
|
79
|
+
hubspot_client!
|
80
|
+
pry (~> 0.14)
|
81
|
+
rspec (~> 3.12)
|
82
|
+
rubocop (~> 1.39)
|
83
|
+
rubocop-rspec (~> 2.15)
|
84
|
+
vcr (~> 6.1)
|
85
|
+
webmock (~> 3.18)
|
86
|
+
|
87
|
+
BUNDLED WITH
|
88
|
+
2.3.26
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
|
2
|
+
# HubspotClient
|
3
|
+
|
4
|
+
An simple Hubspot Client. We only like to support the CRm features for the moment. Maybe we do more.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'hubspot_client'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install hubspot_client
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
You need to configure the `graphql_connector` first:
|
25
|
+
``` ruby
|
26
|
+
HubspotClient.configure do |config|
|
27
|
+
config.access_token = 'PRIVATE_APP_ACCESS_TOKEN'
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
## Models
|
32
|
+
|
33
|
+
The idea is that the models behave like an ActiveRecord Model.
|
34
|
+
|
35
|
+
### Contact - HubspotClient::Model::Contact
|
36
|
+
|
37
|
+
[Hubspot- API](https://developers.hubspot.com/docs/api/crm/contacts)
|
38
|
+
|
39
|
+
#### find
|
40
|
+
You can find by `hubspot_id` or `email`
|
41
|
+
```ruby
|
42
|
+
HubspotClient::Model::Contact.find(hubspot_id: '1337')
|
43
|
+
=> #<HubspotClient::Model::Contact createdate="2022-11-11T11:57:15.901Z", email="vader@example.com", firstname="Darth", hs_object_id="1337", lastmodifieddate="2022-11-17T13:31:00.526Z", lastname="Vader">
|
44
|
+
|
45
|
+
HubspotClient::Model::Contact.find(email: 'vader@example.com')
|
46
|
+
=> #<HubspotClient::Model::Contact createdate="2022-11-11T11:57:15.901Z", email="vader@example.com", firstname="Darth", hs_object_id="1337", lastmodifieddate="2022-11-17T13:31:00.526Z", lastname="Vader">
|
47
|
+
```
|
48
|
+
|
49
|
+
### Company
|
50
|
+
|
51
|
+
[Hubspot- API](https://developers.hubspot.com/docs/api/crm/companies)
|
52
|
+
|
53
|
+
### Subscription-Preferences
|
54
|
+
|
55
|
+
[Hubspot- API](https://developers.hubspot.com/docs/api/marketing-api/subscriptions-preferences)
|
56
|
+
|
57
|
+
## Development
|
58
|
+
|
59
|
+
After checking out the repo, run
|
60
|
+
```shell
|
61
|
+
bundle install
|
62
|
+
```
|
63
|
+
|
64
|
+
Then, run
|
65
|
+
```shell
|
66
|
+
bundle exec rspec spec
|
67
|
+
```
|
68
|
+
to run the tests.
|
69
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
70
|
+
|
71
|
+
You need a `.env` file looks like, if you want to test it against your hubspot instance:
|
72
|
+
```shell
|
73
|
+
ACCESS_TOKEN=<youur_private_app_access_token>
|
74
|
+
```
|
75
|
+
|
76
|
+
## Contributing
|
77
|
+
|
78
|
+
Bug reports and pull requests are welcome on GitHub at [https://github.com/farbfox/hubspot_client](https://github.com/farbfox/hubspot_client). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
79
|
+
|
80
|
+
## License
|
81
|
+
|
82
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
83
|
+
|
84
|
+
## Code of Conduct
|
85
|
+
|
86
|
+
Everyone interacting in the HubspotClient project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/farbfox/hubspot_client/blob/master/CODE_OF_CONDUCT.md).
|
data/bin/console
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'hubspot_client'
|
6
|
+
require 'dotenv'
|
7
|
+
require 'pry'
|
8
|
+
|
9
|
+
Dotenv.load
|
10
|
+
|
11
|
+
HubspotClient.configure do |config|
|
12
|
+
config.access_token = ENV['ACCESS_TOKEN']
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'irb'
|
16
|
+
IRB.start(__FILE__)
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'hubspot_client/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'hubspot_client'
|
9
|
+
spec.version = HubspotClient::VERSION
|
10
|
+
spec.authors = %w[Garllon]
|
11
|
+
spec.email = ['garllon@protonmail.com']
|
12
|
+
|
13
|
+
spec.summary = 'Hubspot client'
|
14
|
+
spec.description = 'Hubspot client to handle CRM objects.'
|
15
|
+
spec.homepage = 'https://github.com/Farbfox/hubspot_client/blob/main/README.md'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.required_ruby_version = '>= 3.0.0'
|
19
|
+
|
20
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
21
|
+
spec.metadata['source_code_uri'] = 'https://github.com/Farbfox/hubspot_client'
|
22
|
+
spec.metadata['changelog_uri'] = 'https://github.com/Farbfox/hubspot_client/blob/main/CHANGELOG.md'
|
23
|
+
|
24
|
+
# Specify which files should be added to the gem when it is released.
|
25
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added
|
26
|
+
# into git.
|
27
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
28
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|features)/}) }
|
29
|
+
end
|
30
|
+
spec.bindir = 'exe'
|
31
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ['lib']
|
33
|
+
|
34
|
+
spec.add_dependency 'httparty', '~> 0.20.0'
|
35
|
+
|
36
|
+
spec.add_development_dependency 'bundler', '~> 2.3.26'
|
37
|
+
spec.add_development_dependency 'dotenv', '~> 2.8', '>= 2.8.1'
|
38
|
+
spec.add_development_dependency 'pry', '~> 0.14'
|
39
|
+
spec.add_development_dependency 'rspec', '~> 3.12'
|
40
|
+
spec.add_development_dependency 'rubocop', '~> 1.39'
|
41
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.15'
|
42
|
+
spec.add_development_dependency 'vcr', '~> 6.1'
|
43
|
+
spec.add_development_dependency 'webmock', '~> 3.18'
|
44
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HubspotClient
|
4
|
+
module Client
|
5
|
+
class CompanyNotFound < StandardError; end
|
6
|
+
class CompanyNotCreated < StandardError; end
|
7
|
+
class CompanyNotUpdated < StandardError; end
|
8
|
+
|
9
|
+
class Company
|
10
|
+
include HTTParty
|
11
|
+
base_uri 'https://api.hubapi.com'
|
12
|
+
|
13
|
+
BASE_PATH = '/crm/v3/objects/companies'
|
14
|
+
FIND_PROPERTIES = %w[name phone address city zip].freeze
|
15
|
+
|
16
|
+
def find_by_id(hubspot_id)
|
17
|
+
response = self.class.get("#{BASE_PATH}/#{hubspot_id}?properties=#{FIND_PROPERTIES.join(',')}",
|
18
|
+
headers: headers)
|
19
|
+
return response if response.code == 200
|
20
|
+
|
21
|
+
raise CompanyNotFound, 'Hubspot Company Not Found'
|
22
|
+
end
|
23
|
+
|
24
|
+
def create(properties)
|
25
|
+
response = self.class.post(BASE_PATH,
|
26
|
+
body: { properties: properties }.to_json,
|
27
|
+
headers: headers)
|
28
|
+
|
29
|
+
return response if response.code == 201
|
30
|
+
|
31
|
+
raise CompanyNotCreated, 'Hubspot could not Create'
|
32
|
+
end
|
33
|
+
|
34
|
+
def update(hubspot_id, properties)
|
35
|
+
response = self.class.patch("#{BASE_PATH}/#{hubspot_id}",
|
36
|
+
body: { properties: properties }.to_json,
|
37
|
+
headers: headers)
|
38
|
+
|
39
|
+
return response if response.code == 200
|
40
|
+
|
41
|
+
raise CompanyNotUpdated, 'Hubspot could not update'
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def headers
|
47
|
+
{ Authorization: "Bearer #{HubspotClient.configuration.access_token}",
|
48
|
+
'Content-Type': 'application/json' }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HubspotClient
|
4
|
+
module Client
|
5
|
+
class ContactNotFound < StandardError; end
|
6
|
+
class ContactNotCreated < StandardError; end
|
7
|
+
class ContactNotUpdated < StandardError; end
|
8
|
+
|
9
|
+
class Contact
|
10
|
+
include HTTParty
|
11
|
+
base_uri 'https://api.hubapi.com'
|
12
|
+
|
13
|
+
BASE_PATH = '/crm/v3/objects/contacts'
|
14
|
+
FIND_PROPERTIES = %w[firstname lastname email phone lifecyclestage associatedcompanyid].freeze
|
15
|
+
|
16
|
+
def find_by_email(email)
|
17
|
+
query_params = find_query_params({ idProperty: 'email' })
|
18
|
+
find_by("#{BASE_PATH}/#{email}?#{query_params}")
|
19
|
+
end
|
20
|
+
|
21
|
+
def find_by_id(hubspot_id)
|
22
|
+
query_params = find_query_params
|
23
|
+
|
24
|
+
find_by("#{BASE_PATH}/#{hubspot_id}?#{query_params}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def create(properties)
|
28
|
+
response = self.class.post(BASE_PATH,
|
29
|
+
body: { properties: properties }.to_json,
|
30
|
+
headers: headers)
|
31
|
+
|
32
|
+
return response if response.code == 201
|
33
|
+
|
34
|
+
raise ContactNotCreated, 'Hubspot Contact Not created'
|
35
|
+
end
|
36
|
+
|
37
|
+
def update(hubspot_id, properties)
|
38
|
+
response = self.class.patch("#{BASE_PATH}/#{hubspot_id}",
|
39
|
+
body: { properties: properties }.to_json,
|
40
|
+
headers: headers)
|
41
|
+
|
42
|
+
return response if response.code == 200
|
43
|
+
|
44
|
+
raise ContactNotUpdated, 'Hubspot could not update'
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def find_by(path)
|
50
|
+
response = self.class.get(path, headers: headers)
|
51
|
+
return response if response.code == 200
|
52
|
+
|
53
|
+
raise ContactNotFound, 'Hubspot Contact Not Found'
|
54
|
+
end
|
55
|
+
|
56
|
+
def find_query_params(query_params = {})
|
57
|
+
query_params['properties'] = FIND_PROPERTIES.join(',')
|
58
|
+
query_params.map do |key, value|
|
59
|
+
"#{key}=#{value}"
|
60
|
+
end.join('&')
|
61
|
+
end
|
62
|
+
|
63
|
+
def headers
|
64
|
+
{ Authorization: "Bearer #{HubspotClient.configuration.access_token}",
|
65
|
+
'Content-Type': 'application/json' }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HubspotClient
|
4
|
+
module Client
|
5
|
+
class Properties
|
6
|
+
include HTTParty
|
7
|
+
base_uri 'https://api.hubapi.com'
|
8
|
+
|
9
|
+
BASE_PATH = '/crm/v3/properties'
|
10
|
+
|
11
|
+
def for(object_type)
|
12
|
+
response = self.class.get("#{BASE_PATH}/#{object_type}", headers: headers)
|
13
|
+
return response if response.code == 200
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def headers
|
19
|
+
{ Authorization: "Bearer #{HubspotClient.configuration.access_token}",
|
20
|
+
'Content-Type': 'application/json' }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HubspotClient
|
4
|
+
module Model
|
5
|
+
class Company < OpenStruct
|
6
|
+
UPDATABLE_PROPERTIES = %i[name phone address city zip].freeze
|
7
|
+
|
8
|
+
def self.find(hubspot_id: nil)
|
9
|
+
response = Client::Company.new.find_by_id(hubspot_id)
|
10
|
+
|
11
|
+
return nil if response['properties'].nil?
|
12
|
+
|
13
|
+
new(response['properties'])
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.create(properties)
|
17
|
+
sliced_properties = properties.slice(*UPDATABLE_PROPERTIES)
|
18
|
+
response = Client::Company.new.create(sliced_properties)
|
19
|
+
|
20
|
+
new(response['properties'])
|
21
|
+
end
|
22
|
+
|
23
|
+
def update
|
24
|
+
properties = to_h.slice(*UPDATABLE_PROPERTIES)
|
25
|
+
response = Client::Company.new.update(hs_object_id, properties)
|
26
|
+
|
27
|
+
return true if response.code == 200
|
28
|
+
|
29
|
+
false
|
30
|
+
end
|
31
|
+
|
32
|
+
def reload
|
33
|
+
response = Client::Company.new.find_by_id(hs_object_id)
|
34
|
+
response['properties'].each do |key, value|
|
35
|
+
self[key] = value if value != self[key]
|
36
|
+
end
|
37
|
+
|
38
|
+
self
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HubspotClient
|
4
|
+
module Model
|
5
|
+
class MissingParameter < StandardError; end
|
6
|
+
|
7
|
+
class Contact < OpenStruct
|
8
|
+
UPDATABLE_PROPERTIES = %i[firstname lastname email phone lifecyclestage].freeze
|
9
|
+
|
10
|
+
def self.find(hubspot_id: nil, email: nil)
|
11
|
+
response = if hubspot_id
|
12
|
+
Client::Contact.new.find_by_id(hubspot_id)
|
13
|
+
elsif email
|
14
|
+
Client::Contact.new.find_by_email(email)
|
15
|
+
else
|
16
|
+
raise MissingParameter, 'email or hubspot_id needs to be set'
|
17
|
+
end
|
18
|
+
|
19
|
+
new(response['properties'])
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.create(properties)
|
23
|
+
sliced_properties = properties.slice(*UPDATABLE_PROPERTIES)
|
24
|
+
response = Client::Contact.new.create(sliced_properties)
|
25
|
+
|
26
|
+
new(response['properties'])
|
27
|
+
end
|
28
|
+
|
29
|
+
def update
|
30
|
+
properties = to_h.slice(*UPDATABLE_PROPERTIES)
|
31
|
+
response = Client::Contact.new.update(hs_object_id, properties)
|
32
|
+
|
33
|
+
return true if response.code == 200
|
34
|
+
|
35
|
+
false
|
36
|
+
end
|
37
|
+
|
38
|
+
def reload
|
39
|
+
response = Client::Contact.new.find_by_id(hs_object_id)
|
40
|
+
response['properties'].each do |key, value|
|
41
|
+
self[key] = value if value != self[key]
|
42
|
+
end
|
43
|
+
|
44
|
+
self
|
45
|
+
end
|
46
|
+
|
47
|
+
def primary_company
|
48
|
+
@primary_company ||= Company.find(hubspot_id: associatedcompanyid)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'httparty'
|
4
|
+
require 'hubspot_client/version'
|
5
|
+
require 'hubspot_client/configuration'
|
6
|
+
require 'hubspot_client/client/contact'
|
7
|
+
require 'hubspot_client/client/company'
|
8
|
+
require 'hubspot_client/client/properties'
|
9
|
+
require 'hubspot_client/model/contact'
|
10
|
+
require 'hubspot_client/model/company'
|
11
|
+
|
12
|
+
module HubspotClient
|
13
|
+
class << self
|
14
|
+
attr_writer :configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.configuration
|
18
|
+
@configuration ||= Configuration.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.reset
|
22
|
+
@configuration.reset!
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.configure
|
26
|
+
yield(configuration)
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hubspot_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.beta1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Garllon
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-11-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.20.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.20.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.3.26
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.3.26
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dotenv
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.8'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 2.8.1
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '2.8'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 2.8.1
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: pry
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0.14'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0.14'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rspec
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '3.12'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '3.12'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rubocop
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '1.39'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '1.39'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: rubocop-rspec
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '2.15'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '2.15'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: vcr
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '6.1'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '6.1'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: webmock
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '3.18'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - "~>"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '3.18'
|
145
|
+
description: Hubspot client to handle CRM objects.
|
146
|
+
email:
|
147
|
+
- garllon@protonmail.com
|
148
|
+
executables: []
|
149
|
+
extensions: []
|
150
|
+
extra_rdoc_files: []
|
151
|
+
files:
|
152
|
+
- ".github/workflows/rspec_and_rubocop.yml"
|
153
|
+
- ".gitignore"
|
154
|
+
- ".rubocop.yml"
|
155
|
+
- Gemfile
|
156
|
+
- Gemfile.lock
|
157
|
+
- README.md
|
158
|
+
- bin/console
|
159
|
+
- hubspot_client.gemspec
|
160
|
+
- lib/hubspot_client.rb
|
161
|
+
- lib/hubspot_client/client/company.rb
|
162
|
+
- lib/hubspot_client/client/contact.rb
|
163
|
+
- lib/hubspot_client/client/properties.rb
|
164
|
+
- lib/hubspot_client/configuration.rb
|
165
|
+
- lib/hubspot_client/model/company.rb
|
166
|
+
- lib/hubspot_client/model/contact.rb
|
167
|
+
- lib/hubspot_client/version.rb
|
168
|
+
homepage: https://github.com/Farbfox/hubspot_client/blob/main/README.md
|
169
|
+
licenses:
|
170
|
+
- MIT
|
171
|
+
metadata:
|
172
|
+
homepage_uri: https://github.com/Farbfox/hubspot_client/blob/main/README.md
|
173
|
+
source_code_uri: https://github.com/Farbfox/hubspot_client
|
174
|
+
changelog_uri: https://github.com/Farbfox/hubspot_client/blob/main/CHANGELOG.md
|
175
|
+
post_install_message:
|
176
|
+
rdoc_options: []
|
177
|
+
require_paths:
|
178
|
+
- lib
|
179
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
180
|
+
requirements:
|
181
|
+
- - ">="
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: 3.0.0
|
184
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - ">"
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: 1.3.1
|
189
|
+
requirements: []
|
190
|
+
rubygems_version: 3.3.3
|
191
|
+
signing_key:
|
192
|
+
specification_version: 4
|
193
|
+
summary: Hubspot client
|
194
|
+
test_files: []
|