hubspot_client 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +60 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +20 -0
- data/Gemfile.lock +9 -1
- data/README.md +32 -2
- data/hubspot_client.gemspec +1 -0
- data/lib/hubspot_client/client/form.rb +22 -0
- data/lib/hubspot_client/client/submission.rb +36 -0
- data/lib/hubspot_client/version.rb +1 -1
- data/lib/hubspot_client.rb +2 -0
- metadata +19 -3
- data/.github/workflows/rspec_and_rubocop.yml +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5904fbc990f2c806e61e911eba497a18c8d5edd447bf037e7645b67c996316e
|
4
|
+
data.tar.gz: 37c4de7c938ae280b5c33f184eb2bdc8c4c86aab769aeed3c55223f64a66cf26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 285786683544164c349a56e2dbfc14ffdaff18f073aaf6e409daa0dc5c12a892f5ffffc0e7607b31f0ae8a85a77e542d25edd69576411f61f6cb18033a510d9e
|
7
|
+
data.tar.gz: 13a19aa59a459dfa3b50e3a2314e89f9d611fea3a2a56d862c1490c893d46f5f59bb3af313e917e3cb2b8999fac6afd6a5da7aef8619a0f432987f505b568127
|
@@ -0,0 +1,60 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
rspec:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
ruby: ['3.0', '3.1', '3.2']
|
11
|
+
name: "ruby ${{ matrix.ruby }}"
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v3
|
15
|
+
- uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: ${{ matrix.ruby }}
|
18
|
+
- name: Bundle install
|
19
|
+
run: |
|
20
|
+
gem install bundler
|
21
|
+
bundle install
|
22
|
+
- name: Run RSpec
|
23
|
+
run: |
|
24
|
+
bundle exec rspec
|
25
|
+
|
26
|
+
rubocop:
|
27
|
+
runs-on: ubuntu-latest
|
28
|
+
steps:
|
29
|
+
- uses: actions/checkout@v3
|
30
|
+
- uses: ruby/setup-ruby@v1
|
31
|
+
with:
|
32
|
+
ruby-version: 3.1
|
33
|
+
- name: Bundle install
|
34
|
+
run: |
|
35
|
+
gem install bundler
|
36
|
+
bundle install
|
37
|
+
- name: Run rubocop
|
38
|
+
run: |
|
39
|
+
bundle exec rubocop
|
40
|
+
coverage:
|
41
|
+
name: coverage
|
42
|
+
runs-on: ubuntu-latest
|
43
|
+
steps:
|
44
|
+
- uses: actions/checkout@v1
|
45
|
+
- uses: ruby/setup-ruby@v1
|
46
|
+
with:
|
47
|
+
ruby-version: 3.1
|
48
|
+
- name: Setup Code Climate test-reporter
|
49
|
+
run: |
|
50
|
+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
51
|
+
chmod +x ./cc-test-reporter
|
52
|
+
./cc-test-reporter before-build
|
53
|
+
- name: Build and test with RSpec
|
54
|
+
run: |
|
55
|
+
gem install bundler
|
56
|
+
bundle install
|
57
|
+
bundle exec rspec
|
58
|
+
- name: Publish code coverage
|
59
|
+
run: |
|
60
|
+
./cc-test-reporter after-build -r ${{ secrets.CC_TEST_REPORTER_ID }}
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
## 0.3.0
|
2
|
+
|
3
|
+
### Features
|
4
|
+
* add client form, to get all forms
|
5
|
+
* add client submission, to submit forms
|
6
|
+
|
7
|
+
## 0.2.1 (2022-12-07)
|
8
|
+
|
9
|
+
### Patch
|
10
|
+
* only update writeable properties
|
11
|
+
|
12
|
+
## 0.2.0 (2022-12-02)
|
13
|
+
|
14
|
+
### Features
|
15
|
+
* Show response body, if the request was not successfully.
|
16
|
+
* Remove whitelist updatable_properties
|
17
|
+
|
18
|
+
### Breaking Changes
|
19
|
+
None
|
20
|
+
|
1
21
|
## 0.1.0 (2022-11-30)
|
2
22
|
|
3
23
|
### Features
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hubspot_client (0.
|
4
|
+
hubspot_client (0.3.0)
|
5
5
|
httparty (~> 0.20.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -14,6 +14,7 @@ GEM
|
|
14
14
|
crack (0.4.5)
|
15
15
|
rexml
|
16
16
|
diff-lcs (1.5.0)
|
17
|
+
docile (1.4.0)
|
17
18
|
dotenv (2.8.1)
|
18
19
|
hashdiff (1.0.1)
|
19
20
|
httparty (0.20.0)
|
@@ -63,6 +64,12 @@ GEM
|
|
63
64
|
rubocop-rspec (2.15.0)
|
64
65
|
rubocop (~> 1.33)
|
65
66
|
ruby-progressbar (1.11.0)
|
67
|
+
simplecov (0.22.0)
|
68
|
+
docile (~> 1.1)
|
69
|
+
simplecov-html (~> 0.11)
|
70
|
+
simplecov_json_formatter (~> 0.1)
|
71
|
+
simplecov-html (0.12.3)
|
72
|
+
simplecov_json_formatter (0.1.4)
|
66
73
|
unicode-display_width (2.3.0)
|
67
74
|
vcr (6.1.0)
|
68
75
|
webmock (3.18.1)
|
@@ -81,6 +88,7 @@ DEPENDENCIES
|
|
81
88
|
rspec (~> 3.12)
|
82
89
|
rubocop (~> 1.39)
|
83
90
|
rubocop-rspec (~> 2.15)
|
91
|
+
simplecov (~> 0.22.0)
|
84
92
|
vcr (~> 6.1)
|
85
93
|
webmock (~> 3.18)
|
86
94
|
|
data/README.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
|
2
2
|
# HubspotClient
|
3
3
|
|
4
|
+
[](https://badge.fury.io/rb/hubspot_client)
|
6
|
+
[](https://github.com/Farbfox/hubspot_client/actions/workflows/ci.yml)
|
7
|
+
[](https://codeclimate.com/github/Farbfox/hubspot_client/maintainability)
|
8
|
+
[](https://codeclimate.com/github/Farbfox/hubspot_client/test_coverage)
|
9
|
+
|
4
10
|
A Hubspot Client. Currently we only support the following CRM Parts:
|
5
11
|
* Contact
|
6
12
|
* Company
|
@@ -108,12 +114,36 @@ hubspot_company.update
|
|
108
114
|
hubspot_company.update({ name: 'Blubber' })
|
109
115
|
```
|
110
116
|
|
111
|
-
|
112
|
-
|
113
117
|
### Communication-Preference
|
114
118
|
|
115
119
|
[Hubspot- API](https://developers.hubspot.com/docs/api/marketing-api/subscriptions-preferences)
|
116
120
|
|
121
|
+
## Clients
|
122
|
+
|
123
|
+
Clients are normally under the hood of models. However you can use them directly if you like.
|
124
|
+
|
125
|
+
### Submission
|
126
|
+
|
127
|
+
[forms/submit_form_v3_authentication](https://legacydocs.hubspot.com/docs/methods/forms/submit_form_v3_authentication#:~:text=As%20this%20API%20is%20authenticated%2C)
|
128
|
+
|
129
|
+
With the `HubspotClient::Client::Form.all_forms` method you can get all forms from your hubspot instance.
|
130
|
+
Checkout which fields you need.
|
131
|
+
|
132
|
+
```ruby
|
133
|
+
HubspotClient::Client::Submission.new(portal_id: '1337', form_guid: '1337', fields: fields).submit
|
134
|
+
```
|
135
|
+
|
136
|
+
The `fields` parameter is a list of objects with the following properties:
|
137
|
+
```ruby
|
138
|
+
[
|
139
|
+
{
|
140
|
+
"objectTypeId": '0-1',
|
141
|
+
"name": 'email',
|
142
|
+
"value": 'darth_garllon@example.com'
|
143
|
+
}
|
144
|
+
]
|
145
|
+
```
|
146
|
+
|
117
147
|
## Development
|
118
148
|
|
119
149
|
After checking out the repo, run
|
data/hubspot_client.gemspec
CHANGED
@@ -39,6 +39,7 @@ Gem::Specification.new do |spec|
|
|
39
39
|
spec.add_development_dependency 'rspec', '~> 3.12'
|
40
40
|
spec.add_development_dependency 'rubocop', '~> 1.39'
|
41
41
|
spec.add_development_dependency 'rubocop-rspec', '~> 2.15'
|
42
|
+
spec.add_development_dependency 'simplecov', '~> 0.22.0'
|
42
43
|
spec.add_development_dependency 'vcr', '~> 6.1'
|
43
44
|
spec.add_development_dependency 'webmock', '~> 3.18'
|
44
45
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HubspotClient
|
4
|
+
module Client
|
5
|
+
class Form
|
6
|
+
include HTTParty
|
7
|
+
base_uri 'https://api.hubapi.com'
|
8
|
+
|
9
|
+
BASE_PATH_V3 = '/marketing/v3/forms/'
|
10
|
+
|
11
|
+
def self.all_forms(limit: 20)
|
12
|
+
url = "#{BASE_PATH_V3}?limit=#{limit}"
|
13
|
+
get(url, headers: headers)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.headers
|
17
|
+
{ Authorization: "Bearer #{HubspotClient.configuration.access_token}",
|
18
|
+
'Content-Type': 'application/json' }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HubspotClient
|
4
|
+
module Client
|
5
|
+
class Submission
|
6
|
+
include HTTParty
|
7
|
+
base_uri 'https://api.hsforms.com'
|
8
|
+
|
9
|
+
BASE_PATH_V3 = '/submissions/v3/integration/secure/submit'
|
10
|
+
|
11
|
+
def initialize(portal_id:, form_guid:, fields: [])
|
12
|
+
@portal_id = portal_id
|
13
|
+
@form_guid = form_guid
|
14
|
+
@fields = fields
|
15
|
+
end
|
16
|
+
|
17
|
+
def submit
|
18
|
+
url = "#{BASE_PATH_V3}/#{@portal_id}/#{@form_guid}"
|
19
|
+
self.class.post(url, body: body.to_json, headers: headers)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def body
|
25
|
+
{
|
26
|
+
"fields": @fields
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def headers
|
31
|
+
{ Authorization: "Bearer #{HubspotClient.configuration.access_token}",
|
32
|
+
'Content-Type': 'application/json' }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/hubspot_client.rb
CHANGED
@@ -5,7 +5,9 @@ require 'hubspot_client/client_base_error'
|
|
5
5
|
require 'hubspot_client/client/communication_preference'
|
6
6
|
require 'hubspot_client/client/company'
|
7
7
|
require 'hubspot_client/client/contact'
|
8
|
+
require 'hubspot_client/client/form'
|
8
9
|
require 'hubspot_client/client/properties'
|
10
|
+
require 'hubspot_client/client/submission'
|
9
11
|
require 'hubspot_client/configuration'
|
10
12
|
require 'hubspot_client/model/communication_preference'
|
11
13
|
require 'hubspot_client/model/company'
|
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.3.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:
|
12
|
+
date: 2023-07-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -115,6 +115,20 @@ dependencies:
|
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '2.15'
|
118
|
+
- !ruby/object:Gem::Dependency
|
119
|
+
name: simplecov
|
120
|
+
requirement: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.22.0
|
125
|
+
type: :development
|
126
|
+
prerelease: false
|
127
|
+
version_requirements: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.22.0
|
118
132
|
- !ruby/object:Gem::Dependency
|
119
133
|
name: vcr
|
120
134
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,7 +165,7 @@ executables: []
|
|
151
165
|
extensions: []
|
152
166
|
extra_rdoc_files: []
|
153
167
|
files:
|
154
|
-
- ".github/workflows/
|
168
|
+
- ".github/workflows/ci.yml"
|
155
169
|
- ".gitignore"
|
156
170
|
- ".rubocop.yml"
|
157
171
|
- CHANGELOG.md
|
@@ -164,7 +178,9 @@ files:
|
|
164
178
|
- lib/hubspot_client/client/communication_preference.rb
|
165
179
|
- lib/hubspot_client/client/company.rb
|
166
180
|
- lib/hubspot_client/client/contact.rb
|
181
|
+
- lib/hubspot_client/client/form.rb
|
167
182
|
- lib/hubspot_client/client/properties.rb
|
183
|
+
- lib/hubspot_client/client/submission.rb
|
168
184
|
- lib/hubspot_client/client_base_error.rb
|
169
185
|
- lib/hubspot_client/configuration.rb
|
170
186
|
- lib/hubspot_client/model/communication_preference.rb
|
@@ -1,41 +0,0 @@
|
|
1
|
-
name: Rspec and Rubocop
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches-ignore:
|
6
|
-
- 'main'
|
7
|
-
jobs:
|
8
|
-
rspec:
|
9
|
-
runs-on: ubuntu-latest
|
10
|
-
strategy:
|
11
|
-
matrix:
|
12
|
-
ruby: ['3.0', '3.1']
|
13
|
-
name: "ruby ${{ matrix.ruby }}"
|
14
|
-
|
15
|
-
steps:
|
16
|
-
- uses: actions/checkout@v3
|
17
|
-
- uses: ruby/setup-ruby@v1
|
18
|
-
with:
|
19
|
-
ruby-version: ${{ matrix.ruby }}
|
20
|
-
- name: Bundle install
|
21
|
-
run: |
|
22
|
-
gem install bundler
|
23
|
-
bundle install
|
24
|
-
- name: Run RSpec
|
25
|
-
run: |
|
26
|
-
bundle exec rspec
|
27
|
-
|
28
|
-
rubocop:
|
29
|
-
runs-on: ubuntu-latest
|
30
|
-
steps:
|
31
|
-
- uses: actions/checkout@v3
|
32
|
-
- uses: ruby/setup-ruby@v1
|
33
|
-
with:
|
34
|
-
ruby-version: 3.1
|
35
|
-
- name: Bundle install
|
36
|
-
run: |
|
37
|
-
gem install bundler
|
38
|
-
bundle install
|
39
|
-
- name: Run rubocop
|
40
|
-
run: |
|
41
|
-
bundle exec rubocop
|