hubspot_client 0.1.0.beta2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +5 -1
- data/CHANGELOG.md +9 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/hubspot_client.gemspec +2 -2
- data/lib/hubspot_client/client/communication_preference.rb +39 -0
- data/lib/hubspot_client/model/communication_preference.rb +11 -0
- data/lib/hubspot_client/model/contact.rb +12 -0
- data/lib/hubspot_client/version.rb +1 -1
- data/lib/hubspot_client.rb +6 -4
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64366ba11cb24670e4a304a5a16307402736fe0f941f725535f148a37329afdc
|
4
|
+
data.tar.gz: d134c5b394c90e1b86d7cc716b20196289ba3c3c1b7768793d5d15fdca86ff0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5be8964ed3c42cc2e01481da815de2d7f068ff1a4359f092ec1c89a864c761aa51c91cc6c79511004c685bcab19da1a8b7a81d0ec4cdf17b7ccc95de8fdb72b8
|
7
|
+
data.tar.gz: b27567094d0c0cfe0166ee7ae13b0c99012b2f127cddb62d5f703916b17e32864257a39892109360625c528239ddbc0961fbc3df369be1c89c1ded0e0ab6e906
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/hubspot_client.gemspec
CHANGED
@@ -7,8 +7,8 @@ require 'hubspot_client/version'
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = 'hubspot_client'
|
9
9
|
spec.version = HubspotClient::VERSION
|
10
|
-
spec.authors = %w[Garllon]
|
11
|
-
spec.email = [
|
10
|
+
spec.authors = %w[Garllon romankonz]
|
11
|
+
spec.email = %w[garllon@protonmail.com roman@konz.me]
|
12
12
|
|
13
13
|
spec.summary = 'Hubspot client'
|
14
14
|
spec.description = 'Hubspot client to handle CRM objects.'
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HubspotClient
|
4
|
+
module Client
|
5
|
+
class SubscriptionNotSuccessful < StandardError; end
|
6
|
+
class FetchDefinitionsNotSuccessful < StandardError; end
|
7
|
+
|
8
|
+
class CommunicationPreference
|
9
|
+
include HTTParty
|
10
|
+
base_uri 'https://api.hubapi.com'
|
11
|
+
|
12
|
+
BASE_PATH = '/communication-preferences/v3'
|
13
|
+
|
14
|
+
def definitions
|
15
|
+
response = self.class.get("#{BASE_PATH}/definitions",
|
16
|
+
headers: headers)
|
17
|
+
|
18
|
+
return response if response.code == 200
|
19
|
+
|
20
|
+
raise FetchDefinitionsNotSuccessful
|
21
|
+
end
|
22
|
+
|
23
|
+
def subscribe(properties)
|
24
|
+
response = self.class.post("#{BASE_PATH}/subscribe",
|
25
|
+
body: properties.to_json,
|
26
|
+
headers: headers)
|
27
|
+
|
28
|
+
return response if response.code == 200
|
29
|
+
|
30
|
+
raise SubscriptionNotSuccessful
|
31
|
+
end
|
32
|
+
|
33
|
+
def headers
|
34
|
+
{ Authorization: "Bearer #{HubspotClient.configuration.access_token}",
|
35
|
+
'Content-Type': 'application/json' }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -45,6 +45,18 @@ module HubspotClient
|
|
45
45
|
self
|
46
46
|
end
|
47
47
|
|
48
|
+
def create_communication_subscription(subscription_id:, legal_basis: nil, legal_basis_explanation: nil)
|
49
|
+
properties = {
|
50
|
+
emailAddress: email,
|
51
|
+
subscriptionId: subscription_id
|
52
|
+
}
|
53
|
+
|
54
|
+
properties[:legalBasis] = legal_basis if legal_basis
|
55
|
+
properties[:legalBasisExplanation] = legal_basis_explanation if legal_basis_explanation
|
56
|
+
|
57
|
+
Client::CommunicationPreference.new.subscribe(properties)
|
58
|
+
end
|
59
|
+
|
48
60
|
def primary_company
|
49
61
|
@primary_company ||= Company.find(hubspot_id: associatedcompanyid)
|
50
62
|
end
|
data/lib/hubspot_client.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'httparty'
|
4
|
-
require 'hubspot_client/
|
5
|
-
require 'hubspot_client/configuration'
|
6
|
-
require 'hubspot_client/client/contact'
|
4
|
+
require 'hubspot_client/client/communication_preference'
|
7
5
|
require 'hubspot_client/client/company'
|
6
|
+
require 'hubspot_client/client/contact'
|
8
7
|
require 'hubspot_client/client/properties'
|
9
|
-
require 'hubspot_client/
|
8
|
+
require 'hubspot_client/configuration'
|
9
|
+
require 'hubspot_client/model/communication_preference'
|
10
10
|
require 'hubspot_client/model/company'
|
11
|
+
require 'hubspot_client/model/contact'
|
12
|
+
require 'hubspot_client/version'
|
11
13
|
|
12
14
|
module HubspotClient
|
13
15
|
class << self
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hubspot_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garllon
|
8
|
+
- romankonz
|
8
9
|
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
12
|
+
date: 2022-11-30 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: httparty
|
@@ -145,6 +146,7 @@ dependencies:
|
|
145
146
|
description: Hubspot client to handle CRM objects.
|
146
147
|
email:
|
147
148
|
- garllon@protonmail.com
|
149
|
+
- roman@konz.me
|
148
150
|
executables: []
|
149
151
|
extensions: []
|
150
152
|
extra_rdoc_files: []
|
@@ -159,10 +161,12 @@ files:
|
|
159
161
|
- bin/console
|
160
162
|
- hubspot_client.gemspec
|
161
163
|
- lib/hubspot_client.rb
|
164
|
+
- lib/hubspot_client/client/communication_preference.rb
|
162
165
|
- lib/hubspot_client/client/company.rb
|
163
166
|
- lib/hubspot_client/client/contact.rb
|
164
167
|
- lib/hubspot_client/client/properties.rb
|
165
168
|
- lib/hubspot_client/configuration.rb
|
169
|
+
- lib/hubspot_client/model/communication_preference.rb
|
166
170
|
- lib/hubspot_client/model/company.rb
|
167
171
|
- lib/hubspot_client/model/contact.rb
|
168
172
|
- lib/hubspot_client/version.rb
|
@@ -184,9 +188,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
184
188
|
version: 3.0.0
|
185
189
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
190
|
requirements:
|
187
|
-
- - "
|
191
|
+
- - ">="
|
188
192
|
- !ruby/object:Gem::Version
|
189
|
-
version:
|
193
|
+
version: '0'
|
190
194
|
requirements: []
|
191
195
|
rubygems_version: 3.3.22
|
192
196
|
signing_key:
|