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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4cf7152f7d94654ae7efaef840fc2232392091973642e5b6a877358d665c687
4
- data.tar.gz: 7f9b630bc30d894300a8317f170583c1179684f3915f50055821e63fe892bcb4
3
+ metadata.gz: bab00d972a316aadaced5d712c7abe5d86ddab1236caa123a8b44d0b9cfcfeac
4
+ data.tar.gz: 9ed639a810e45d0601188e0b56b102a71a51312580aa7f12ceca3a0ba5ea291d
5
5
  SHA512:
6
- metadata.gz: 4a22483996355e355ca0efe55b88d83a66f704936920a64287c05e175a9348a1039acdf6652f3811a380a31c6aceda9be648768b25e9e807035e3e051b1699ba
7
- data.tar.gz: 4ba24e78d4f838a817c96a8bd8b3681809d50a2a886dab6b078090423239421794917b79de0eb17e8bfe91b735ac4bfa42a3e66633bef5dfeebb760d98c02cc0
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hubspot-api-client (14.2.0)
4
+ hubspot-api-client (14.3.0)
5
5
  json (~> 2.1, >= 2.1.0)
6
6
  require_all (~> 3.0.0)
7
7
  typhoeus (~> 1.4.0)
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("#{self.class.name.gsub('Discovery::', '').gsub(/(.*)::.*/, '\1')}::ApiClient").new(config)
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 unless signature_param_names.include?(param_name)
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
 
@@ -1,3 +1,3 @@
1
1
  module Hubspot
2
- VERSION = '14.2.0'
2
+ VERSION = '14.3.0'
3
3
  end
@@ -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: 'simple_public_object_input_value', limit: 10} }
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, simple_public_object_input: simple_public_object_input_value, opts: {:auth_names=>"oauth2", :limit=>10}') }
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: 'simple_public_object_input_value', test_id: 'test_id_value'} }
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, simple_public_object_input: simple_public_object_input_value, opts: {:auth_names=>"oauth2", :limit=>5}') }
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: 'simple_public_object_input_value', limit: 7, test_id: 'test_id_value'} }
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, simple_public_object_input: simple_public_object_input_value, opts: {:auth_names=>"oauth2", :limit=>7}') }
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.2.0
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-25 00:00:00.000000000 Z
11
+ date: 2022-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus