hubspot_client 0.3.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5904fbc990f2c806e61e911eba497a18c8d5edd447bf037e7645b67c996316e
4
- data.tar.gz: 37c4de7c938ae280b5c33f184eb2bdc8c4c86aab769aeed3c55223f64a66cf26
3
+ metadata.gz: d32c26caa7aef52958e69b0e2d39e817a3f7bc3040588047cf87a971e368624c
4
+ data.tar.gz: d9eb9948cefd4c32be3dd6a063a066f19585a787460eb1497bf440c798f35297
5
5
  SHA512:
6
- metadata.gz: 285786683544164c349a56e2dbfc14ffdaff18f073aaf6e409daa0dc5c12a892f5ffffc0e7607b31f0ae8a85a77e542d25edd69576411f61f6cb18033a510d9e
7
- data.tar.gz: 13a19aa59a459dfa3b50e3a2314e89f9d611fea3a2a56d862c1490c893d46f5f59bb3af313e917e3cb2b8999fac6afd6a5da7aef8619a0f432987f505b568127
6
+ metadata.gz: 3ce85e31052c0fa66eab3902c9a97b11a3644549a54d7bdcd177c85f6efbcfb2713301c919ce32b4ad3b7feecd382d5ddc40c847fb74f201c1512cedfb6228b4
7
+ data.tar.gz: 9de133859142bd82180e74193a659998d8cd97044ff86ed69e9e7dbc64fb19ccaaa1c4d09d644fbc041705edffc76bdc4e51941cda3d592181c975afa26c0f60
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  .env
2
+ .env.hubspot-dev
2
3
  .idea/
3
4
  .ruby-version
