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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6bc3a880bcae828da2e0ae5b37c4027339352b7294868caeb3b87395be557897
4
- data.tar.gz: 78a1a367a7a052726fa95f4d792ffdcb1d619ba58cfde4a3f3f1842277aedb41
3
+ metadata.gz: 64366ba11cb24670e4a304a5a16307402736fe0f941f725535f148a37329afdc
4
+ data.tar.gz: d134c5b394c90e1b86d7cc716b20196289ba3c3c1b7768793d5d15fdca86ff0c
5
5
  SHA512:
6
- metadata.gz: c5d4d5cd7dae89474741e4a985452b2a7aaf15681ba97b61a4fe8ddf8a52d5ecebd0267a6c4304470e65b5a20c35cf52a46c3f4aa66cb86febe0c313d5534914
7
- data.tar.gz: 965e6fbd91337cc4f22c88ed74b4ca02ffc1a5fd3dacc8dbd9b0a3efc7254c288fa06efc840827fb453372b389f9cf35fd66398c15f276e3103ec863a820a221
6
+ metadata.gz: 5be8964ed3c42cc2e01481da815de2d7f068ff1a4359f092ec1c89a864c761aa51c91cc6c79511004c685bcab19da1a8b7a81d0ec4cdf17b7ccc95de8fdb72b8
7
+ data.tar.gz: b27567094d0c0cfe0166ee7ae13b0c99012b2f127cddb62d5f703916b17e32864257a39892109360625c528239ddbc0961fbc3df369be1c89c1ded0e0ab6e906
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  .env
2
2
  .idea/
3
+ .ruby-version
data/.rubocop.yml CHANGED
@@ -4,4 +4,8 @@ Layout/LineLength:
4
4
  Max: 120
5
5
 
6
6
  Style/Documentation:
7
- Enabled: false
7
+ Enabled: false
8
+
9
+ Metrics/ModuleLength:
10
+ Exclude:
11
+ - 'spec/hubspot_client/model/contact_spec.rb'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 0.1.0 (2022-11-30)
2
+
3
+ ### Features
4
+ * add method for contact model to set communication preferences
5
+ * added communication preference client
6
+
7
+ ### Breaking Changes
8
+ None
9
+
1
10
  ## 0.1.0.beta2 (2022-11-28)
2
11
 
3
12
  ### Features
data/Gemfile CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- # Specify your gem's dependencies in graphql_connector.gemspec
5
+ # Specify your gem's dependencies in hubspot_client.gemspec
6
6
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hubspot_client (0.1.0.beta2)
4
+ hubspot_client (0.1.0)
5
5
  httparty (~> 0.20.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -21,7 +21,7 @@ Or install it yourself as:
21
21
 
22
22
  ## Usage
23
23
 
24
- You need to configure the `graphql_connector` first:
24
+ You need to configure the `hubspot_client` first:
25
25
  ``` ruby
26
26
  HubspotClient.configure do |config|
27
27
  config.access_token = 'PRIVATE_APP_ACCESS_TOKEN'
@@ -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 = ['garllon@protonmail.com']
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
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HubspotClient
4
+ module Model
5
+ class CommunicationPreference
6
+ def self.definitions
7
+ Client::CommunicationPreference.new.definitions
8
+ end
9
+ end
10
+ end
11
+ 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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HubspotClient
4
- VERSION = '0.1.0.beta2'
4
+ VERSION = '0.1.0'
5
5
  end
@@ -1,13 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'httparty'
4
- require 'hubspot_client/version'
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/model/contact'
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.beta2
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-29 00:00:00.000000000 Z
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: 1.3.1
193
+ version: '0'
190
194
  requirements: []
191
195
  rubygems_version: 3.3.22
192
196
  signing_key: