hubspot-api-client 14.0.0 → 14.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/Gemfile.lock +5 -5
  4. data/README.md +41 -0
  5. data/lib/hubspot/client.rb +0 -18
  6. data/lib/hubspot/codegen/automation/actions/api_error.rb +1 -1
  7. data/lib/hubspot/codegen/cms/audit-logs/api_error.rb +1 -1
  8. data/lib/hubspot/codegen/cms/blogs/authors/api_error.rb +1 -1
  9. data/lib/hubspot/codegen/cms/blogs/blog-posts/api_error.rb +1 -1
  10. data/lib/hubspot/codegen/cms/blogs/tags/api_error.rb +1 -1
  11. data/lib/hubspot/codegen/cms/domains/api_error.rb +1 -1
  12. data/lib/hubspot/codegen/cms/hubdb/api_error.rb +1 -1
  13. data/lib/hubspot/codegen/cms/performance/api_error.rb +1 -1
  14. data/lib/hubspot/codegen/cms/site-search/api_error.rb +1 -1
  15. data/lib/hubspot/codegen/cms/source-code/api_error.rb +1 -1
  16. data/lib/hubspot/codegen/cms/url-redirects/api_error.rb +1 -1
  17. data/lib/hubspot/codegen/communication_preferences/api_error.rb +1 -1
  18. data/lib/hubspot/codegen/conversations/visitor-identification/api_error.rb +1 -1
  19. data/lib/hubspot/codegen/crm/associations/api_error.rb +1 -1
  20. data/lib/hubspot/codegen/crm/companies/api_error.rb +1 -1
  21. data/lib/hubspot/codegen/crm/contacts/api_error.rb +1 -1
  22. data/lib/hubspot/codegen/crm/deals/api_error.rb +1 -1
  23. data/lib/hubspot/codegen/crm/extensions/accounting/api_error.rb +1 -1
  24. data/lib/hubspot/codegen/crm/extensions/calling/api_error.rb +1 -1
  25. data/lib/hubspot/codegen/crm/extensions/cards/api_error.rb +1 -1
  26. data/lib/hubspot/codegen/crm/extensions/videoconferencing/api_error.rb +1 -1
  27. data/lib/hubspot/codegen/crm/imports/api_error.rb +1 -1
  28. data/lib/hubspot/codegen/crm/line_items/api_error.rb +1 -1
  29. data/lib/hubspot/codegen/crm/objects/api_error.rb +1 -1
  30. data/lib/hubspot/codegen/crm/objects/calls/api_error.rb +1 -1
  31. data/lib/hubspot/codegen/crm/objects/emails/api_error.rb +1 -1
  32. data/lib/hubspot/codegen/crm/objects/feedback_submissions/api/associations_api.rb +3 -3
  33. data/lib/hubspot/codegen/crm/objects/feedback_submissions/api/basic_api.rb +5 -5
  34. data/lib/hubspot/codegen/crm/objects/feedback_submissions/api/batch_api.rb +4 -4
  35. data/lib/hubspot/codegen/crm/objects/feedback_submissions/api/public_object_api.rb +1 -1
  36. data/lib/hubspot/codegen/crm/objects/feedback_submissions/api/search_api.rb +1 -1
  37. data/lib/hubspot/codegen/crm/objects/feedback_submissions/api_error.rb +1 -1
  38. data/lib/hubspot/codegen/crm/objects/feedback_submissions/configuration.rb +7 -0
  39. data/lib/hubspot/codegen/crm/objects/meetings/api_error.rb +1 -1
  40. data/lib/hubspot/codegen/crm/objects/notes/api_error.rb +1 -1
  41. data/lib/hubspot/codegen/crm/objects/tasks/api_error.rb +1 -1
  42. data/lib/hubspot/codegen/crm/owners/api_error.rb +1 -1
  43. data/lib/hubspot/codegen/crm/pipelines/api_error.rb +1 -1
  44. data/lib/hubspot/codegen/crm/products/api_error.rb +1 -1
  45. data/lib/hubspot/codegen/crm/properties/api_error.rb +1 -1
  46. data/lib/hubspot/codegen/crm/quotes/api_error.rb +1 -1
  47. data/lib/hubspot/codegen/crm/schemas/api_error.rb +1 -1
  48. data/lib/hubspot/codegen/crm/tickets/api_error.rb +1 -1
  49. data/lib/hubspot/codegen/crm/timeline/api_error.rb +1 -1
  50. data/lib/hubspot/codegen/events/api_error.rb +1 -1
  51. data/lib/hubspot/codegen/files/files/api_error.rb +1 -1
  52. data/lib/hubspot/codegen/marketing/events/api_error.rb +1 -1
  53. data/lib/hubspot/codegen/marketing/forms/api_error.rb +1 -1
  54. data/lib/hubspot/codegen/marketing/transactional/api_error.rb +1 -1
  55. data/lib/hubspot/codegen/oauth/api_error.rb +1 -1
  56. data/lib/hubspot/codegen/settings/users/api_error.rb +1 -1
  57. data/lib/hubspot/codegen/webhooks/api_error.rb +1 -1
  58. data/lib/hubspot/discovery/base_api_client.rb +25 -3
  59. data/lib/hubspot/version.rb +1 -1
  60. data/spec/discovery/base_api_client_spec.rb +35 -7
  61. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 134361b7d051362baa33c291832d7671ca44ef8edb38dfc9e86fe25ad6ada34e