4
5
  coverage/*
data/CHANGELOG.md CHANGED
@@ -1,14 +1,28 @@
1
- ## 0.3.0
1
+ ## 0.3.1 (2023-07-05)
2
+
3
+ ### Features
4
+ * add missing context and legalConsentOptions to submission client
5
+
6
+ ### Breaking Changes
7
+ None
8
+
9
+ ## 0.3.0 (2023-07-03)
2
10
 
3
11
  ### Features
4
12
  * add client form, to get all forms
5
13
  * add client submission, to submit forms
6
14
 
15
+ ### Breaking Changes
16
+ None
17
+
7
18
  ## 0.2.1 (2022-12-07)
8
19
 
9
20
  ### Patch
10
21
  * only update writeable properties
11
22
 
23
+ ### Breaking Changes
24
+ None
25
+
12
26
  ## 0.2.0 (2022-12-02)
13
27
 
14
28
  ### Features
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hubspot_client (0.3.0)
4
+ hubspot_client (0.3.1)
5
5
  httparty (~> 0.20.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -137,13 +137,32 @@ The `fields` parameter is a list of objects with the following properties:
137
137
  ```ruby
138
138
  [
139
139
  {
140
- "objectTypeId": '0-1',
140
+ "objectTypeId": '0-1', # Optional
141
141
  "name": 'email',
142
142
  "value": 'darth_garllon@example.com'
143
143
  }
144
144
  ]
145
145
  ```
146
146
 
147
+ the `context` parameter is a hash of the following attributes:
148
+ ```ruby
149
+ {
150
+ "pageUri": 'https://example.com',
151
+ "pageName": 'Example page'
152
+ }
153
+ ```
154
+
155
+ The `leagalConsentOptions` parameter is a hash of the following attributes:
156
+ ```ruby
157
+ {
158
+ consent: {
159
+ consentToProcess: true,
160
+ text: "I agree to allow #{company_name} to store and process my personal data.",
161
+ communications: []
162
+ }
163
+ }
164
+ ```
165
+
147
166
  ## Development
148
167
 
149
168
  After checking out the repo, run
data/bin/console CHANGED
@@ -6,7 +6,15 @@ require 'hubspot_client'
6
6
  require 'dotenv'
7
7
  require 'pry'
8
8
 
9
- Dotenv.load
9
+ def load_environment_variables
10
+ env_file = ENV['ENV_FILE'] || '.env'
11
+ raise "#{env_file} not found" unless File.exist?(env_file)
12
+
13
+ puts "Loading `#{env_file}` file"
14
+ Dotenv.load(env_file)
15
+ end
16
+
17
+ load_environment_variables
10
18
 
11
19
  HubspotClient.configure do |config|
12
20
  config.access_token = ENV['ACCESS_TOKEN']
@@ -8,10 +8,28 @@ module HubspotClient
8
8
 
9
9
  BASE_PATH_V3 = '/submissions/v3/integration/secure/submit'
10
10
 
11
- def initialize(portal_id:, form_guid:, fields: [])
12
- @portal_id = portal_id
13
- @form_guid = form_guid
14
- @fields = fields
11
+ # EXAMPLES:
12
+ # fields: [{name: 'email', value: 'darth_garllon@example.com'}]
13
+ #
14
+ # context: {
15
+ # pageUri: "https://example.com",
16
+ # pageName: "Example page"
17
+ # }
18
+ #
19
+ # legal_consent_options: {
20
+ # consent: {
21
+ # consentToProcess: true,
22
+ # text: "I agree to allow #{company_name} to store and process my personal data.",
23
+ # communications: []
24
+ # }
25
+ # }
26
+
27
+ def initialize(portal_id:, form_guid:, fields: [], context: {}, legal_consent_options: {})
28
+ @portal_id = portal_id
29
+ @form_guid = form_guid
30
+ @fields = fields
31
+ @context = context
32
+ @legal_consent_options = legal_consent_options
15
33
  end
16
34
 
17
35
  def submit
@@ -23,7 +41,9 @@ module HubspotClient
23
41
 
24
42
  def body
25
43
  {
26
- "fields": @fields
44
+ fields: @fields,
45
+ context: @context,
46
+ legalConsentOptions: @legal_consent_options
27
47
  }
28
48
  end
29
49
 
@@ -19,7 +19,7 @@ module HubspotClient
19
19
 
20
20
  def update(new_properties = {})
21
21
  assign_attributes(new_properties)
22
- response = Client::Company.new.update(hs_object_id, to_h)
22
+ response = Client::Company.new.update(hs_object_id, to_h.slice(*writable_properties))
23
23
 
24
24
  return true if response.code == 200
25
25
 
@@ -40,6 +40,12 @@ module HubspotClient
40
40
  self[attribute] = value
41
41
  end
42
42
  end
43
+
44
+ private
45
+
46
+ def writable_properties
47
+ HubspotClient::Model::Property.writable_property_names_for('companies')
48
+ end
43
49
  end
44
50
  end
45
51
  end
@@ -25,7 +25,7 @@ module HubspotClient
25
25
 
26
26
  def update(new_properties = {})
27
27
  assign_attributes(new_properties)
28
- response = Client::Contact.new.update(hs_object_id, to_h)
28
+ response = Client::Contact.new.update(hs_object_id, to_h.slice(*writable_properties))
29
29
 
30
30
  return true if response.code == 200
31
31
 
@@ -70,6 +70,12 @@ module HubspotClient
70
70
  self[attribute] = value
71
71
  end
72
72
  end
73
+
74
+ private
75
+
76
+ def writable_properties
77
+ HubspotClient::Model::Property.writable_property_names_for('contacts')
78
+ end
73
79
  end
74
80
  end
75
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HubspotClient
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.1'
5
5
  end
@@ -12,6 +12,7 @@ require 'hubspot_client/configuration'
12
12
  require 'hubspot_client/model/communication_preference'
13
13
  require 'hubspot_client/model/company'
14
14
  require 'hubspot_client/model/contact'
15
+ require 'hubspot_client/model/property'
15
16
  require 'hubspot_client/version'
16
17
 
17
18
  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.3.0
4
+ version: 0.3.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: 2023-07-03 00:00:00.000000000 Z
12
+ date: 2023-07-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -186,6 +186,7 @@ files:
186
186
  - lib/hubspot_client/model/communication_preference.rb
187
187
  - lib/hubspot_client/model/company.rb
188
188
  - lib/hubspot_client/model/contact.rb
189
+ - lib/hubspot_client/model/property.rb
189
190
  - lib/hubspot_client/version.rb
190
191
  homepage: https://github.com/Farbfox/hubspot_client/blob/main/README.md
191
192
  licenses: