hubspot_client 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +12 -6
- data/lib/hubspot_client/client/communication_preference.rb +4 -4
- data/lib/hubspot_client/client/company.rb +6 -6
- data/lib/hubspot_client/client/contact.rb +7 -7
- data/lib/hubspot_client/client_base_error.rb +8 -0
- data/lib/hubspot_client/model/company.rb +8 -6
- data/lib/hubspot_client/model/contact.rb +8 -6
- data/lib/hubspot_client/model/property.rb +19 -0
- data/lib/hubspot_client/version.rb +1 -1
- data/lib/hubspot_client.rb +2 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dd7941d915d5f004993d879b6575183f74a4b63dddd95760f79ee03c2df5453
|
4
|
+
data.tar.gz: 1cb35e4a8c2f29589f6ee0fa488e63bb36fd501c1ad31e9dc426b2798b829e63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8e0bfd247d726aa8cd993d50d5351dba0429388f37ea8c331fda4e713c652cb1be99ca247eb3a48c7b6010dd5849bdd944a7bf8fbcce2b48e8c0e123cc10685
|
7
|
+
data.tar.gz: 5149870440dcce65666deddab1d44ccd79003f2caa7523a64b580c7bb6ae64892e3504ce84261c15e6f1c981414ed6c2c978fc366fac93f374dcc4b5e7a7d1b2
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
|
2
2
|
# HubspotClient
|
3
3
|
|
4
|
-
|
4
|
+
A Hubspot Client. Currently we only support the following CRM Parts:
|
5
|
+
* Contact
|
6
|
+
* Company
|
7
|
+
* Properties
|
8
|
+
|
9
|
+
Also:
|
10
|
+
* Communication Preferences
|
5
11
|
|
6
12
|
## Installation
|
7
13
|
|
@@ -30,9 +36,10 @@ end
|
|
30
36
|
|
31
37
|
## Models
|
32
38
|
|
33
|
-
The
|
39
|
+
The following models exists and should be mainly used. However you can also use the clients itself,
|
40
|
+
if you like, but you need to understand the code by yourself.
|
34
41
|
|
35
|
-
### Contact
|
42
|
+
### Contact
|
36
43
|
|
37
44
|
[Hubspot- API](https://developers.hubspot.com/docs/api/crm/contacts)
|
38
45
|
|
@@ -47,9 +54,8 @@ HubspotClient::Model::Contact.find(email: 'vader@example.com')
|
|
47
54
|
=> #<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">
|
48
55
|
```
|
49
56
|
|
50
|
-
####
|
57
|
+
#### associate_primary_company
|
51
58
|
|
52
|
-
Successfull Request
|
53
59
|
```ruby
|
54
60
|
hubspot_contact = HubspotClient::Model::Contact.find(hubspot_id: '1337')
|
55
61
|
=> #<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">
|
@@ -104,7 +110,7 @@ hubspot_company.update({ name: 'Blubber' })
|
|
104
110
|
|
105
111
|
|
106
112
|
|
107
|
-
###
|
113
|
+
### Communication-Preference
|
108
114
|
|
109
115
|
[Hubspot- API](https://developers.hubspot.com/docs/api/marketing-api/subscriptions-preferences)
|
110
116
|
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
module HubspotClient
|
4
4
|
module Client
|
5
|
-
class SubscriptionNotSuccessful <
|
6
|
-
class FetchDefinitionsNotSuccessful <
|
5
|
+
class SubscriptionNotSuccessful < ClientBaseError; end
|
6
|
+
class FetchDefinitionsNotSuccessful < ClientBaseError; end
|
7
7
|
|
8
8
|
class CommunicationPreference
|
9
9
|
include HTTParty
|
@@ -17,7 +17,7 @@ module HubspotClient
|
|
17
17
|
|
18
18
|
return response if response.code == 200
|
19
19
|
|
20
|
-
raise FetchDefinitionsNotSuccessful
|
20
|
+
raise FetchDefinitionsNotSuccessful, response
|
21
21
|
end
|
22
22
|
|
23
23
|
def subscribe(properties)
|
@@ -27,7 +27,7 @@ module HubspotClient
|
|
27
27
|
|
28
28
|
return response if response.code == 200
|
29
29
|
|
30
|
-
raise SubscriptionNotSuccessful
|
30
|
+
raise SubscriptionNotSuccessful, response
|
31
31
|
end
|
32
32
|
|
33
33
|
def headers
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
module HubspotClient
|
4
4
|
module Client
|
5
|
-
class CompanyNotFound <
|
6
|
-
class CompanyNotCreated <
|
7
|
-
class CompanyNotUpdated <
|
5
|
+
class CompanyNotFound < ClientBaseError; end
|
6
|
+
class CompanyNotCreated < ClientBaseError; end
|
7
|
+
class CompanyNotUpdated < ClientBaseError; end
|
8
8
|
|
9
9
|
class Company
|
10
10
|
include HTTParty
|
@@ -18,7 +18,7 @@ module HubspotClient
|
|
18
18
|
headers: headers)
|
19
19
|
return response if response.code == 200
|
20
20
|
|
21
|
-
raise CompanyNotFound,
|
21
|
+
raise CompanyNotFound, response
|
22
22
|
end
|
23
23
|
|
24
24
|
def create(properties)
|
@@ -28,7 +28,7 @@ module HubspotClient
|
|
28
28
|
|
29
29
|
return response if response.code == 201
|
30
30
|
|
31
|
-
raise CompanyNotCreated,
|
31
|
+
raise CompanyNotCreated, response
|
32
32
|
end
|
33
33
|
|
34
34
|
def update(hubspot_id, properties)
|
@@ -38,7 +38,7 @@ module HubspotClient
|
|
38
38
|
|
39
39
|
return response if response.code == 200
|
40
40
|
|
41
|
-
raise CompanyNotUpdated,
|
41
|
+
raise CompanyNotUpdated, response
|
42
42
|
end
|
43
43
|
|
44
44
|
private
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module HubspotClient
|
4
4
|
module Client
|
5
|
-
class ContactNotFound <
|
6
|
-
class ContactNotCreated <
|
7
|
-
class ContactNotUpdated <
|
8
|
-
class AssociationError <
|
5
|
+
class ContactNotFound < ClientBaseError; end
|
6
|
+
class ContactNotCreated < ClientBaseError; end
|
7
|
+
class ContactNotUpdated < ClientBaseError; end
|
8
|
+
class AssociationError < ClientBaseError; end
|
9
9
|
|
10
10
|
class Contact
|
11
11
|
include HTTParty
|
@@ -32,7 +32,7 @@ module HubspotClient
|
|
32
32
|
|
33
33
|
return response if response.code == 201
|
34
34
|
|
35
|
-
raise ContactNotCreated,
|
35
|
+
raise ContactNotCreated, response
|
36
36
|
end
|
37
37
|
|
38
38
|
def update(hubspot_id, properties)
|
@@ -42,7 +42,7 @@ module HubspotClient
|
|
42
42
|
|
43
43
|
return response if response.code == 200
|
44
44
|
|
45
|
-
raise ContactNotUpdated,
|
45
|
+
raise ContactNotUpdated, response
|
46
46
|
end
|
47
47
|
|
48
48
|
def associate_with(hubspot_id, to_object_type, to_object_type_id, association_type = '1')
|
@@ -60,7 +60,7 @@ module HubspotClient
|
|
60
60
|
response = self.class.get(path, headers: headers)
|
61
61
|
return response if response.code == 200
|
62
62
|
|
63
|
-
raise ContactNotFound,
|
63
|
+
raise ContactNotFound, response
|
64
64
|
end
|
65
65
|
|
66
66
|
def find_query_params(query_params = {})
|
@@ -3,8 +3,6 @@
|
|
3
3
|
module HubspotClient
|
4
4
|
module Model
|
5
5
|
class Company < OpenStruct
|
6
|
-
UPDATABLE_PROPERTIES = %i[name phone address city zip].freeze
|
7
|
-
|
8
6
|
def self.find(hubspot_id: nil)
|
9
7
|
response = Client::Company.new.find_by_id(hubspot_id)
|
10
8
|
|
@@ -14,16 +12,14 @@ module HubspotClient
|
|
14
12
|
end
|
15
13
|
|
16
14
|
def self.create(properties)
|
17
|
-
|
18
|
-
response = Client::Company.new.create(sliced_properties)
|
15
|
+
response = Client::Company.new.create(properties)
|
19
16
|
|
20
17
|
new(response['properties'])
|
21
18
|
end
|
22
19
|
|
23
20
|
def update(new_properties = {})
|
24
21
|
assign_attributes(new_properties)
|
25
|
-
|
26
|
-
response = Client::Company.new.update(hs_object_id, properties)
|
22
|
+
response = Client::Company.new.update(hs_object_id, to_h.slice(*writable_properties))
|
27
23
|
|
28
24
|
return true if response.code == 200
|
29
25
|
|
@@ -44,6 +40,12 @@ module HubspotClient
|
|
44
40
|
self[attribute] = value
|
45
41
|
end
|
46
42
|
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def writable_properties
|
47
|
+
HubspotClient::Model::Property.writable_property_names_for('companies')
|
48
|
+
end
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|
@@ -5,8 +5,6 @@ module HubspotClient
|
|
5
5
|
class MissingParameter < StandardError; end
|
6
6
|
|
7
7
|
class Contact < OpenStruct
|
8
|
-
UPDATABLE_PROPERTIES = %i[firstname lastname email phone lifecyclestage].freeze
|
9
|
-
|
10
8
|
def self.find(hubspot_id: nil, email: nil)
|
11
9
|
response = if hubspot_id
|
12
10
|
Client::Contact.new.find_by_id(hubspot_id)
|
@@ -20,16 +18,14 @@ module HubspotClient
|
|
20
18
|
end
|
21
19
|
|
22
20
|
def self.create(properties)
|
23
|
-
|
24
|
-
response = Client::Contact.new.create(sliced_properties)
|
21
|
+
response = Client::Contact.new.create(properties)
|
25
22
|
|
26
23
|
new(response['properties'])
|
27
24
|
end
|
28
25
|
|
29
26
|
def update(new_properties = {})
|
30
27
|
assign_attributes(new_properties)
|
31
|
-
|
32
|
-
response = Client::Contact.new.update(hs_object_id, properties)
|
28
|
+
response = Client::Contact.new.update(hs_object_id, to_h.slice(*writable_properties))
|
33
29
|
|
34
30
|
return true if response.code == 200
|
35
31
|
|
@@ -74,6 +70,12 @@ module HubspotClient
|
|
74
70
|
self[attribute] = value
|
75
71
|
end
|
76
72
|
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def writable_properties
|
77
|
+
HubspotClient::Model::Property.writable_property_names_for('contacts')
|
78
|
+
end
|
77
79
|
end
|
78
80
|
end
|
79
81
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HubspotClient
|
4
|
+
module Model
|
5
|
+
class Property
|
6
|
+
def self.all_for(object_type)
|
7
|
+
HubspotClient::Client::Properties.new.for(object_type)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.writable_property_names_for(object_type)
|
11
|
+
readonly_properties = all_for(object_type)['results'].reject do |property|
|
12
|
+
property['modificationMetadata']['readOnlyValue'] == true
|
13
|
+
end
|
14
|
+
|
15
|
+
readonly_properties.map { |property| property['name'].to_sym }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/hubspot_client.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'httparty'
|
4
|
+
require 'hubspot_client/client_base_error'
|
4
5
|
require 'hubspot_client/client/communication_preference'
|
5
6
|
require 'hubspot_client/client/company'
|
6
7
|
require 'hubspot_client/client/contact'
|
@@ -9,6 +10,7 @@ require 'hubspot_client/configuration'
|
|
9
10
|
require 'hubspot_client/model/communication_preference'
|
10
11
|
require 'hubspot_client/model/company'
|
11
12
|
require 'hubspot_client/model/contact'
|
13
|
+
require 'hubspot_client/model/property'
|
12
14
|
require 'hubspot_client/version'
|
13
15
|
|
14
16
|
module HubspotClient
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hubspot_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garllon
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-12-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -165,10 +165,12 @@ files:
|
|
165
165
|
- lib/hubspot_client/client/company.rb
|
166
166
|
- lib/hubspot_client/client/contact.rb
|
167
167
|
- lib/hubspot_client/client/properties.rb
|
168
|
+
- lib/hubspot_client/client_base_error.rb
|
168
169
|
- lib/hubspot_client/configuration.rb
|
169
170
|
- lib/hubspot_client/model/communication_preference.rb
|
170
171
|
- lib/hubspot_client/model/company.rb
|
171
172
|
- lib/hubspot_client/model/contact.rb
|
173
|
+
- lib/hubspot_client/model/property.rb
|
172
174
|
- lib/hubspot_client/version.rb
|
173
175
|
homepage: https://github.com/Farbfox/hubspot_client/blob/main/README.md
|
174
176
|
licenses:
|
@@ -192,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
194
|
- !ruby/object:Gem::Version
|
193
195
|
version: '0'
|
194
196
|
requirements: []
|
195
|
-
rubygems_version: 3.3.
|
197
|
+
rubygems_version: 3.3.3
|
196
198
|
signing_key:
|
197
199
|
specification_version: 4
|
198
200
|
summary: Hubspot client
|