4
- data.tar.gz: 147e7343c303e82963193fa22d9f81ca955d61578fa07ff7939e094e71034356
3
+ metadata.gz: bab00d972a316aadaced5d712c7abe5d86ddab1236caa123a8b44d0b9cfcfeac
4
+ data.tar.gz: 9ed639a810e45d0601188e0b56b102a71a51312580aa7f12ceca3a0ba5ea291d
5
5
  SHA512:
6
- metadata.gz: ce0a04af94a5a22d5edd2ba5a2f4dff3c2d951e738e154568f99234e990bb558345a587d2af25b93f22f2e2f0f8dcf24a389322d2678437a05cb702ba4f9697b
7
- data.tar.gz: 8489ddafbf060f36e142af2bbd5a88c331c441c7df644e512dbc3b4699f61c53f79ef155562a100ac0053bad6b4513c2d0b7eca3f3d0004d044b1fef7484bc6c
6
+ metadata.gz: d478dd41e3b787640f72f395b6a7c79e7e05819c2ed507fe03a2594b190345b0c31b57299a15ceac472bd1b6ad0ce065c40cd57c41fc040f8e981aae0b7c67df
7
+ data.tar.gz: 469b1fe3d0660baf67e66e44fbcbb0968292038663bd1918312bcb123de055bcaf24178e0fe95b1a29885f06ae34a88310251669d7d9efa6649049822c26de91
data/CHANGELOG.md CHANGED
@@ -5,6 +5,21 @@ 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
+
13
+ ## [14.2.0] - 2022-08-25
14
+ ### Changed
15
+
16
+ - using new separate configurations for Hubspot::Client
17
+
18
+ ## [14.1.0] - 2022-08-23
19
+ ### Changed
20
+
21
+ - using default ruby StandardError
22
+
8
23
  ## [14.0.0] - 2022-08-11
9
24
  ### Changed
10
25
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hubspot-api-client (14.0.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)
@@ -10,8 +10,8 @@ GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  ZenTest (4.12.1)
13
- addressable (2.8.0)
14
- public_suffix (>= 2.0.2, < 5.0)
13
+ addressable (2.8.1)
14
+ public_suffix (>= 2.0.2, < 6.0)
15
15
  autotest (4.4.6)
16
16
  ZenTest (>= 4.4.1)
17
17
  autotest-growl (0.2.16)
@@ -29,7 +29,7 @@ GEM
29
29
  pry (0.14.1)
30
30
  coderay (~> 1.1)
31
31
  method_source (~> 1.0)
32
- public_suffix (4.0.7)
32
+ public_suffix (5.0.0)
33
33
  rake (12.3.3)
34
34
  rake-release (1.3.0)
35
35
  bundler (>= 1.11, < 3)
@@ -51,7 +51,7 @@ GEM
51
51
  typhoeus (1.4.0)
52
52
  ethon (>= 0.9.0)
53
53
  vcr (3.0.3)
54
- webmock (3.17.1)
54
+ webmock (3.18.1)
55
55
  addressable (>= 2.8.0)
56
56
  crack (>= 0.3.2)
57
57
  hashdiff (>= 0.4.0, < 2.0.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
 
@@ -2,8 +2,6 @@ require_rel 'discovery'
2
2
 
3
3
  module Hubspot
4
4
  class Client
5
- attr_reader :api_key, :access_token
6
-
7
5
  def self.api_modules
8
6
  %i[
9
7
  automation
@@ -28,25 +26,9 @@ module Hubspot
28
26
  'Hubspot::Discovery'
29
27
  end
30
28
 
31
- def configure_api_key
32
- Hubspot.configure do |config|
33
- config.api_key['hapikey'] = api_key
34
- end
35
- end
36
-
37
- def configure_access_token
38
- Hubspot.configure do |config|
39
- config.access_token = access_token
40
- end
41
- end
42
-
43
29
  def initialize(params)
44
30
  raise 'Please, pass :api_key or :access_token' if params[:api_key].nil? && params[:developer_api_key].nil? && params[:access_token].nil?
45
- @api_key = params[:api_key] || params[:developer_api_key]
46
- @access_token = params[:access_token]
47
31
  @params = params
48
- configure_api_key if @api_key
49
- configure_access_token if @access_token
50
32
  end
51
33
  end
52
34
  end
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Automation
15
15
  module Actions
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Cms
15
15
  module AuditLogs
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -14,7 +14,7 @@ module Hubspot
14
14
  module Cms
15
15
  module Blogs
16
16
  module Authors
17
- class ApiError < StandardError
17
+ class ApiError < ::StandardError
18
18
  attr_reader :code, :response_headers, :response_body
19
19
 
20
20
  # Usage examples:
@@ -14,7 +14,7 @@ module Hubspot
14
14
  module Cms
15
15
  module Blogs
16
16
  module BlogPosts
17
- class ApiError < StandardError
17
+ class ApiError < ::StandardError
18
18
  attr_reader :code, :response_headers, :response_body
19
19
 
20
20
  # Usage examples:
@@ -14,7 +14,7 @@ module Hubspot
14
14
  module Cms
15
15
  module Blogs
16
16
  module Tags
17
- class ApiError < StandardError
17
+ class ApiError < ::StandardError
18
18
  attr_reader :code, :response_headers, :response_body
19
19
 
20
20
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Cms
15
15
  module Domains
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Cms
15
15
  module Hubdb
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Cms
15
15
  module Performance
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Cms
15
15
  module SiteSearch
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Cms
15
15
  module SourceCode
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Cms
15
15
  module UrlRedirects
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -12,7 +12,7 @@ OpenAPI Generator version: 4.3.1
12
12
 
13
13
  module Hubspot
14
14
  module CommunicationPreferences
15
- class ApiError < StandardError
15
+ class ApiError < ::StandardError
16
16
  attr_reader :code, :response_headers, :response_body
17
17
 
18
18
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Conversations
15
15
  module VisitorIdentification
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Crm
15
15
  module Associations
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Crm
15
15
  module Companies
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Crm
15
15
  module Contacts
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Crm
15
15
  module Deals
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -14,7 +14,7 @@ module Hubspot
14
14
  module Crm
15
15
  module Extensions
16
16
  module Accounting
17
- class ApiError < StandardError
17
+ class ApiError < ::StandardError
18
18
  attr_reader :code, :response_headers, :response_body
19
19
 
20
20
  # Usage examples:
@@ -14,7 +14,7 @@ module Hubspot
14
14
  module Crm
15
15
  module Extensions
16
16
  module Calling
17
- class ApiError < StandardError
17
+ class ApiError < ::StandardError
18
18
  attr_reader :code, :response_headers, :response_body
19
19
 
20
20
  # Usage examples:
@@ -14,7 +14,7 @@ module Hubspot
14
14
  module Crm
15
15
  module Extensions
16
16
  module Cards
17
- class ApiError < StandardError
17
+ class ApiError < ::StandardError
18
18
  attr_reader :code, :response_headers, :response_body
19
19
 
20
20
  # Usage examples:
@@ -14,7 +14,7 @@ module Hubspot
14
14
  module Crm
15
15
  module Extensions
16
16
  module Videoconferencing
17
- class ApiError < StandardError
17
+ class ApiError < ::StandardError
18
18
  attr_reader :code, :response_headers, :response_body
19
19
 
20
20
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Crm
15
15
  module Imports
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Crm
15
15
  module LineItems
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Crm
15
15
  module Objects
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -14,7 +14,7 @@ module Hubspot
14
14
  module Crm
15
15
  module Objects
16
16
  module Calls
17
- class ApiError < StandardError
17
+ class ApiError < ::StandardError
18
18
  attr_reader :code, :response_headers, :response_body
19
19
 
20
20
  # Usage examples:
@@ -14,7 +14,7 @@ module Hubspot
14
14
  module Crm
15
15
  module Objects
16
16
  module Emails
17
- class ApiError < StandardError
17
+ class ApiError < ::StandardError
18
18
  attr_reader :code, :response_headers, :response_body
19
19
 
20
20
  # Usage examples:
@@ -82,7 +82,7 @@ module Hubspot
82
82
  return_type = opts[:return_type]
83
83
 
84
84
  # auth_names
85
- auth_names = opts[:auth_names] || ['hapikey']
85
+ auth_names = opts[:auth_names] || ['hapikey', 'oauth2']
86
86
 
87
87
  new_options = opts.merge(
88
88
  :header_params => header_params,
@@ -160,7 +160,7 @@ module Hubspot
160
160
  return_type = opts[:return_type] || 'SimplePublicObjectWithAssociations'
161
161
 
162
162
  # auth_names
163
- auth_names = opts[:auth_names] || ['hapikey']
163
+ auth_names = opts[:auth_names] || ['hapikey', 'oauth2']
164
164
 
165
165
  new_options = opts.merge(
166
166
  :header_params => header_params,
@@ -232,7 +232,7 @@ module Hubspot
232
232
  return_type = opts[:return_type] || 'CollectionResponseAssociatedIdForwardPaging'
233
233
 
234
234
  # auth_names
235
- auth_names = opts[:auth_names] || ['hapikey']
235
+ auth_names = opts[:auth_names] || ['hapikey', 'oauth2']
236
236
 
237
237
  new_options = opts.merge(
238
238
  :header_params => header_params,
@@ -68,7 +68,7 @@ module Hubspot
68
68
  return_type = opts[:return_type]
69
69
 
70
70
  # auth_names
71
- auth_names = opts[:auth_names] || ['hapikey']
71
+ auth_names = opts[:auth_names] || ['hapikey', 'oauth2']
72
72
 
73
73
  new_options = opts.merge(
74
74
  :header_params => header_params,
@@ -132,7 +132,7 @@ module Hubspot
132
132
  return_type = opts[:return_type] || 'SimplePublicObject'
133
133
 
134
134
  # auth_names
135
- auth_names = opts[:auth_names] || ['hapikey']
135
+ auth_names = opts[:auth_names] || ['hapikey', 'oauth2']
136
136
 
137
137
  new_options = opts.merge(
138
138
  :header_params => header_params,
@@ -209,7 +209,7 @@ module Hubspot
209
209
  return_type = opts[:return_type] || 'SimplePublicObjectWithAssociations'
210
210
 
211
211
  # auth_names
212
- auth_names = opts[:auth_names] || ['hapikey']
212
+ auth_names = opts[:auth_names] || ['hapikey', 'oauth2']
213
213
 
214
214
  new_options = opts.merge(
215
215
  :header_params => header_params,
@@ -283,7 +283,7 @@ module Hubspot
283
283
  return_type = opts[:return_type] || 'CollectionResponseSimplePublicObjectWithAssociationsForwardPaging'
284
284
 
285
285
  # auth_names
286
- auth_names = opts[:auth_names] || ['hapikey']
286
+ auth_names = opts[:auth_names] || ['hapikey', 'oauth2']
287
287
 
288
288
  new_options = opts.merge(
289
289
  :header_params => header_params,
@@ -356,7 +356,7 @@ module Hubspot
356
356
  return_type = opts[:return_type] || 'SimplePublicObject'
357
357
 
358
358
  # auth_names
359
- auth_names = opts[:auth_names] || ['hapikey']
359
+ auth_names = opts[:auth_names] || ['hapikey', 'oauth2']
360
360
 
361
361
  new_options = opts.merge(
362
362
  :header_params => header_params,
@@ -66,7 +66,7 @@ module Hubspot
66
66
  return_type = opts[:return_type]
67
67
 
68
68
  # auth_names
69
- auth_names = opts[:auth_names] || ['hapikey']
69
+ auth_names = opts[:auth_names] || ['hapikey', 'oauth2']
70
70
 
71
71
  new_options = opts.merge(
72
72
  :header_params => header_params,
@@ -128,7 +128,7 @@ module Hubspot
128
128
  return_type = opts[:return_type] || 'BatchResponseSimplePublicObject'
129
129
 
130
130
  # auth_names
131
- auth_names = opts[:auth_names] || ['hapikey']
131
+ auth_names = opts[:auth_names] || ['hapikey', 'oauth2']
132
132
 
133
133
  new_options = opts.merge(
134
134
  :header_params => header_params,
@@ -193,7 +193,7 @@ module Hubspot
193
193
  return_type = opts[:return_type] || 'BatchResponseSimplePublicObject'
194
194
 
195
195
  # auth_names
196
- auth_names = opts[:auth_names] || ['hapikey']
196
+ auth_names = opts[:auth_names] || ['hapikey', 'oauth2']
197
197
 
198
198
  new_options = opts.merge(
199
199
  :header_params => header_params,
@@ -255,7 +255,7 @@ module Hubspot
255
255
  return_type = opts[:return_type] || 'BatchResponseSimplePublicObject'
256
256
 
257
257
  # auth_names
258
- auth_names = opts[:auth_names] || ['hapikey']
258
+ auth_names = opts[:auth_names] || ['hapikey', 'oauth2']
259
259
 
260
260
  new_options = opts.merge(
261
261
  :header_params => header_params,
@@ -66,7 +66,7 @@ module Hubspot
66
66
  return_type = opts[:return_type] || 'SimplePublicObject'
67
67
 
68
68
  # auth_names
69
- auth_names = opts[:auth_names] || ['hapikey']
69
+ auth_names = opts[:auth_names] || ['hapikey', 'oauth2']
70
70
 
71
71
  new_options = opts.merge(
72
72
  :header_params => header_params,
@@ -64,7 +64,7 @@ module Hubspot
64
64
  return_type = opts[:return_type] || 'CollectionResponseWithTotalSimplePublicObjectForwardPaging'
65
65
 
66
66
  # auth_names
67
- auth_names = opts[:auth_names] || ['hapikey']
67
+ auth_names = opts[:auth_names] || ['hapikey', 'oauth2']
68
68
 
69
69
  new_options = opts.merge(
70
70
  :header_params => header_params,
@@ -14,7 +14,7 @@ module Hubspot
14
14
  module Crm
15
15
  module Objects
16
16
  module FeedbackSubmissions
17
- class ApiError < StandardError
17
+ class ApiError < ::StandardError
18
18
  attr_reader :code, :response_headers, :response_body
19
19
 
20
20
  # Usage examples:
@@ -207,6 +207,13 @@ module Hubspot
207
207
  key: 'hapikey',
208
208
  value: api_key_with_prefix('hapikey')
209
209
  },
210
+ 'oauth2' =>
211
+ {
212
+ type: 'oauth2',
213
+ in: 'header',
214
+ key: 'Authorization',
215
+ value: "Bearer #{access_token}"
216
+ },
210
217
  }
211
218
  end
212
219
 
@@ -14,7 +14,7 @@ module Hubspot
14
14
  module Crm
15
15
  module Objects
16
16
  module Meetings
17
- class ApiError < StandardError
17
+ class ApiError < ::StandardError
18
18
  attr_reader :code, :response_headers, :response_body
19
19
 
20
20
  # Usage examples:
@@ -14,7 +14,7 @@ module Hubspot
14
14
  module Crm
15
15
  module Objects
16
16
  module Notes
17
- class ApiError < StandardError
17
+ class ApiError < ::StandardError
18
18
  attr_reader :code, :response_headers, :response_body
19
19
 
20
20
  # Usage examples:
@@ -14,7 +14,7 @@ module Hubspot
14
14
  module Crm
15
15
  module Objects
16
16
  module Tasks
17
- class ApiError < StandardError
17
+ class ApiError < ::StandardError
18
18
  attr_reader :code, :response_headers, :response_body
19
19
 
20
20
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Crm
15
15
  module Owners
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Crm
15
15
  module Pipelines
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Crm
15
15
  module Products
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Crm
15
15
  module Properties
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Crm
15
15
  module Quotes
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Crm
15
15
  module Schemas
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Crm
15
15
  module Tickets
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Crm
15
15
  module Timeline
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -12,7 +12,7 @@ OpenAPI Generator version: 4.3.1
12
12
 
13
13
  module Hubspot
14
14
  module Events
15
- class ApiError < StandardError
15
+ class ApiError < ::StandardError
16
16
  attr_reader :code, :response_headers, :response_body
17
17
 
18
18
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Files
15
15
  module Files
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Marketing
15
15
  module Events
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Marketing
15
15
  module Forms
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Marketing
15
15
  module Transactional
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -12,7 +12,7 @@ OpenAPI Generator version: 4.3.1
12
12
 
13
13
  module Hubspot
14
14
  module OAuth
15
- class ApiError < StandardError
15
+ class ApiError < ::StandardError
16
16
  attr_reader :code, :response_headers, :response_body
17
17
 
18
18
  # Usage examples:
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  module Hubspot
14
14
  module Settings
15
15
  module Users
16
- class ApiError < StandardError
16
+ class ApiError < ::StandardError
17
17
  attr_reader :code, :response_headers, :response_body
18
18
 
19
19
  # Usage examples:
@@ -12,7 +12,7 @@ OpenAPI Generator version: 4.3.1
12
12
 
13
13
  module Hubspot
14
14
  module Webhooks
15
- class ApiError < StandardError
15
+ class ApiError < ::StandardError
16
16
  attr_reader :code, :response_headers, :response_body
17
17
 
18
18
  # Usage examples:
@@ -1,3 +1,5 @@
1
+ require_rel '../helpers/camel_case'
2
+
1
3
  module Hubspot
2
4
  module Discovery
3
5
  module BaseApiClient
@@ -12,12 +14,16 @@ module Hubspot
12
14
  api.methods.grep(/with_http_info/).map {|elem| elem.to_s.gsub('_with_http_info', '').to_sym }
13
15
  end
14
16
 
17
+ def config
18
+ @config ||= new_config
19
+ end
20
+
15
21
  def api_client
16
- api&.api_client
22
+ @api_client ||= Kernel.const_get("#{codegen_module_name}::ApiClient").new(config)
17
23
  end
18
24
 
19
25
  def api
20
- @api ||= Kernel.const_get(codegen_api_class).new
26
+ @api ||= Kernel.const_get(codegen_api_class).new(api_client)
21
27
  end
22
28
 
23
29
  def get_all(params = {})
@@ -26,10 +32,22 @@ module Hubspot
26
32
 
27
33
  private
28
34
 
35
+ def new_config
36
+ config = Kernel.const_get("#{self.class.name.gsub('Discovery::', '').gsub(/(.*)::.*/, '\1')}::Configuration").new
37
+ config.access_token = base_params[:access_token] if base_params[:access_token]
38
+ config.api_key['hapikey'] = base_params[:api_key] if base_params[:api_key]
39
+ config.api_key['hapikey'] = base_params[:developer_api_key] if base_params[:developer_api_key]
40
+ config
41
+ end
42
+
29
43
  def codegen_api_class
30
44
  self.class.name.gsub('Discovery::', '')
31
45
  end
32
46
 
47
+ def codegen_module_name
48
+ codegen_api_class.gsub(/(.*)::.*/, '\1')
49
+ end
50
+
33
51
  def define_methods
34
52
  define_api_methods
35
53
  end
@@ -53,11 +71,15 @@ module Hubspot
53
71
 
54
72
  signature_param_names = signature_params.map { |_, param| param }
55
73
  params_with_defaults.each do |param_name, param_value|
56
- 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
57
75
  end
58
76
 
59
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
60
81
  raise "Param #{param} is required for #{api.class}\##{api_method} method" if req == :req && params_with_defaults[param].nil?
82
+
61
83
  params_with_defaults[param]
62
84
  end
63
85
 
@@ -1,3 +1,3 @@
1
1
  module Hubspot
2
- VERSION = '14.0.0'
2
+ VERSION = '14.3.0'
3
3
  end
@@ -6,6 +6,9 @@ describe 'Hubspot::Discovery::BaseApiClient' do
6
6
  end
7
7
 
8
8
  class Hubspot::SomeApiClass
9
+ def initialize(api_client)
10
+ end
11
+
9
12
  def get(test_id, opts = {})
10
13
  "got test_id: #{test_id}, opts: #{opts}"
11
14
  end
@@ -14,15 +17,34 @@ describe 'Hubspot::Discovery::BaseApiClient' do
14
17
  end
15
18
 
16
19
  def update(test_id, simple_public_object_input, opts = {})
17
- "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}"
18
21
  end
19
22
 
20
23
  def update_with_http_info
21
24
  end
22
25
  end
23
26
 
27
+ class Hubspot::ApiClient
28
+ def initialize(config)
29
+ end
30
+ end
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
+
24
45
  subject(:client) { Hubspot::Discovery::SomeApiClass.new(access_token: 'test') }
25
46
  let(:api) { client.api }
47
+ let(:body) { {name: 'test_name', email: 'test_email'} }
26
48
 
27
49
  it { is_expected.to respond_to(:get) }
28
50
  it { is_expected.to respond_to(:update) }
@@ -49,21 +71,27 @@ describe 'Hubspot::Discovery::BaseApiClient' do
49
71
  subject(:update) { client.update(params) }
50
72
 
51
73
  context 'with default params order' do
52
- 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} }
53
75
 
54
- 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}') }
55
77
  end
56
78
 
57
79
  context 'with reversed params order' do
58
- 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'} }
59
81
 
60
- 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}') }
61
83
  end
62
84
 
63
85
  context 'with shuffled params order' do
64
- 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'} }
65
87
 
66
- 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}') }
67
95
  end
68
96
  end
69
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.0.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-11 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