hubspot-api-client 16.2.1 → 16.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -1
  3. data/Gemfile.lock +1 -1
  4. data/README.md +33 -1
  5. data/lib/hubspot/codegen/crm/associations/v4/api/batch_api.rb +428 -0
  6. data/lib/hubspot/codegen/crm/associations/v4/api/definitions_api.rb +332 -0
  7. data/lib/hubspot/codegen/crm/associations/v4/api_client.rb +412 -0
  8. data/lib/hubspot/codegen/crm/associations/v4/api_error.rb +63 -0
  9. data/lib/hubspot/codegen/crm/associations/v4/configuration.rb +296 -0
  10. data/lib/hubspot/codegen/crm/associations/v4/models/association_spec.rb +278 -0
  11. data/lib/hubspot/codegen/crm/associations/v4/models/association_spec_with_label.rb +287 -0
  12. data/lib/hubspot/codegen/crm/associations/v4/models/batch_input_public_association_multi_archive.rb +232 -0
  13. data/lib/hubspot/codegen/crm/associations/v4/models/batch_input_public_association_multi_post.rb +232 -0
  14. data/lib/hubspot/codegen/crm/associations/v4/models/batch_input_public_default_association_multi_post.rb +232 -0
  15. data/lib/hubspot/codegen/crm/associations/v4/models/batch_input_public_fetch_associations_batch_request.rb +232 -0
  16. data/lib/hubspot/codegen/crm/associations/v4/models/batch_response_labels_between_object_pair.rb +328 -0
  17. data/lib/hubspot/codegen/crm/associations/v4/models/batch_response_labels_between_object_pair_with_errors.rb +348 -0
  18. data/lib/hubspot/codegen/crm/associations/v4/models/batch_response_public_association_multi_with_label.rb +328 -0
  19. data/lib/hubspot/codegen/crm/associations/v4/models/batch_response_public_association_multi_with_label_with_errors.rb +348 -0
  20. data/lib/hubspot/codegen/crm/associations/v4/models/batch_response_public_default_association.rb +348 -0
  21. data/lib/hubspot/codegen/crm/associations/v4/models/collection_response_association_spec_with_label_no_paging.rb +232 -0
  22. data/lib/hubspot/codegen/crm/associations/v4/models/error.rb +307 -0
  23. data/lib/hubspot/codegen/crm/associations/v4/models/error_category.rb +278 -0
  24. data/lib/hubspot/codegen/crm/associations/v4/models/error_detail.rb +273 -0
  25. data/lib/hubspot/codegen/crm/associations/v4/models/labels_between_object_pair.rb +288 -0
  26. data/lib/hubspot/codegen/crm/associations/v4/models/multi_associated_object_with_label.rb +246 -0
  27. data/lib/hubspot/codegen/crm/associations/v4/models/next_page.rb +239 -0
  28. data/lib/hubspot/codegen/crm/associations/v4/models/paging.rb +234 -0
  29. data/lib/hubspot/codegen/crm/associations/v4/models/previous_page.rb +239 -0
  30. data/lib/hubspot/codegen/crm/associations/v4/models/public_association_definition_create_request.rb +244 -0
  31. data/lib/hubspot/codegen/crm/associations/v4/models/public_association_definition_update_request.rb +244 -0
  32. data/lib/hubspot/codegen/crm/associations/v4/models/public_association_multi_archive.rb +246 -0
  33. data/lib/hubspot/codegen/crm/associations/v4/models/public_association_multi_post.rb +260 -0
  34. data/lib/hubspot/codegen/crm/associations/v4/models/public_association_multi_with_label.rb +255 -0
  35. data/lib/hubspot/codegen/crm/associations/v4/models/public_default_association.rb +258 -0
  36. data/lib/hubspot/codegen/crm/associations/v4/models/public_default_association_multi_post.rb +244 -0
  37. data/lib/hubspot/codegen/crm/associations/v4/models/public_fetch_associations_batch_request.rb +239 -0
  38. data/lib/hubspot/codegen/crm/associations/v4/models/public_object_id.rb +230 -0
  39. data/lib/hubspot/codegen/crm/associations/v4/models/standard_error.rb +324 -0
  40. data/lib/hubspot/codegen/crm/properties/models/property.rb +14 -4
  41. data/lib/hubspot/codegen/crm/properties/models/property_create.rb +38 -8
  42. data/lib/hubspot/codegen/crm/properties/models/property_update.rb +18 -8
  43. data/lib/hubspot/codegen/oauth/api/access_tokens_api.rb +0 -2
  44. data/lib/hubspot/codegen/oauth/api/refresh_tokens_api.rb +5 -7
  45. data/lib/hubspot/codegen/oauth/api/tokens_api.rb +0 -2
  46. data/lib/hubspot/codegen/oauth/api_client.rb +0 -2
  47. data/lib/hubspot/codegen/oauth/api_error.rb +0 -2
  48. data/lib/hubspot/codegen/oauth/configuration.rb +0 -2
  49. data/lib/hubspot/codegen/oauth/models/access_token_info_response.rb +0 -2
  50. data/lib/hubspot/codegen/oauth/models/error.rb +0 -2
  51. data/lib/hubspot/codegen/oauth/models/error_detail.rb +0 -2
  52. data/lib/hubspot/codegen/oauth/models/refresh_token_info_response.rb +0 -2
  53. data/lib/hubspot/codegen/oauth/models/token_response_if.rb +31 -33
  54. data/lib/hubspot/discovery/crm/associations/client.rb +3 -1
  55. data/lib/hubspot/discovery/crm/associations/v4/api/batch_api.rb +15 -0
  56. data/lib/hubspot/discovery/crm/associations/v4/api/definitions_api.rb +15 -0
  57. data/lib/hubspot/discovery/crm/associations/v4/client.rb +21 -0
  58. data/lib/hubspot/helpers/get_all_helper.rb +2 -1
  59. data/lib/hubspot/version.rb +1 -1
  60. data/spec/discovery/cms/blogs/client_spec.rb +9 -0
  61. data/spec/discovery/cms/client_spec.rb +13 -0
  62. data/spec/discovery/crm/associations/client_spec.rb +7 -0
  63. data/spec/discovery/crm/associations/v4/batch_api_spec.rb +11 -0
  64. data/spec/discovery/crm/associations/v4/definitions_api_spec.rb +10 -0
  65. data/spec/discovery/crm/client_spec.rb +21 -0
  66. data/spec/discovery/crm/extensions/client_spec.rb +11 -0
  67. data/spec/discovery/crm/objects/client_spec.rb +13 -0
  68. data/spec/discovery/marketing/client_spec.rb +9 -0
  69. metadata +58 -2
@@ -0,0 +1,296 @@
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
+ class Configuration
18
+ # Defines url scheme
19
+ attr_accessor :scheme
20
+
21
+ # Defines url host
22
+ attr_accessor :host
23
+
24
+ # Defines url base path
25
+ attr_accessor :base_path
26
+
27
+ # Define server configuration index
28
+ attr_accessor :server_index
29
+
30
+ # Define server operation configuration index
31
+ attr_accessor :server_operation_index
32
+
33
+ # Default server variables
34
+ attr_accessor :server_variables
35
+
36
+ # Default server operation variables
37
+ attr_accessor :server_operation_variables
38
+
39
+ # Defines API keys used with API Key authentications.
40
+ #
41
+ # @return [Hash] key: parameter name, value: parameter value (API key)
42
+ #
43
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
44
+ # config.api_key['api_key'] = 'xxx'
45
+ attr_accessor :api_key
46
+
47
+ # Defines API key prefixes used with API Key authentications.
48
+ #
49
+ # @return [Hash] key: parameter name, value: API key prefix
50
+ #
51
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
52
+ # config.api_key_prefix['api_key'] = 'Token'
53
+ attr_accessor :api_key_prefix
54
+
55
+ # Defines the username used with HTTP basic authentication.
56
+ #
57
+ # @return [String]
58
+ attr_accessor :username
59
+
60
+ # Defines the password used with HTTP basic authentication.
61
+ #
62
+ # @return [String]
63
+ attr_accessor :password
64
+
65
+ # Defines the access token (Bearer) used with OAuth2.
66
+ attr_accessor :access_token
67
+
68
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
69
+ # details will be logged with `logger.debug` (see the `logger` attribute).
70
+ # Default to false.
71
+ #
72
+ # @return [true, false]
73
+ attr_accessor :debugging
74
+
75
+ # Defines the logger used for debugging.
76
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
77
+ #
78
+ # @return [#debug]
79
+ attr_accessor :logger
80
+
81
+ # Defines the temporary folder to store downloaded files
82
+ # (for API endpoints that have file response).
83
+ # Default to use `Tempfile`.
84
+ #
85
+ # @return [String]
86
+ attr_accessor :temp_folder_path
87
+
88
+ # The time limit for HTTP request in seconds.
89
+ # Default to 0 (never times out).
90
+ attr_accessor :timeout
91
+
92
+ # Set this to false to skip client side validation in the operation.
93
+ # Default to true.
94
+ # @return [true, false]
95
+ attr_accessor :client_side_validation
96
+
97
+ ### TLS/SSL setting
98
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
99
+ # Default to true.
100
+ #
101
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
102
+ #
103
+ # @return [true, false]
104
+ attr_accessor :verify_ssl
105
+
106
+ ### TLS/SSL setting
107
+ # Set this to false to skip verifying SSL host name
108
+ # Default to true.
109
+ #
110
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
111
+ #
112
+ # @return [true, false]
113
+ attr_accessor :verify_ssl_host
114
+
115
+ ### TLS/SSL setting
116
+ # Set this to customize the certificate file to verify the peer.
117
+ #
118
+ # @return [String] the path to the certificate file
119
+ #
120
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
121
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
122
+ attr_accessor :ssl_ca_cert
123
+
124
+ ### TLS/SSL setting
125
+ # Client certificate file (for client certificate)
126
+ attr_accessor :cert_file
127
+
128
+ ### TLS/SSL setting
129
+ # Client private key file (for client certificate)
130
+ attr_accessor :key_file
131
+
132
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
133
+ # Default to nil.
134
+ #
135
+ # @see The params_encoding option of Ethon. Related source code:
136
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
137
+ attr_accessor :params_encoding
138
+
139
+
140
+ attr_accessor :inject_format
141
+
142
+ attr_accessor :force_ending_format
143
+
144
+ attr_accessor :error_handler
145
+
146
+ def initialize
147
+ @scheme = 'https'
148
+ @host = 'api.hubapi.com'
149
+ @base_path = ''
150
+ @server_index = 0
151
+ @server_operation_index = {}
152
+ @server_variables = {}
153
+ @server_operation_variables = {}
154
+ @api_key = {}
155
+ @api_key_prefix = {}
156
+ @client_side_validation = true
157
+ @verify_ssl = true
158
+ @verify_ssl_host = true
159
+ @cert_file = nil
160
+ @key_file = nil
161
+ @timeout = 0
162
+ @params_encoding = nil
163
+ @debugging = false
164
+ @inject_format = false
165
+ @force_ending_format = false
166
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
167
+ # error_handler params: { 'status_code': { max_retries: ..., seconds_delay: ... }, ... }
168
+ @error_handler = {}
169
+
170
+ yield(self) if block_given?
171
+ end
172
+
173
+ # The default Configuration object.
174
+ def self.default
175
+ @@default ||= Configuration.new
176
+ end
177
+
178
+ def configure
179
+ yield(self) if block_given?
180
+ end
181
+
182
+ def scheme=(scheme)
183
+ # remove :// from scheme
184
+ @scheme = scheme.sub(/:\/\//, '')
185
+ end
186
+
187
+ def host=(host)
188
+ # remove http(s):// and anything after a slash
189
+ @host = host.sub(/https?:\/\//, '').split('/').first
190
+ end
191
+
192
+ def base_path=(base_path)
193
+ # Add leading and trailing slashes to base_path
194
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
195
+ @base_path = '' if @base_path == '/'
196
+ end
197
+
198
+ # Returns base URL for specified operation based on server settings
199
+ def base_url(operation = nil)
200
+ index = server_operation_index.fetch(operation, server_index)
201
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
202
+
203
+ server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
204
+ end
205
+
206
+ # Gets API key (with prefix if set).
207
+ # @param [String] param_name the parameter name of API key auth
208
+ def api_key_with_prefix(param_name, param_alias = nil)
209
+ key = @api_key[param_name]
210
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
211
+ if @api_key_prefix[param_name]
212
+ "#{@api_key_prefix[param_name]} #{key}"
213
+ else
214
+ key
215
+ end
216
+ end
217
+
218
+ # Gets Basic Auth token string
219
+ def basic_auth_token
220
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
221
+ end
222
+
223
+ # Returns Auth Settings hash for api client.
224
+ def auth_settings
225
+ {
226
+ 'hapikey' =>
227
+ {
228
+ type: 'api_key',
229
+ in: 'query',
230
+ key: 'hapikey',
231
+ value: api_key_with_prefix('hapikey')
232
+ },
233
+ 'oauth2' =>
234
+ {
235
+ type: 'oauth2',
236
+ in: 'header',
237
+ key: 'Authorization',
238
+ value: "Bearer #{access_token}"
239
+ },
240
+ }
241
+ end
242
+
243
+ # Returns an array of Server setting
244
+ def server_settings
245
+ [
246
+ {
247
+ url: "https://api.hubapi.com",
248
+ description: "No description provided",
249
+ }
250
+ ]
251
+ end
252
+
253
+ def operation_server_settings
254
+ {
255
+ }
256
+ end
257
+
258
+ # Returns URL based on server settings
259
+ #
260
+ # @param index array index of the server settings
261
+ # @param variables hash of variable and the corresponding value
262
+ def server_url(index, variables = {}, servers = nil)
263
+ servers = server_settings if servers == nil
264
+
265
+ # check array index out of bound
266
+ if (index < 0 || index >= servers.size)
267
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
268
+ end
269
+
270
+ server = servers[index]
271
+ url = server[:url]
272
+
273
+ return url unless server.key? :variables
274
+
275
+ # go through variable and assign a value
276
+ server[:variables].each do |name, variable|
277
+ if variables.key?(name)
278
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
279
+ url.gsub! "{" + name.to_s + "}", variables[name]
280
+ else
281
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
282
+ end
283
+ else
284
+ # use default value
285
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
286
+ end
287
+ end
288
+
289
+ url
290
+ end
291
+
292
+ end
293
+ end
294
+ end
295
+ end
296
+ end
@@ -0,0 +1,278 @@
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 'time'
15
+
16
+ module Hubspot
17
+ module Crm
18
+ module Associations
19
+ module V4
20
+ class AssociationSpec
21
+ attr_accessor :association_category
22
+
23
+ attr_accessor :association_type_id
24
+
25
+ class EnumAttributeValidator
26
+ attr_reader :datatype
27
+ attr_reader :allowable_values
28
+
29
+ def initialize(datatype, allowable_values)
30
+ @allowable_values = allowable_values.map do |value|
31
+ case datatype.to_s
32
+ when /Integer/i
33
+ value.to_i
34
+ when /Float/i
35
+ value.to_f
36
+ else
37
+ value
38
+ end
39
+ end
40
+ end
41
+
42
+ def valid?(value)
43
+ !value || allowable_values.include?(value)
44
+ end
45
+ end
46
+
47
+ # Attribute mapping from ruby-style variable name to JSON key.
48
+ def self.attribute_map
49
+ {
50
+ :'association_category' => :'associationCategory',
51
+ :'association_type_id' => :'associationTypeId'
52
+ }
53
+ end
54
+
55
+ # Returns all the JSON keys this model knows about
56
+ def self.acceptable_attributes
57
+ attribute_map.values
58
+ end
59
+
60
+ # Attribute type mapping.
61
+ def self.openapi_types
62
+ {
63
+ :'association_category' => :'String',
64
+ :'association_type_id' => :'Integer'
65
+ }
66
+ end
67
+
68
+ # List of attributes with nullable: true
69
+ def self.openapi_nullable
70
+ Set.new([
71
+ ])
72
+ end
73
+
74
+ # Initializes the object
75
+ # @param [Hash] attributes Model attributes in the form of hash
76
+ def initialize(attributes = {})
77
+ if (!attributes.is_a?(Hash))
78
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Crm::Associations::V4::AssociationSpec` initialize method"
79
+ end
80
+
81
+ # check to see if the attribute exists and convert string to symbol for hash key
82
+ attributes = attributes.each_with_object({}) { |(k, v), h|
83
+ if (!self.class.attribute_map.key?(k.to_sym))
84
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Crm::Associations::V4::AssociationSpec`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
85
+ end
86
+ h[k.to_sym] = v
87
+ }
88
+
89
+ if attributes.key?(:'association_category')
90
+ self.association_category = attributes[:'association_category']
91
+ end
92
+
93
+ if attributes.key?(:'association_type_id')
94
+ self.association_type_id = attributes[:'association_type_id']
95
+ end
96
+ end
97
+
98
+ # Show invalid properties with the reasons. Usually used together with valid?
99
+ # @return Array for valid properties with the reasons
100
+ def list_invalid_properties
101
+ invalid_properties = Array.new
102
+ if @association_category.nil?
103
+ invalid_properties.push('invalid value for "association_category", association_category cannot be nil.')
104
+ end
105
+
106
+ if @association_type_id.nil?
107
+ invalid_properties.push('invalid value for "association_type_id", association_type_id cannot be nil.')
108
+ end
109
+
110
+ invalid_properties
111
+ end
112
+
113
+ # Check to see if the all the properties in the model are valid
114
+ # @return true if the model is valid
115
+ def valid?
116
+ return false if @association_category.nil?
117
+ association_category_validator = EnumAttributeValidator.new('String', ["HUBSPOT_DEFINED", "USER_DEFINED", "INTEGRATOR_DEFINED"])
118
+ return false unless association_category_validator.valid?(@association_category)
119
+ return false if @association_type_id.nil?
120
+ true
121
+ end
122
+
123
+ # Custom attribute writer method checking allowed values (enum).
124
+ # @param [Object] association_category Object to be assigned
125
+ def association_category=(association_category)
126
+ validator = EnumAttributeValidator.new('String', ["HUBSPOT_DEFINED", "USER_DEFINED", "INTEGRATOR_DEFINED"])
127
+ unless validator.valid?(association_category)
128
+ fail ArgumentError, "invalid value for \"association_category\", must be one of #{validator.allowable_values}."
129
+ end
130
+ @association_category = association_category
131
+ end
132
+
133
+ # Checks equality by comparing each attribute.
134
+ # @param [Object] Object to be compared
135
+ def ==(o)
136
+ return true if self.equal?(o)
137
+ self.class == o.class &&
138
+ association_category == o.association_category &&
139
+ association_type_id == o.association_type_id
140
+ end
141
+
142
+ # @see the `==` method
143
+ # @param [Object] Object to be compared
144
+ def eql?(o)
145
+ self == o
146
+ end
147
+
148
+ # Calculates hash code according to all attributes.
149
+ # @return [Integer] Hash code
150
+ def hash
151
+ [association_category, association_type_id].hash
152
+ end
153
+
154
+ # Builds the object from hash
155
+ # @param [Hash] attributes Model attributes in the form of hash
156
+ # @return [Object] Returns the model itself
157
+ def self.build_from_hash(attributes)
158
+ new.build_from_hash(attributes)
159
+ end
160
+
161
+ # Builds the object from hash
162
+ # @param [Hash] attributes Model attributes in the form of hash
163
+ # @return [Object] Returns the model itself
164
+ def build_from_hash(attributes)
165
+ return nil unless attributes.is_a?(Hash)
166
+ attributes = attributes.transform_keys(&:to_sym)
167
+ self.class.openapi_types.each_pair do |key, type|
168
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
169
+ self.send("#{key}=", nil)
170
+ elsif type =~ /\AArray<(.*)>/i
171
+ # check to ensure the input is an array given that the attribute
172
+ # is documented as an array but the input is not
173
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
174
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
175
+ end
176
+ elsif !attributes[self.class.attribute_map[key]].nil?
177
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
178
+ end
179
+ end
180
+
181
+ self
182
+ end
183
+
184
+ # Deserializes the data based on type
185
+ # @param string type Data type
186
+ # @param string value Value to be deserialized
187
+ # @return [Object] Deserialized data
188
+ def _deserialize(type, value)
189
+ case type.to_sym
190
+ when :Time
191
+ Time.parse(value)
192
+ when :Date
193
+ Date.parse(value)
194
+ when :String
195
+ value.to_s
196
+ when :Integer
197
+ value.to_i
198
+ when :Float
199
+ value.to_f
200
+ when :Boolean
201
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
202
+ true
203
+ else
204
+ false
205
+ end
206
+ when :Object
207
+ # generic object (usually a Hash), return directly
208
+ value
209
+ when /\AArray<(?<inner_type>.+)>\z/
210
+ inner_type = Regexp.last_match[:inner_type]
211
+ value.map { |v| _deserialize(inner_type, v) }
212
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
213
+ k_type = Regexp.last_match[:k_type]
214
+ v_type = Regexp.last_match[:v_type]
215
+ {}.tap do |hash|
216
+ value.each do |k, v|
217
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
218
+ end
219
+ end
220
+ else # model
221
+ # models (e.g. Pet) or oneOf
222
+ klass = Hubspot::Crm::Associations::V4.const_get(type)
223
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
224
+ end
225
+ end
226
+
227
+ # Returns the string representation of the object
228
+ # @return [String] String presentation of the object
229
+ def to_s
230
+ to_hash.to_s
231
+ end
232
+
233
+ # to_body is an alias to to_hash (backward compatibility)
234
+ # @return [Hash] Returns the object in the form of hash
235
+ def to_body
236
+ to_hash
237
+ end
238
+
239
+ # Returns the object in the form of hash
240
+ # @return [Hash] Returns the object in the form of hash
241
+ def to_hash
242
+ hash = {}
243
+ self.class.attribute_map.each_pair do |attr, param|
244
+ value = self.send(attr)
245
+ if value.nil?
246
+ is_nullable = self.class.openapi_nullable.include?(attr)
247
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
248
+ end
249
+
250
+ hash[param] = _to_hash(value)
251
+ end
252
+ hash
253
+ end
254
+
255
+ # Outputs non-array value in the form of hash
256
+ # For object, use to_hash. Otherwise, just return the value
257
+ # @param [Object] value Any valid value
258
+ # @return [Hash] Returns the value in the form of hash
259
+ def _to_hash(value)
260
+ if value.is_a?(Array)
261
+ value.compact.map { |v| _to_hash(v) }
262
+ elsif value.is_a?(Hash)
263
+ {}.tap do |hash|
264
+ value.each { |k, v| hash[k] = _to_hash(v) }
265
+ end
266
+ elsif value.respond_to? :to_hash
267
+ value.to_hash
268
+ else
269
+ value
270
+ end
271
+ end
272
+
273
+ end
274
+
275
+ end
276
+ end
277
+ end
278
+ end