hubspot-api-client 17.0.0.pre.beta.2 → 17.0.0.pre.beta.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -1
  3. data/Gemfile.lock +1 -1
  4. data/lib/hubspot/codegen/crm/associations/schema/api/types_api.rb +97 -0
  5. data/lib/hubspot/codegen/crm/associations/schema/api_client.rb +412 -0
  6. data/lib/hubspot/codegen/crm/associations/schema/api_error.rb +63 -0
  7. data/lib/hubspot/codegen/crm/associations/schema/configuration.rb +296 -0
  8. data/lib/hubspot/codegen/crm/associations/schema/models/associated_id.rb +244 -0
  9. data/lib/hubspot/codegen/crm/associations/schema/models/batch_input_public_association.rb +232 -0
  10. data/lib/hubspot/codegen/crm/associations/schema/models/batch_input_public_object_id.rb +232 -0
  11. data/lib/hubspot/codegen/crm/associations/schema/models/batch_response_public_association.rb +328 -0
  12. data/lib/hubspot/codegen/crm/associations/schema/models/batch_response_public_association_multi.rb +328 -0
  13. data/lib/hubspot/codegen/crm/associations/schema/models/batch_response_public_association_multi_with_errors.rb +348 -0
  14. data/lib/hubspot/codegen/crm/associations/schema/models/batch_response_public_association_with_errors.rb +348 -0
  15. data/lib/hubspot/codegen/crm/associations/schema/models/collection_response_public_association_definition_no_paging.rb +232 -0
  16. data/lib/hubspot/codegen/crm/associations/schema/models/error.rb +307 -0
  17. data/lib/hubspot/codegen/crm/associations/schema/models/error_category.rb +278 -0
  18. data/lib/hubspot/codegen/crm/associations/schema/models/error_detail.rb +273 -0
  19. data/lib/hubspot/codegen/crm/associations/schema/models/next_page.rb +239 -0
  20. data/lib/hubspot/codegen/crm/associations/schema/models/paging.rb +234 -0
  21. data/lib/hubspot/codegen/crm/associations/schema/models/previous_page.rb +239 -0
  22. data/lib/hubspot/codegen/crm/associations/schema/models/public_association.rb +258 -0
  23. data/lib/hubspot/codegen/crm/associations/schema/models/public_association_definition.rb +244 -0
  24. data/lib/hubspot/codegen/crm/associations/schema/models/public_association_multi.rb +256 -0
  25. data/lib/hubspot/codegen/crm/associations/schema/models/public_object_id.rb +231 -0
  26. data/lib/hubspot/codegen/crm/associations/schema/models/standard_error.rb +324 -0
  27. data/lib/hubspot/codegen/crm/associations/v4/api/basic_api.rb +365 -0
  28. data/lib/hubspot/codegen/crm/associations/v4/api/batch_api.rb +1 -1
  29. data/lib/hubspot/codegen/crm/associations/v4/api_client.rb +1 -1
  30. data/lib/hubspot/codegen/crm/associations/v4/api_error.rb +1 -1
  31. data/lib/hubspot/codegen/crm/associations/v4/configuration.rb +1 -1
  32. data/lib/hubspot/codegen/crm/associations/v4/models/associated_id.rb +244 -0
  33. data/lib/hubspot/codegen/crm/associations/v4/models/association_spec.rb +1 -1
  34. data/lib/hubspot/codegen/crm/associations/v4/models/association_spec_with_label.rb +1 -1
  35. data/lib/hubspot/codegen/crm/associations/v4/models/batch_input_public_association_multi_archive.rb +1 -1
  36. data/lib/hubspot/codegen/crm/associations/v4/models/batch_input_public_association_multi_post.rb +1 -1
  37. data/lib/hubspot/codegen/crm/associations/v4/models/batch_input_public_default_association_multi_post.rb +1 -1
  38. data/lib/hubspot/codegen/crm/associations/v4/models/batch_input_public_fetch_associations_batch_request.rb +1 -1
  39. data/lib/hubspot/codegen/crm/associations/v4/models/batch_input_simple_public_object_batch_input.rb +232 -0
  40. data/lib/hubspot/codegen/crm/associations/v4/models/batch_input_simple_public_object_id.rb +232 -0
  41. data/lib/hubspot/codegen/crm/associations/v4/models/batch_input_simple_public_object_input_for_create.rb +232 -0
  42. data/lib/hubspot/codegen/crm/associations/v4/models/batch_read_input_simple_public_object_id.rb +273 -0
  43. data/lib/hubspot/codegen/crm/associations/v4/models/batch_response_labels_between_object_pair.rb +1 -1
  44. data/lib/hubspot/codegen/crm/associations/v4/models/batch_response_labels_between_object_pair_with_errors.rb +1 -1
  45. data/lib/hubspot/codegen/crm/associations/v4/models/batch_response_public_association_multi_with_label.rb +1 -1
  46. data/lib/hubspot/codegen/crm/associations/v4/models/batch_response_public_association_multi_with_label_with_errors.rb +1 -1
  47. data/lib/hubspot/codegen/crm/associations/v4/models/batch_response_public_default_association.rb +1 -1
  48. data/lib/hubspot/codegen/crm/associations/v4/models/batch_response_simple_public_object.rb +328 -0
  49. data/lib/hubspot/codegen/crm/associations/v4/models/batch_response_simple_public_object_with_errors.rb +348 -0
  50. data/lib/hubspot/codegen/crm/associations/v4/models/collection_response_associated_id.rb +241 -0
  51. data/lib/hubspot/codegen/crm/associations/v4/models/collection_response_association_spec_with_label_no_paging.rb +1 -1
  52. data/lib/hubspot/codegen/crm/associations/v4/models/collection_response_multi_associated_object_with_label_forward_paging.rb +241 -0
  53. data/lib/hubspot/codegen/crm/associations/v4/models/collection_response_simple_public_object_with_associations_forward_paging.rb +241 -0
  54. data/lib/hubspot/codegen/crm/associations/v4/models/error.rb +1 -1
  55. data/lib/hubspot/codegen/crm/associations/v4/models/error_category.rb +1 -1
  56. data/lib/hubspot/codegen/crm/associations/v4/models/error_detail.rb +1 -1
  57. data/lib/hubspot/codegen/crm/associations/v4/models/forward_paging.rb +225 -0
  58. data/lib/hubspot/codegen/crm/associations/v4/models/labels_between_object_pair.rb +1 -1
  59. data/lib/hubspot/codegen/crm/associations/v4/models/multi_associated_object_with_label.rb +1 -1
  60. data/lib/hubspot/codegen/crm/associations/v4/models/next_page.rb +1 -1
  61. data/lib/hubspot/codegen/crm/associations/v4/models/paging.rb +1 -1
  62. data/lib/hubspot/codegen/crm/associations/v4/models/previous_page.rb +1 -1
  63. data/lib/hubspot/codegen/crm/associations/v4/models/public_association_definition_create_request.rb +1 -1
  64. data/lib/hubspot/codegen/crm/associations/v4/models/public_association_definition_update_request.rb +1 -1
  65. data/lib/hubspot/codegen/crm/associations/v4/models/public_association_multi_archive.rb +1 -1
  66. data/lib/hubspot/codegen/crm/associations/v4/models/public_association_multi_post.rb +1 -1
  67. data/lib/hubspot/codegen/crm/associations/v4/models/public_association_multi_with_label.rb +1 -1
  68. data/lib/hubspot/codegen/crm/associations/v4/models/public_associations_for_object.rb +246 -0
  69. data/lib/hubspot/codegen/crm/associations/v4/models/public_default_association.rb +1 -1
  70. data/lib/hubspot/codegen/crm/associations/v4/models/public_default_association_multi_post.rb +1 -1
  71. data/lib/hubspot/codegen/crm/associations/v4/models/public_fetch_associations_batch_request.rb +1 -1
  72. data/lib/hubspot/codegen/crm/associations/v4/models/public_gdpr_delete_input.rb +239 -0
  73. data/lib/hubspot/codegen/crm/associations/v4/models/public_object_id.rb +1 -1
  74. data/lib/hubspot/codegen/crm/associations/v4/models/simple_public_object.rb +303 -0
  75. data/lib/hubspot/codegen/crm/associations/v4/models/simple_public_object_batch_input.rb +246 -0
  76. data/lib/hubspot/codegen/crm/associations/v4/models/simple_public_object_id.rb +230 -0
  77. data/lib/hubspot/codegen/crm/associations/v4/models/simple_public_object_input.rb +232 -0
  78. data/lib/hubspot/codegen/crm/associations/v4/models/simple_public_object_input_for_create.rb +248 -0
  79. data/lib/hubspot/codegen/crm/associations/v4/models/simple_public_object_with_associations.rb +314 -0
  80. data/lib/hubspot/codegen/crm/associations/v4/models/standard_error.rb +1 -1
  81. data/lib/hubspot/codegen/crm/associations/v4/models/value_with_timestamp.rb +285 -0
  82. data/lib/hubspot/codegen/crm/associations/v4/schema/api/definitions_api.rb +334 -0
  83. data/lib/hubspot/codegen/crm/associations/v4/schema/api_client.rb +414 -0
  84. data/lib/hubspot/codegen/crm/associations/v4/schema/api_error.rb +65 -0
  85. data/lib/hubspot/codegen/crm/associations/v4/schema/configuration.rb +298 -0
  86. data/lib/hubspot/codegen/crm/associations/v4/schema/models/association_spec.rb +280 -0
  87. data/lib/hubspot/codegen/crm/associations/v4/schema/models/association_spec_with_label.rb +289 -0
  88. data/lib/hubspot/codegen/crm/associations/v4/schema/models/batch_input_public_association_multi_archive.rb +234 -0
  89. data/lib/hubspot/codegen/crm/associations/v4/schema/models/batch_input_public_association_multi_post.rb +234 -0
  90. data/lib/hubspot/codegen/crm/associations/v4/schema/models/batch_input_public_default_association_multi_post.rb +234 -0
  91. data/lib/hubspot/codegen/crm/associations/v4/schema/models/batch_input_public_fetch_associations_batch_request.rb +234 -0
  92. data/lib/hubspot/codegen/crm/associations/v4/schema/models/batch_response_labels_between_object_pair.rb +330 -0
  93. data/lib/hubspot/codegen/crm/associations/v4/schema/models/batch_response_labels_between_object_pair_with_errors.rb +350 -0
  94. data/lib/hubspot/codegen/crm/associations/v4/schema/models/batch_response_public_association_multi_with_label.rb +330 -0
  95. data/lib/hubspot/codegen/crm/associations/v4/schema/models/batch_response_public_association_multi_with_label_with_errors.rb +350 -0
  96. data/lib/hubspot/codegen/crm/associations/v4/schema/models/batch_response_public_default_association.rb +350 -0
  97. data/lib/hubspot/codegen/crm/associations/v4/schema/models/collection_response_association_spec_with_label_no_paging.rb +234 -0
  98. data/lib/hubspot/codegen/crm/associations/v4/schema/models/error.rb +309 -0
  99. data/lib/hubspot/codegen/crm/associations/v4/schema/models/error_category.rb +280 -0
  100. data/lib/hubspot/codegen/crm/associations/v4/schema/models/error_detail.rb +275 -0
  101. data/lib/hubspot/codegen/crm/associations/v4/schema/models/labels_between_object_pair.rb +290 -0
  102. data/lib/hubspot/codegen/crm/associations/v4/schema/models/multi_associated_object_with_label.rb +248 -0
  103. data/lib/hubspot/codegen/crm/associations/v4/schema/models/next_page.rb +241 -0
  104. data/lib/hubspot/codegen/crm/associations/v4/schema/models/paging.rb +236 -0
  105. data/lib/hubspot/codegen/crm/associations/v4/schema/models/previous_page.rb +241 -0
  106. data/lib/hubspot/codegen/crm/associations/v4/schema/models/public_association_definition_create_request.rb +246 -0
  107. data/lib/hubspot/codegen/crm/associations/v4/schema/models/public_association_definition_update_request.rb +246 -0
  108. data/lib/hubspot/codegen/crm/associations/v4/schema/models/public_association_multi_archive.rb +248 -0
  109. data/lib/hubspot/codegen/crm/associations/v4/schema/models/public_association_multi_post.rb +262 -0
  110. data/lib/hubspot/codegen/crm/associations/v4/schema/models/public_association_multi_with_label.rb +257 -0
  111. data/lib/hubspot/codegen/crm/associations/v4/schema/models/public_default_association.rb +260 -0
  112. data/lib/hubspot/codegen/crm/associations/v4/schema/models/public_default_association_multi_post.rb +246 -0
  113. data/lib/hubspot/codegen/crm/associations/v4/schema/models/public_fetch_associations_batch_request.rb +241 -0
  114. data/lib/hubspot/codegen/crm/associations/v4/schema/models/public_object_id.rb +232 -0
  115. data/lib/hubspot/codegen/crm/associations/v4/schema/models/standard_error.rb +326 -0
  116. data/lib/hubspot/codegen/crm/objects/communications/api/basic_api.rb +391 -0
  117. data/lib/hubspot/codegen/crm/objects/communications/api/batch_api.rb +295 -0
  118. data/lib/hubspot/codegen/crm/objects/communications/api/public_object_api.rb +94 -0
  119. data/lib/hubspot/codegen/crm/objects/communications/api/search_api.rb +92 -0
  120. data/lib/hubspot/codegen/crm/objects/communications/api_client.rb +412 -0
  121. data/lib/hubspot/codegen/crm/objects/communications/api_error.rb +63 -0
  122. data/lib/hubspot/codegen/crm/objects/communications/configuration.rb +296 -0
  123. data/lib/hubspot/codegen/crm/objects/communications/models/associated_id.rb +244 -0
  124. data/lib/hubspot/codegen/crm/objects/communications/models/association_spec.rb +278 -0
  125. data/lib/hubspot/codegen/crm/objects/communications/models/batch_input_simple_public_object_batch_input.rb +232 -0
  126. data/lib/hubspot/codegen/crm/objects/communications/models/batch_input_simple_public_object_id.rb +232 -0
  127. data/lib/hubspot/codegen/crm/objects/communications/models/batch_input_simple_public_object_input_for_create.rb +232 -0
  128. data/lib/hubspot/codegen/crm/objects/communications/models/batch_read_input_simple_public_object_id.rb +273 -0
  129. data/lib/hubspot/codegen/crm/objects/communications/models/batch_response_simple_public_object.rb +328 -0
  130. data/lib/hubspot/codegen/crm/objects/communications/models/batch_response_simple_public_object_with_errors.rb +348 -0
  131. data/lib/hubspot/codegen/crm/objects/communications/models/collection_response_associated_id.rb +241 -0
  132. data/lib/hubspot/codegen/crm/objects/communications/models/collection_response_simple_public_object_with_associations_forward_paging.rb +241 -0
  133. data/lib/hubspot/codegen/crm/objects/communications/models/collection_response_with_total_simple_public_object_forward_paging.rb +255 -0
  134. data/lib/hubspot/codegen/crm/objects/communications/models/error.rb +307 -0
  135. data/lib/hubspot/codegen/crm/objects/communications/models/error_category.rb +278 -0
  136. data/lib/hubspot/codegen/crm/objects/communications/models/error_detail.rb +273 -0
  137. data/lib/hubspot/codegen/crm/objects/communications/models/filter.rb +308 -0
  138. data/lib/hubspot/codegen/crm/objects/communications/models/filter_group.rb +232 -0
  139. data/lib/hubspot/codegen/crm/objects/communications/models/forward_paging.rb +225 -0
  140. data/lib/hubspot/codegen/crm/objects/communications/models/next_page.rb +239 -0
  141. data/lib/hubspot/codegen/crm/objects/communications/models/paging.rb +234 -0
  142. data/lib/hubspot/codegen/crm/objects/communications/models/previous_page.rb +239 -0
  143. data/lib/hubspot/codegen/crm/objects/communications/models/public_associations_for_object.rb +246 -0
  144. data/lib/hubspot/codegen/crm/objects/communications/models/public_merge_input.rb +244 -0
  145. data/lib/hubspot/codegen/crm/objects/communications/models/public_object_id.rb +230 -0
  146. data/lib/hubspot/codegen/crm/objects/communications/models/public_object_search_request.rb +301 -0
  147. data/lib/hubspot/codegen/crm/objects/communications/models/simple_public_object.rb +303 -0
  148. data/lib/hubspot/codegen/crm/objects/communications/models/simple_public_object_batch_input.rb +246 -0
  149. data/lib/hubspot/codegen/crm/objects/communications/models/simple_public_object_id.rb +230 -0
  150. data/lib/hubspot/codegen/crm/objects/communications/models/simple_public_object_input.rb +232 -0
  151. data/lib/hubspot/codegen/crm/objects/communications/models/simple_public_object_input_for_create.rb +248 -0
  152. data/lib/hubspot/codegen/crm/objects/communications/models/simple_public_object_with_associations.rb +314 -0
  153. data/lib/hubspot/codegen/crm/objects/communications/models/standard_error.rb +324 -0
  154. data/lib/hubspot/codegen/crm/objects/communications/models/value_with_timestamp.rb +285 -0
  155. data/lib/hubspot/discovery/crm/associations/client.rb +4 -2
  156. data/lib/hubspot/discovery/crm/associations/schema/api/types_api.rb +15 -0
  157. data/lib/hubspot/discovery/crm/associations/schema/client.rb +20 -0
  158. data/lib/hubspot/discovery/crm/associations/v4/api/{definitions_api.rb → basic_api.rb} +1 -1
  159. data/lib/hubspot/discovery/crm/associations/v4/client.rb +6 -1
  160. data/lib/hubspot/discovery/crm/associations/v4/schema/api/definitions_api.rb +17 -0
  161. data/lib/hubspot/discovery/crm/associations/v4/schema/client.rb +22 -0
  162. data/lib/hubspot/discovery/crm/objects/client.rb +1 -0
  163. data/lib/hubspot/discovery/crm/objects/communications/api/basic_api.rb +15 -0
  164. data/lib/hubspot/discovery/crm/objects/communications/api/batch_api.rb +15 -0
  165. data/lib/hubspot/discovery/crm/objects/communications/api/public_object_api.rb +15 -0
  166. data/lib/hubspot/discovery/crm/objects/communications/api/search_api.rb +15 -0
  167. data/lib/hubspot/discovery/crm/objects/communications/client.rb +24 -0
  168. data/lib/hubspot/version.rb +1 -1
  169. data/spec/discovery/crm/associations/client_spec.rb +1 -0
  170. data/spec/discovery/crm/associations/schema/types_api_spec.rb +7 -0
  171. data/spec/discovery/crm/associations/v4/basic_api_spec.rb +10 -0
  172. data/spec/discovery/crm/associations/v4/client_spec.rb +7 -0
  173. data/spec/discovery/crm/associations/v4/{definitions_api_spec.rb → schema/definitions_api_spec.rb} +3 -3
  174. data/spec/discovery/crm/objects/client_spec.rb +1 -0
  175. data/spec/discovery/crm/objects/communications/basic_api_spec.rb +10 -0
  176. data/spec/discovery/crm/objects/communications/batch_api_spec.rb +10 -0
  177. data/spec/discovery/crm/objects/communications/public_object_api_spec.rb +7 -0
  178. data/spec/discovery/crm/objects/communications/search_api_spec.rb +7 -0
  179. metadata +145 -10
  180. data/lib/hubspot/codegen/crm/associations/api/types_api.rb +0 -95
  181. data/lib/hubspot/codegen/crm/associations/v4/api/definitions_api.rb +0 -332
  182. data/lib/hubspot/discovery/crm/associations/api/types_api.rb +0 -13
  183. data/spec/discovery/crm/associations/types_api_spec.rb +0 -7
@@ -0,0 +1,414 @@
1
+ =begin
2
+ #CrmPublicAssociationsServiceV4
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: v4
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.2.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'json'
15
+ require 'logger'
16
+ require 'tempfile'
17
+ require 'time'
18
+ require 'typhoeus'
19
+
20
+ module Hubspot
21
+ module Crm
22
+ module Associations
23
+ module V4
24
+ module Schema
25
+ class ApiClient
26
+ # The Configuration object holding settings to be used in the API client.
27
+ attr_accessor :config
28
+
29
+ # Defines the headers to be used in HTTP requests of all API calls by default.
30
+ #
31
+ # @return [Hash]
32
+ attr_accessor :default_headers
33
+
34
+ # Initializes the ApiClient
35
+ # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
36
+ def initialize(config = Configuration.default)
37
+ @config = config
38
+ @user_agent = "hubspot-api-client-ruby; #{VERSION}"
39
+ @default_headers = {
40
+ 'Content-Type' => 'application/json',
41
+ 'User-Agent' => @user_agent
42
+ }
43
+ end
44
+
45
+ def self.default
46
+ @@default ||= ApiClient.new
47
+ end
48
+
49
+ # Call an API with given options.
50
+ #
51
+ # @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
52
+ # the data deserialized from response body (could be nil), response status code and response headers.
53
+ def call_api(http_method, path, opts = {})
54
+ request = build_request(http_method, path, opts)
55
+ response = request.run
56
+
57
+ if @config.debugging
58
+ @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
59
+ end
60
+
61
+ if !response.success? && config.error_handler.any?
62
+ config.error_handler.each do |statuses, opts|
63
+ statuses = statuses.is_a?(Integer) ? [statuses] : statuses
64
+
65
+ retries = opts[:max_retries] || 5
66
+ while retries > 0 && statuses.include?(response.code)
67
+ sleep opts[:seconds_delay] if opts[:seconds_delay]
68
+ response = request.run
69
+ opts[:retry_block].call if opts[:retry_block]
70
+ retries -= 1
71
+ end
72
+ end
73
+ end
74
+
75
+ unless response.success?
76
+ if response.timed_out?
77
+ fail ApiError.new('Connection timed out')
78
+ elsif response.code == 0
79
+ # Errors from libcurl will be made visible here
80
+ fail ApiError.new(:code => 0,
81
+ :message => response.return_message)
82
+ else
83
+ fail ApiError.new(:code => response.code,
84
+ :response_headers => response.headers,
85
+ :response_body => response.body),
86
+ response.status_message
87
+ end
88
+ end
89
+
90
+ if opts[:return_type]
91
+ data = deserialize(response, opts[:return_type])
92
+ else
93
+ data = nil
94
+ end
95
+ return data, response.code, response.headers
96
+ end
97
+
98
+ # Builds the HTTP request
99
+ #
100
+ # @param [String] http_method HTTP method/verb (e.g. POST)
101
+ # @param [String] path URL path (e.g. /account/new)
102
+ # @option opts [Hash] :header_params Header parameters
103
+ # @option opts [Hash] :query_params Query parameters
104
+ # @option opts [Hash] :form_params Query parameters
105
+ # @option opts [Object] :body HTTP body (JSON/XML)
106
+ # @return [Typhoeus::Request] A Typhoeus Request
107
+ def build_request(http_method, path, opts = {})
108
+ url = build_request_url(path, opts)
109
+ http_method = http_method.to_sym.downcase
110
+
111
+ header_params = @default_headers.merge(opts[:header_params] || {})
112
+ query_params = opts[:query_params] || {}
113
+ form_params = opts[:form_params] || {}
114
+ follow_location = opts[:follow_location] || true
115
+
116
+ update_params_for_auth! header_params, query_params, opts[:auth_names]
117
+
118
+ # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
119
+ _verify_ssl_host = @config.verify_ssl_host ? 2 : 0
120
+
121
+ req_opts = {
122
+ :method => http_method,
123
+ :headers => header_params,
124
+ :params => query_params,
125
+ :params_encoding => @config.params_encoding,
126
+ :timeout => @config.timeout,
127
+ :ssl_verifypeer => @config.verify_ssl,
128
+ :ssl_verifyhost => _verify_ssl_host,
129
+ :sslcert => @config.cert_file,
130
+ :sslkey => @config.key_file,
131
+ :verbose => @config.debugging,
132
+ :followlocation => follow_location
133
+ }
134
+
135
+ # set custom cert, if provided
136
+ req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
137
+
138
+ if [:post, :patch, :put, :delete].include?(http_method)
139
+ req_body = build_request_body(header_params, form_params, opts[:body])
140
+ req_opts.update :body => req_body
141
+ if @config.debugging
142
+ @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
143
+ end
144
+ end
145
+
146
+ request = Typhoeus::Request.new(url, req_opts)
147
+ download_file(request) if opts[:return_type] == 'File'
148
+ request
149
+ end
150
+
151
+ # Builds the HTTP request body
152
+ #
153
+ # @param [Hash] header_params Header parameters
154
+ # @param [Hash] form_params Query parameters
155
+ # @param [Object] body HTTP body (JSON/XML)
156
+ # @return [String] HTTP body data in the form of string
157
+ def build_request_body(header_params, form_params, body)
158
+ # http form
159
+ if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
160
+ header_params['Content-Type'] == 'multipart/form-data'
161
+ data = {}
162
+ form_params.each do |key, value|
163
+ case value
164
+ when ::File, ::Array, nil
165
+ # let typhoeus handle File, Array and nil parameters
166
+ data[key] = value
167
+ else
168
+ data[key] = value.to_s
169
+ end
170
+ end
171
+ elsif body
172
+ data = body.is_a?(String) ? body : body.to_json
173
+ else
174
+ data = nil
175
+ end
176
+ data
177
+ end
178
+
179
+ # Save response body into a file in (the defined) temporary folder, using the filename
180
+ # from the "Content-Disposition" header if provided, otherwise a random filename.
181
+ # The response body is written to the file in chunks in order to handle files which
182
+ # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
183
+ # process can use.
184
+ #
185
+ # @see Configuration#temp_folder_path
186
+ def download_file(request)
187
+ tempfile = nil
188
+ encoding = nil
189
+ request.on_headers do |response|
190
+ content_disposition = response.headers['Content-Disposition']
191
+ if content_disposition && content_disposition =~ /filename=/i
192
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
193
+ prefix = sanitize_filename(filename)
194
+ else
195
+ prefix = 'download-'
196
+ end
197
+ prefix = prefix + '-' unless prefix.end_with?('-')
198
+ encoding = response.body.encoding
199
+ tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
200
+ @tempfile = tempfile
201
+ end
202
+ request.on_body do |chunk|
203
+ chunk.force_encoding(encoding)
204
+ tempfile.write(chunk)
205
+ end
206
+ request.on_complete do |response|
207
+ if tempfile
208
+ tempfile.close
209
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
210
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
211
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
212
+ "explicitly with `tempfile.delete`"
213
+ end
214
+ end
215
+ end
216
+
217
+ # Check if the given MIME is a JSON MIME.
218
+ # JSON MIME examples:
219
+ # application/json
220
+ # application/json; charset=UTF8
221
+ # APPLICATION/JSON
222
+ # */*
223
+ # @param [String] mime MIME
224
+ # @return [Boolean] True if the MIME is application/json
225
+ def json_mime?(mime)
226
+ (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
227
+ end
228
+
229
+ # Deserialize the response to the given return type.
230
+ #
231
+ # @param [Response] response HTTP response
232
+ # @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
233
+ def deserialize(response, return_type)
234
+ body = response.body
235
+
236
+ # handle file downloading - return the File instance processed in request callbacks
237
+ # note that response body is empty when the file is written in chunks in request on_body callback
238
+ return @tempfile if return_type == 'File'
239
+
240
+ return nil if body.nil? || body.empty?
241
+
242
+ # return response body directly for String return type
243
+ return body if return_type == 'String'
244
+
245
+ # ensuring a default content type
246
+ content_type = response.headers['Content-Type'] || 'application/json'
247
+
248
+ fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
249
+
250
+ begin
251
+ data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
252
+ rescue JSON::ParserError => e
253
+ if %w(String Date Time).include?(return_type)
254
+ data = body
255
+ else
256
+ raise e
257
+ end
258
+ end
259
+
260
+ convert_to_type data, return_type
261
+ end
262
+
263
+ # Convert data to the given return type.
264
+ # @param [Object] data Data to be converted
265
+ # @param [String] return_type Return type
266
+ # @return [Mixed] Data in a particular type
267
+ def convert_to_type(data, return_type)
268
+ return nil if data.nil?
269
+ case return_type
270
+ when 'String'
271
+ data.to_s
272
+ when 'Integer'
273
+ data.to_i
274
+ when 'Float'
275
+ data.to_f
276
+ when 'Boolean'
277
+ data == true
278
+ when 'Time'
279
+ # parse date time (expecting ISO 8601 format)
280
+ Time.parse data
281
+ when 'Date'
282
+ # parse date time (expecting ISO 8601 format)
283
+ Date.parse data
284
+ when 'Object'
285
+ # generic object (usually a Hash), return directly
286
+ data
287
+ when /\AArray<(.+)>\z/
288
+ # e.g. Array<Pet>
289
+ sub_type = $1
290
+ data.map { |item| convert_to_type(item, sub_type) }
291
+ when /\AHash\<String, (.+)\>\z/
292
+ # e.g. Hash<String, Integer>
293
+ sub_type = $1
294
+ {}.tap do |hash|
295
+ data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
296
+ end
297
+ else
298
+ # models (e.g. Pet) or oneOf
299
+ klass = Hubspot::Crm::Associations::V4.const_get(return_type)
300
+ klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
301
+ end
302
+ end
303
+
304
+ # Sanitize filename by removing path.
305
+ # e.g. ../../sun.gif becomes sun.gif
306
+ #
307
+ # @param [String] filename the filename to be sanitized
308
+ # @return [String] the sanitized filename
309
+ def sanitize_filename(filename)
310
+ filename.gsub(/.*[\/\\]/, '')
311
+ end
312
+
313
+ def build_request_url(path, opts = {})
314
+ # Add leading and trailing slashes to path
315
+ path = "/#{path}".gsub(/\/+/, '/')
316
+ @config.base_url(opts[:operation]) + path
317
+ end
318
+
319
+ # Update header and query params based on authentication settings.
320
+ #
321
+ # @param [Hash] header_params Header parameters
322
+ # @param [Hash] query_params Query parameters
323
+ # @param [String] auth_names Authentication scheme name
324
+ def update_params_for_auth!(header_params, query_params, auth_names)
325
+ Array(auth_names).each do |auth_name|
326
+ auth_setting = @config.auth_settings[auth_name]
327
+ next unless auth_setting
328
+ case auth_setting[:in]
329
+ when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
330
+ when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
331
+ else fail ArgumentError, 'Authentication token must be in `query` or `header`'
332
+ end
333
+ end
334
+ end
335
+
336
+ # Sets user agent in HTTP header
337
+ #
338
+ # @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
339
+ def user_agent=(user_agent)
340
+ @user_agent = user_agent
341
+ @default_headers['User-Agent'] = @user_agent
342
+ end
343
+
344
+ # Return Accept header based on an array of accepts provided.
345
+ # @param [Array] accepts array for Accept
346
+ # @return [String] the Accept header (e.g. application/json)
347
+ def select_header_accept(accepts)
348
+ return nil if accepts.nil? || accepts.empty?
349
+ # use JSON when present, otherwise use all of the provided
350
+ json_accept = accepts.find { |s| json_mime?(s) }
351
+ json_accept || accepts.join(',')
352
+ end
353
+
354
+ # Return Content-Type header based on an array of content types provided.
355
+ # @param [Array] content_types array for Content-Type
356
+ # @return [String] the Content-Type header (e.g. application/json)
357
+ def select_header_content_type(content_types)
358
+ # return nil by default
359
+ return if content_types.nil? || content_types.empty?
360
+ # use JSON when present, otherwise use the first one
361
+ json_content_type = content_types.find { |s| json_mime?(s) }
362
+ json_content_type || content_types.first
363
+ end
364
+
365
+ # Convert object (array, hash, object, etc) to JSON string.
366
+ # @param [Object] model object to be converted into JSON string
367
+ # @return [String] JSON string representation of the object
368
+ def object_to_http_body(model)
369
+ return model if model.nil? || model.is_a?(String)
370
+ local_body = nil
371
+ if model.is_a?(Array)
372
+ local_body = model.map { |m| object_to_hash(m) }
373
+ else
374
+ local_body = object_to_hash(model)
375
+ end
376
+ local_body.to_json
377
+ end
378
+
379
+ # Convert object(non-array) to hash.
380
+ # @param [Object] obj object to be converted into JSON string
381
+ # @return [String] JSON string representation of the object
382
+ def object_to_hash(obj)
383
+ if obj.respond_to?(:to_hash)
384
+ obj.to_hash
385
+ else
386
+ obj
387
+ end
388
+ end
389
+
390
+ # Build parameter value according to the given collection format.
391
+ # @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
392
+ def build_collection_param(param, collection_format)
393
+ case collection_format
394
+ when :csv
395
+ param.join(',')
396
+ when :ssv
397
+ param.join(' ')
398
+ when :tsv
399
+ param.join("\t")
400
+ when :pipes
401
+ param.join('|')
402
+ when :multi
403
+ # return the array directly as typhoeus will handle it as expected
404
+ param
405
+ else
406
+ fail "unknown collection format: #{collection_format.inspect}"
407
+ end
408
+ end
409
+ end
410
+ end
411
+ end
412
+ end
413
+ end
414
+ end
@@ -0,0 +1,65 @@
1
+ =begin
2
+ #CrmPublicAssociationsServiceV4
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: v4
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.2.1
10
+
11
+ =end
12
+
13
+ module Hubspot
14
+ module Crm
15
+ module Associations
16
+ module V4
17
+ module Schema
18
+ class ApiError < ::StandardError
19
+ attr_reader :code, :response_headers, :response_body
20
+
21
+ # Usage examples:
22
+ # ApiError.new
23
+ # ApiError.new("message")
24
+ # ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
25
+ # ApiError.new(:code => 404, :message => "Not Found")
26
+ def initialize(arg = nil)
27
+ if arg.is_a? Hash
28
+ if arg.key?(:message) || arg.key?('message')
29
+ super(arg[:message] || arg['message'])
30
+ else
31
+ super arg
32
+ end
33
+
34
+ arg.each do |k, v|
35
+ instance_variable_set "@#{k}", v
36
+ end
37
+ else
38
+ super arg
39
+ end
40
+ end
41
+
42
+ # Override to_s to display a friendly error message
43
+ def to_s
44
+ message
45
+ end
46
+
47
+ def message
48
+ if @message.nil?
49
+ msg = "Error message: the server returns an error"
50
+ else
51
+ msg = @message
52
+ end
53
+
54
+ msg += "\nHTTP status code: #{code}" if code
55
+ msg += "\nResponse headers: #{response_headers}" if response_headers
56
+ msg += "\nResponse body: #{response_body}" if response_body
57
+
58
+ msg
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end