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 +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +15 -1
- data/Gemfile.lock +1 -1
- data/README.md +20 -1
- data/bin/console +9 -1
- data/lib/hubspot_client/client/submission.rb +25 -5
- data/lib/hubspot_client/model/company.rb +7 -1
- data/lib/hubspot_client/model/contact.rb +7 -1
- data/lib/hubspot_client/model/property.rb +19 -0
- data/lib/hubspot_client/version.rb +1 -1
- data/lib/hubspot_client.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d32c26caa7aef52958e69b0e2d39e817a3f7bc3040588047cf87a971e368624c
|
4
|
+
data.tar.gz: d9eb9948cefd4c32be3dd6a063a066f19585a787460eb1497bf440c798f35297
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ce85e31052c0fa66eab3902c9a97b11a3644549a54d7bdcd177c85f6efbcfb2713301c919ce32b4ad3b7feecd382d5ddc40c847fb74f201c1512cedfb6228b4
|
7
|
+
data.tar.gz: 9de133859142bd82180e74193a659998d8cd97044ff86ed69e9e7dbc64fb19ccaaa1c4d09d644fbc041705edffc76bdc4e51941cda3d592181c975afa26c0f60
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,28 @@
|
|
1
|
-
## 0.3.
|
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
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
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
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
|
data/lib/hubspot_client.rb
CHANGED
@@ -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.
|
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-
|
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:
|