hubspot-api-client 14.3.0 → 14.4.0
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/CHANGELOG.md +5 -0
- data/Gemfile.lock +3 -3
- data/README.md +12 -0
- data/lib/hubspot/discovery/base_api_client.rb +14 -2
- data/lib/hubspot/version.rb +1 -1
- data/spec/discovery/base_api_client_spec.rb +33 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3229748b2d14e474894aecf5f28d60ae7ace8f5dda38d98daa34a2bbda93e033
|
4
|
+
data.tar.gz: 2867ef54025f5caa340e9ad28e7fafa940cb88bc8b11142b6f75d45df8e6829a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13932717d618997bff59721afe32a3480b30f579d299837d55f925cd1b47f300a70143245d954fadc14b8ca408587051abe355900310d34543e243ea866129a6
|
7
|
+
data.tar.gz: 59711b28a7e2b9fe86fe610434d4bcbb1065ece4812c5448e5856ba53fa77ba275eb6df9bfd24299fae494e98858ddfc94dbd5a4f29c51412be942a86d931d8f
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [14.4.0] - 2022-09-27
|
9
|
+
### Changed
|
10
|
+
|
11
|
+
- handling ApiError by passing a block
|
12
|
+
|
8
13
|
## [14.3.0] - 2022-08-31
|
9
14
|
### Changed
|
10
15
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hubspot-api-client (14.
|
4
|
+
hubspot-api-client (14.4.0)
|
5
5
|
json (~> 2.1, >= 2.1.0)
|
6
6
|
require_all (~> 3.0.0)
|
7
7
|
typhoeus (~> 1.4.0)
|
@@ -41,13 +41,13 @@ GEM
|
|
41
41
|
rspec-mocks (~> 3.11.0)
|
42
42
|
rspec-core (3.11.0)
|
43
43
|
rspec-support (~> 3.11.0)
|
44
|
-
rspec-expectations (3.11.
|
44
|
+
rspec-expectations (3.11.1)
|
45
45
|
diff-lcs (>= 1.2.0, < 2.0)
|
46
46
|
rspec-support (~> 3.11.0)
|
47
47
|
rspec-mocks (3.11.1)
|
48
48
|
diff-lcs (>= 1.2.0, < 2.0)
|
49
49
|
rspec-support (~> 3.11.0)
|
50
|
-
rspec-support (3.11.
|
50
|
+
rspec-support (3.11.1)
|
51
51
|
typhoeus (1.4.0)
|
52
52
|
ethon (>= 0.9.0)
|
53
53
|
vcr (3.0.3)
|
data/README.md
CHANGED
@@ -160,6 +160,18 @@ api_response = client.crm.schemas.core_api.create(body: body)
|
|
160
160
|
|
161
161
|
### Error handling
|
162
162
|
|
163
|
+
for new discovery classes since version 14.4
|
164
|
+
|
165
|
+
#### You can rescue an ApiError by passing a block to the method
|
166
|
+
|
167
|
+
```ruby
|
168
|
+
require 'hubspot-api-client'
|
169
|
+
|
170
|
+
client = Hubspot::Client.new(access_token: 'your_access_token')
|
171
|
+
|
172
|
+
contacts = client.crm.contacts.basic_api.get_page { |error| error.message }
|
173
|
+
```
|
174
|
+
|
163
175
|
#### You can set number of retry attempts and delay in seconds before retry on specific status code of response.
|
164
176
|
|
165
177
|
Available params:
|
@@ -48,13 +48,24 @@ module Hubspot
|
|
48
48
|
codegen_api_class.gsub(/(.*)::.*/, '\1')
|
49
49
|
end
|
50
50
|
|
51
|
+
def call_api(api_method, params_to_pass)
|
52
|
+
api.public_send(api_method, *params_to_pass)
|
53
|
+
end
|
54
|
+
|
55
|
+
def call_api_with_rescue(api_method, params_to_pass)
|
56
|
+
error = Kernel.const_get("#{codegen_module_name}::ApiError")
|
57
|
+
call_api(api_method, params_to_pass)
|
58
|
+
rescue error => e
|
59
|
+
yield(e)
|
60
|
+
end
|
61
|
+
|
51
62
|
def define_methods
|
52
63
|
define_api_methods
|
53
64
|
end
|
54
65
|
|
55
66
|
def define_api_methods
|
56
67
|
api_methods.each do |api_method|
|
57
|
-
self.class.define_method(api_method) do |params = {}|
|
68
|
+
self.class.define_method(api_method) do |params = {}, &block|
|
58
69
|
params_with_defaults = params
|
59
70
|
params_with_defaults[:opts] ||= {}
|
60
71
|
params_with_defaults[:opts][:auth_names] = if base_params[:access_token]
|
@@ -83,7 +94,8 @@ module Hubspot
|
|
83
94
|
params_with_defaults[param]
|
84
95
|
end
|
85
96
|
|
86
|
-
|
97
|
+
return call_api_with_rescue(api_method, params_to_pass, &block) unless block.nil?
|
98
|
+
call_api(api_method, params_to_pass)
|
87
99
|
end
|
88
100
|
end
|
89
101
|
end
|
data/lib/hubspot/version.rb
CHANGED
@@ -22,6 +22,13 @@ describe 'Hubspot::Discovery::BaseApiClient' do
|
|
22
22
|
|
23
23
|
def update_with_http_info
|
24
24
|
end
|
25
|
+
|
26
|
+
def raise_error
|
27
|
+
raise Hubspot::ApiError
|
28
|
+
end
|
29
|
+
|
30
|
+
def raise_error_with_http_info
|
31
|
+
end
|
25
32
|
end
|
26
33
|
|
27
34
|
class Hubspot::ApiClient
|
@@ -29,6 +36,12 @@ describe 'Hubspot::Discovery::BaseApiClient' do
|
|
29
36
|
end
|
30
37
|
end
|
31
38
|
|
39
|
+
class Hubspot::ApiError < ::StandardError
|
40
|
+
def message
|
41
|
+
'test error'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
32
45
|
class Hubspot::SimplePublicObjectInput
|
33
46
|
attr_reader :name, :email
|
34
47
|
|
@@ -65,6 +78,13 @@ describe 'Hubspot::Discovery::BaseApiClient' do
|
|
65
78
|
|
66
79
|
it { is_expected.to eq('got test_id: test_id_value, opts: {:auth_names=>"oauth2", :limit=>5}') }
|
67
80
|
end
|
81
|
+
|
82
|
+
context 'with error handle block' do
|
83
|
+
subject(:get) { client.get(params) { |e| e.message } }
|
84
|
+
let(:params) { {test_id: 'test_id_value', limit: 10} }
|
85
|
+
|
86
|
+
it { is_expected.to eq('got test_id: test_id_value, opts: {:auth_names=>"oauth2", :limit=>10}') }
|
87
|
+
end
|
68
88
|
end
|
69
89
|
|
70
90
|
describe '#update' do
|
@@ -93,5 +113,18 @@ describe 'Hubspot::Discovery::BaseApiClient' do
|
|
93
113
|
|
94
114
|
it { is_expected.to eq('updated test_id: test_id_value, name: test_name, email: test_email, opts: {:auth_names=>"oauth2", :limit=>10}') }
|
95
115
|
end
|
116
|
+
|
117
|
+
context 'with block' do
|
118
|
+
subject(:update) { client.update(params) { |e| e.message } }
|
119
|
+
let(:params) { {test_id: 'test_id_value', body: body, limit: 10} }
|
120
|
+
|
121
|
+
it { is_expected.to eq('updated test_id: test_id_value, name: test_name, email: test_email, opts: {:auth_names=>"oauth2", :limit=>10}') }
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe '#raise_error' do
|
126
|
+
subject(:raise_error) { client.raise_error { |e| e.message } }
|
127
|
+
|
128
|
+
it { is_expected.to eq('test error') }
|
96
129
|
end
|
97
130
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hubspot-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 14.
|
4
|
+
version: 14.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HubSpot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|