hubspot-api-client 14.2.0 → 14.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +41 -0
- data/lib/hubspot/discovery/base_api_client.rb +12 -2
- data/lib/hubspot/version.rb +1 -1
- data/spec/discovery/base_api_client_spec.rb +27 -7
- 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: bab00d972a316aadaced5d712c7abe5d86ddab1236caa123a8b44d0b9cfcfeac
|
4
|
+
data.tar.gz: 9ed639a810e45d0601188e0b56b102a71a51312580aa7f12ceca3a0ba5ea291d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d478dd41e3b787640f72f395b6a7c79e7e05819c2ed507fe03a2594b190345b0c31b57299a15ceac472bd1b6ad0ce065c40cd57c41fc040f8e981aae0b7c67df
|
7
|
+
data.tar.gz: 469b1fe3d0660baf67e66e44fbcbb0968292038663bd1918312bcb123de055bcaf24178e0fe95b1a29885f06ae34a88310251669d7d9efa6649049822c26de91
|
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.3.0] - 2022-08-31
|
9
|
+
### Changed
|
10
|
+
|
11
|
+
- using hash instead of model object for Hubspot::Client with body param
|
12
|
+
|
8
13
|
## [14.2.0] - 2022-08-25
|
9
14
|
### Changed
|
10
15
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -116,6 +116,47 @@ object_schema_egg = ::Hubspot::Crm::Schemas::ObjectSchemaEgg.new(
|
|
116
116
|
api_response = api.create(object_schema_egg)
|
117
117
|
```
|
118
118
|
|
119
|
+
for new discovery classes since version 14.3
|
120
|
+
```ruby
|
121
|
+
client = Hubspot::Client.new(access_token: 'your_oauth2_access_token')
|
122
|
+
|
123
|
+
labels = {
|
124
|
+
singular: 'My object',
|
125
|
+
plural: 'My objects'
|
126
|
+
}
|
127
|
+
|
128
|
+
option = {
|
129
|
+
label: 'Option A',
|
130
|
+
value: 'A',
|
131
|
+
description: 'Choice number one',
|
132
|
+
display_order: 1,
|
133
|
+
hidden: false
|
134
|
+
}
|
135
|
+
|
136
|
+
property = {
|
137
|
+
name: 'property001',
|
138
|
+
label: 'My object property',
|
139
|
+
group_name: 'my_object_information',
|
140
|
+
options: [option],
|
141
|
+
display_order: 2,
|
142
|
+
type: 'enumeration',
|
143
|
+
field_type: 'select'
|
144
|
+
}
|
145
|
+
|
146
|
+
body = {
|
147
|
+
labels: labels,
|
148
|
+
required_properties: ['property001'],
|
149
|
+
searchable_properties: [],
|
150
|
+
primary_display_property: 'property001',
|
151
|
+
secondary_display_properties: [],
|
152
|
+
properties: [property],
|
153
|
+
associated_objects: ['CONTACT'],
|
154
|
+
name: 'my_object'
|
155
|
+
}
|
156
|
+
|
157
|
+
api_response = client.crm.schemas.core_api.create(body: body)
|
158
|
+
```
|
159
|
+
|
119
160
|
|
120
161
|
### Error handling
|
121
162
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require_rel '../helpers/camel_case'
|
2
|
+
|
1
3
|
module Hubspot
|
2
4
|
module Discovery
|
3
5
|
module BaseApiClient
|
@@ -17,7 +19,7 @@ module Hubspot
|
|
17
19
|
end
|
18
20
|
|
19
21
|
def api_client
|
20
|
-
@api_client ||= Kernel.const_get("#{
|
22
|
+
@api_client ||= Kernel.const_get("#{codegen_module_name}::ApiClient").new(config)
|
21
23
|
end
|
22
24
|
|
23
25
|
def api
|
@@ -42,6 +44,10 @@ module Hubspot
|
|
42
44
|
self.class.name.gsub('Discovery::', '')
|
43
45
|
end
|
44
46
|
|
47
|
+
def codegen_module_name
|
48
|
+
codegen_api_class.gsub(/(.*)::.*/, '\1')
|
49
|
+
end
|
50
|
+
|
45
51
|
def define_methods
|
46
52
|
define_api_methods
|
47
53
|
end
|
@@ -65,11 +71,15 @@ module Hubspot
|
|
65
71
|
|
66
72
|
signature_param_names = signature_params.map { |_, param| param }
|
67
73
|
params_with_defaults.each do |param_name, param_value|
|
68
|
-
params_with_defaults[:opts][param_name] = param_value
|
74
|
+
params_with_defaults[:opts][param_name] = param_value if !signature_param_names.include?(param_name) && param_name != :body
|
69
75
|
end
|
70
76
|
|
71
77
|
params_to_pass = signature_params.map do |req, param|
|
78
|
+
model_name = Hubspot::Helpers::CamelCase.new.format(param.to_s)
|
79
|
+
Kernel.const_get("#{codegen_module_name}::#{model_name}").build_from_hash(params_with_defaults[:body])
|
80
|
+
rescue NameError
|
72
81
|
raise "Param #{param} is required for #{api.class}\##{api_method} method" if req == :req && params_with_defaults[param].nil?
|
82
|
+
|
73
83
|
params_with_defaults[param]
|
74
84
|
end
|
75
85
|
|
data/lib/hubspot/version.rb
CHANGED
@@ -17,7 +17,7 @@ describe 'Hubspot::Discovery::BaseApiClient' do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def update(test_id, simple_public_object_input, opts = {})
|
20
|
-
"updated test_id: #{test_id}, simple_public_object_input: #{simple_public_object_input}, opts: #{opts}"
|
20
|
+
"updated test_id: #{test_id}, name: #{simple_public_object_input.name}, email: #{simple_public_object_input.email}, opts: #{opts}"
|
21
21
|
end
|
22
22
|
|
23
23
|
def update_with_http_info
|
@@ -29,8 +29,22 @@ describe 'Hubspot::Discovery::BaseApiClient' do
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
class Hubspot::SimplePublicObjectInput
|
33
|
+
attr_reader :name, :email
|
34
|
+
|
35
|
+
def initialize(params)
|
36
|
+
@name = params[:name]
|
37
|
+
@email = params[:email]
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.build_from_hash(params)
|
41
|
+
new(params)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
32
45
|
subject(:client) { Hubspot::Discovery::SomeApiClass.new(access_token: 'test') }
|
33
46
|
let(:api) { client.api }
|
47
|
+
let(:body) { {name: 'test_name', email: 'test_email'} }
|
34
48
|
|
35
49
|
it { is_expected.to respond_to(:get) }
|
36
50
|
it { is_expected.to respond_to(:update) }
|
@@ -57,21 +71,27 @@ describe 'Hubspot::Discovery::BaseApiClient' do
|
|
57
71
|
subject(:update) { client.update(params) }
|
58
72
|
|
59
73
|
context 'with default params order' do
|
60
|
-
let(:params) { {test_id: 'test_id_value', simple_public_object_input:
|
74
|
+
let(:params) { {test_id: 'test_id_value', simple_public_object_input: Hubspot::SimplePublicObjectInput.new(body), limit: 10} }
|
61
75
|
|
62
|
-
it { is_expected.to eq('updated test_id: test_id_value,
|
76
|
+
it { is_expected.to eq('updated test_id: test_id_value, name: test_name, email: test_email, opts: {:auth_names=>"oauth2", :limit=>10}') }
|
63
77
|
end
|
64
78
|
|
65
79
|
context 'with reversed params order' do
|
66
|
-
let(:params) { {limit: 5, simple_public_object_input:
|
80
|
+
let(:params) { {limit: 5, simple_public_object_input: Hubspot::SimplePublicObjectInput.new(body), test_id: 'test_id_value'} }
|
67
81
|
|
68
|
-
it { is_expected.to eq('updated test_id: test_id_value,
|
82
|
+
it { is_expected.to eq('updated test_id: test_id_value, name: test_name, email: test_email, opts: {:auth_names=>"oauth2", :limit=>5}') }
|
69
83
|
end
|
70
84
|
|
71
85
|
context 'with shuffled params order' do
|
72
|
-
let(:params) { {simple_public_object_input:
|
86
|
+
let(:params) { {simple_public_object_input: Hubspot::SimplePublicObjectInput.new(body), limit: 7, test_id: 'test_id_value'} }
|
73
87
|
|
74
|
-
it { is_expected.to eq('updated test_id: test_id_value,
|
88
|
+
it { is_expected.to eq('updated test_id: test_id_value, name: test_name, email: test_email, opts: {:auth_names=>"oauth2", :limit=>7}') }
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'with body' do
|
92
|
+
let(:params) { {test_id: 'test_id_value', body: body, limit: 10} }
|
93
|
+
|
94
|
+
it { is_expected.to eq('updated test_id: test_id_value, name: test_name, email: test_email, opts: {:auth_names=>"oauth2", :limit=>10}') }
|
75
95
|
end
|
76
96
|
end
|
77
97
|
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.3.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-08-
|
11
|
+
date: 2022-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|