hubspot_client 0.1.0 → 0.2.0
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 +2 -6
- data/lib/hubspot_client/model/contact.rb +2 -6
- data/lib/hubspot_client/version.rb +1 -1
- data/lib/hubspot_client.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29ef10cf9b14d327f1d9990684aca8cfe7c7988cbf26cb4420c20bc14c18d237
|
4
|
+
data.tar.gz: fded388fb01ad2b338ba0ba32631553d24e72612fa0866644c9d95725b91542d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5b1458f89a50a95e1323b984329b10b47a992e05b8f1a662935ada633d019e111043de8e4ec31c453fb61f8421bca05be70c63d32629f556ac216b49e60d383
|
7
|
+
data.tar.gz: 512dfc4ba03b80366059709c74ea09559c5e925c339dbdc556b4a24efd0d81db9cedd99ff90c308890c5e1b7fce83c2aeb034ed1a1d69f9cf58e4565f8879774
|
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)
|
27
23
|
|
28
24
|
return true if response.code == 200
|
29
25
|
|
@@ -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)
|
33
29
|
|
34
30
|
return true if response.code == 200
|
35
31
|
|
data/lib/hubspot_client.rb
CHANGED
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.
|
4
|
+
version: 0.2.0
|
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-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -165,6 +165,7 @@ 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
|
@@ -192,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
193
|
- !ruby/object:Gem::Version
|
193
194
|
version: '0'
|
194
195
|
requirements: []
|
195
|
-
rubygems_version: 3.3.
|
196
|
+
rubygems_version: 3.3.3
|
196
197
|
signing_key:
|
197
198
|
specification_version: 4
|
198
199
|
summary: Hubspot client
|