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,348 @@
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 BatchResponsePublicDefaultAssociation
21
+ attr_accessor :status
22
+
23
+ attr_accessor :results
24
+
25
+ attr_accessor :num_errors
26
+
27
+ attr_accessor :errors
28
+
29
+ attr_accessor :requested_at
30
+
31
+ attr_accessor :started_at
32
+
33
+ attr_accessor :completed_at
34
+
35
+ attr_accessor :links
36
+
37
+ class EnumAttributeValidator
38
+ attr_reader :datatype
39
+ attr_reader :allowable_values
40
+
41
+ def initialize(datatype, allowable_values)
42
+ @allowable_values = allowable_values.map do |value|
43
+ case datatype.to_s
44
+ when /Integer/i
45
+ value.to_i
46
+ when /Float/i
47
+ value.to_f
48
+ else
49
+ value
50
+ end
51
+ end
52
+ end
53
+
54
+ def valid?(value)
55
+ !value || allowable_values.include?(value)
56
+ end
57
+ end
58
+
59
+ # Attribute mapping from ruby-style variable name to JSON key.
60
+ def self.attribute_map
61
+ {
62
+ :'status' => :'status',
63
+ :'results' => :'results',
64
+ :'num_errors' => :'numErrors',
65
+ :'errors' => :'errors',
66
+ :'requested_at' => :'requestedAt',
67
+ :'started_at' => :'startedAt',
68
+ :'completed_at' => :'completedAt',
69
+ :'links' => :'links'
70
+ }
71
+ end
72
+
73
+ # Returns all the JSON keys this model knows about
74
+ def self.acceptable_attributes
75
+ attribute_map.values
76
+ end
77
+
78
+ # Attribute type mapping.
79
+ def self.openapi_types
80
+ {
81
+ :'status' => :'String',
82
+ :'results' => :'Array<PublicDefaultAssociation>',
83
+ :'num_errors' => :'Integer',
84
+ :'errors' => :'Array<StandardError>',
85
+ :'requested_at' => :'Time',
86
+ :'started_at' => :'Time',
87
+ :'completed_at' => :'Time',
88
+ :'links' => :'Hash<String, String>'
89
+ }
90
+ end
91
+
92
+ # List of attributes with nullable: true
93
+ def self.openapi_nullable
94
+ Set.new([
95
+ ])
96
+ end
97
+
98
+ # Initializes the object
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ def initialize(attributes = {})
101
+ if (!attributes.is_a?(Hash))
102
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Crm::Associations::V4::BatchResponsePublicDefaultAssociation` initialize method"
103
+ end
104
+
105
+ # check to see if the attribute exists and convert string to symbol for hash key
106
+ attributes = attributes.each_with_object({}) { |(k, v), h|
107
+ if (!self.class.attribute_map.key?(k.to_sym))
108
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Crm::Associations::V4::BatchResponsePublicDefaultAssociation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
109
+ end
110
+ h[k.to_sym] = v
111
+ }
112
+
113
+ if attributes.key?(:'status')
114
+ self.status = attributes[:'status']
115
+ end
116
+
117
+ if attributes.key?(:'results')
118
+ if (value = attributes[:'results']).is_a?(Array)
119
+ self.results = value
120
+ end
121
+ end
122
+
123
+ if attributes.key?(:'num_errors')
124
+ self.num_errors = attributes[:'num_errors']
125
+ end
126
+
127
+ if attributes.key?(:'errors')
128
+ if (value = attributes[:'errors']).is_a?(Array)
129
+ self.errors = value
130
+ end
131
+ end
132
+
133
+ if attributes.key?(:'requested_at')
134
+ self.requested_at = attributes[:'requested_at']
135
+ end
136
+
137
+ if attributes.key?(:'started_at')
138
+ self.started_at = attributes[:'started_at']
139
+ end
140
+
141
+ if attributes.key?(:'completed_at')
142
+ self.completed_at = attributes[:'completed_at']
143
+ end
144
+
145
+ if attributes.key?(:'links')
146
+ if (value = attributes[:'links']).is_a?(Hash)
147
+ self.links = value
148
+ end
149
+ end
150
+ end
151
+
152
+ # Show invalid properties with the reasons. Usually used together with valid?
153
+ # @return Array for valid properties with the reasons
154
+ def list_invalid_properties
155
+ invalid_properties = Array.new
156
+ if @status.nil?
157
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
158
+ end
159
+
160
+ if @results.nil?
161
+ invalid_properties.push('invalid value for "results", results cannot be nil.')
162
+ end
163
+
164
+ if @started_at.nil?
165
+ invalid_properties.push('invalid value for "started_at", started_at cannot be nil.')
166
+ end
167
+
168
+ if @completed_at.nil?
169
+ invalid_properties.push('invalid value for "completed_at", completed_at cannot be nil.')
170
+ end
171
+
172
+ invalid_properties
173
+ end
174
+
175
+ # Check to see if the all the properties in the model are valid
176
+ # @return true if the model is valid
177
+ def valid?
178
+ return false if @status.nil?
179
+ status_validator = EnumAttributeValidator.new('String', ["PENDING", "PROCESSING", "CANCELED", "COMPLETE"])
180
+ return false unless status_validator.valid?(@status)
181
+ return false if @results.nil?
182
+ return false if @started_at.nil?
183
+ return false if @completed_at.nil?
184
+ true
185
+ end
186
+
187
+ # Custom attribute writer method checking allowed values (enum).
188
+ # @param [Object] status Object to be assigned
189
+ def status=(status)
190
+ validator = EnumAttributeValidator.new('String', ["PENDING", "PROCESSING", "CANCELED", "COMPLETE"])
191
+ unless validator.valid?(status)
192
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
193
+ end
194
+ @status = status
195
+ end
196
+
197
+ # Checks equality by comparing each attribute.
198
+ # @param [Object] Object to be compared
199
+ def ==(o)
200
+ return true if self.equal?(o)
201
+ self.class == o.class &&
202
+ status == o.status &&
203
+ results == o.results &&
204
+ num_errors == o.num_errors &&
205
+ errors == o.errors &&
206
+ requested_at == o.requested_at &&
207
+ started_at == o.started_at &&
208
+ completed_at == o.completed_at &&
209
+ links == o.links
210
+ end
211
+
212
+ # @see the `==` method
213
+ # @param [Object] Object to be compared
214
+ def eql?(o)
215
+ self == o
216
+ end
217
+
218
+ # Calculates hash code according to all attributes.
219
+ # @return [Integer] Hash code
220
+ def hash
221
+ [status, results, num_errors, errors, requested_at, started_at, completed_at, links].hash
222
+ end
223
+
224
+ # Builds the object from hash
225
+ # @param [Hash] attributes Model attributes in the form of hash
226
+ # @return [Object] Returns the model itself
227
+ def self.build_from_hash(attributes)
228
+ new.build_from_hash(attributes)
229
+ end
230
+
231
+ # Builds the object from hash
232
+ # @param [Hash] attributes Model attributes in the form of hash
233
+ # @return [Object] Returns the model itself
234
+ def build_from_hash(attributes)
235
+ return nil unless attributes.is_a?(Hash)
236
+ attributes = attributes.transform_keys(&:to_sym)
237
+ self.class.openapi_types.each_pair do |key, type|
238
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
239
+ self.send("#{key}=", nil)
240
+ elsif type =~ /\AArray<(.*)>/i
241
+ # check to ensure the input is an array given that the attribute
242
+ # is documented as an array but the input is not
243
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
244
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
245
+ end
246
+ elsif !attributes[self.class.attribute_map[key]].nil?
247
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
248
+ end
249
+ end
250
+
251
+ self
252
+ end
253
+
254
+ # Deserializes the data based on type
255
+ # @param string type Data type
256
+ # @param string value Value to be deserialized
257
+ # @return [Object] Deserialized data
258
+ def _deserialize(type, value)
259
+ case type.to_sym
260
+ when :Time
261
+ Time.parse(value)
262
+ when :Date
263
+ Date.parse(value)
264
+ when :String
265
+ value.to_s
266
+ when :Integer
267
+ value.to_i
268
+ when :Float
269
+ value.to_f
270
+ when :Boolean
271
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
272
+ true
273
+ else
274
+ false
275
+ end
276
+ when :Object
277
+ # generic object (usually a Hash), return directly
278
+ value
279
+ when /\AArray<(?<inner_type>.+)>\z/
280
+ inner_type = Regexp.last_match[:inner_type]
281
+ value.map { |v| _deserialize(inner_type, v) }
282
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
283
+ k_type = Regexp.last_match[:k_type]
284
+ v_type = Regexp.last_match[:v_type]
285
+ {}.tap do |hash|
286
+ value.each do |k, v|
287
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
288
+ end
289
+ end
290
+ else # model
291
+ # models (e.g. Pet) or oneOf
292
+ klass = Hubspot::Crm::Associations::V4.const_get(type)
293
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
294
+ end
295
+ end
296
+
297
+ # Returns the string representation of the object
298
+ # @return [String] String presentation of the object
299
+ def to_s
300
+ to_hash.to_s
301
+ end
302
+
303
+ # to_body is an alias to to_hash (backward compatibility)
304
+ # @return [Hash] Returns the object in the form of hash
305
+ def to_body
306
+ to_hash
307
+ end
308
+
309
+ # Returns the object in the form of hash
310
+ # @return [Hash] Returns the object in the form of hash
311
+ def to_hash
312
+ hash = {}
313
+ self.class.attribute_map.each_pair do |attr, param|
314
+ value = self.send(attr)
315
+ if value.nil?
316
+ is_nullable = self.class.openapi_nullable.include?(attr)
317
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
318
+ end
319
+
320
+ hash[param] = _to_hash(value)
321
+ end
322
+ hash
323
+ end
324
+
325
+ # Outputs non-array value in the form of hash
326
+ # For object, use to_hash. Otherwise, just return the value
327
+ # @param [Object] value Any valid value
328
+ # @return [Hash] Returns the value in the form of hash
329
+ def _to_hash(value)
330
+ if value.is_a?(Array)
331
+ value.compact.map { |v| _to_hash(v) }
332
+ elsif value.is_a?(Hash)
333
+ {}.tap do |hash|
334
+ value.each { |k, v| hash[k] = _to_hash(v) }
335
+ end
336
+ elsif value.respond_to? :to_hash
337
+ value.to_hash
338
+ else
339
+ value
340
+ end
341
+ end
342
+
343
+ end
344
+
345
+ end
346
+ end
347
+ end
348
+ end
@@ -0,0 +1,232 @@
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 CollectionResponseAssociationSpecWithLabelNoPaging
21
+ attr_accessor :results
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'results' => :'results'
27
+ }
28
+ end
29
+
30
+ # Returns all the JSON keys this model knows about
31
+ def self.acceptable_attributes
32
+ attribute_map.values
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'results' => :'Array<AssociationSpecWithLabel>'
39
+ }
40
+ end
41
+
42
+ # List of attributes with nullable: true
43
+ def self.openapi_nullable
44
+ Set.new([
45
+ ])
46
+ end
47
+
48
+ # Initializes the object
49
+ # @param [Hash] attributes Model attributes in the form of hash
50
+ def initialize(attributes = {})
51
+ if (!attributes.is_a?(Hash))
52
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Crm::Associations::V4::CollectionResponseAssociationSpecWithLabelNoPaging` initialize method"
53
+ end
54
+
55
+ # check to see if the attribute exists and convert string to symbol for hash key
56
+ attributes = attributes.each_with_object({}) { |(k, v), h|
57
+ if (!self.class.attribute_map.key?(k.to_sym))
58
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Crm::Associations::V4::CollectionResponseAssociationSpecWithLabelNoPaging`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
59
+ end
60
+ h[k.to_sym] = v
61
+ }
62
+
63
+ if attributes.key?(:'results')
64
+ if (value = attributes[:'results']).is_a?(Array)
65
+ self.results = value
66
+ end
67
+ end
68
+ end
69
+
70
+ # Show invalid properties with the reasons. Usually used together with valid?
71
+ # @return Array for valid properties with the reasons
72
+ def list_invalid_properties
73
+ invalid_properties = Array.new
74
+ if @results.nil?
75
+ invalid_properties.push('invalid value for "results", results cannot be nil.')
76
+ end
77
+
78
+ invalid_properties
79
+ end
80
+
81
+ # Check to see if the all the properties in the model are valid
82
+ # @return true if the model is valid
83
+ def valid?
84
+ return false if @results.nil?
85
+ true
86
+ end
87
+
88
+ # Checks equality by comparing each attribute.
89
+ # @param [Object] Object to be compared
90
+ def ==(o)
91
+ return true if self.equal?(o)
92
+ self.class == o.class &&
93
+ results == o.results
94
+ end
95
+
96
+ # @see the `==` method
97
+ # @param [Object] Object to be compared
98
+ def eql?(o)
99
+ self == o
100
+ end
101
+
102
+ # Calculates hash code according to all attributes.
103
+ # @return [Integer] Hash code
104
+ def hash
105
+ [results].hash
106
+ end
107
+
108
+ # Builds the object from hash
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ # @return [Object] Returns the model itself
111
+ def self.build_from_hash(attributes)
112
+ new.build_from_hash(attributes)
113
+ end
114
+
115
+ # Builds the object from hash
116
+ # @param [Hash] attributes Model attributes in the form of hash
117
+ # @return [Object] Returns the model itself
118
+ def build_from_hash(attributes)
119
+ return nil unless attributes.is_a?(Hash)
120
+ attributes = attributes.transform_keys(&:to_sym)
121
+ self.class.openapi_types.each_pair do |key, type|
122
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
123
+ self.send("#{key}=", nil)
124
+ elsif type =~ /\AArray<(.*)>/i
125
+ # check to ensure the input is an array given that the attribute
126
+ # is documented as an array but the input is not
127
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
128
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
129
+ end
130
+ elsif !attributes[self.class.attribute_map[key]].nil?
131
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
132
+ end
133
+ end
134
+
135
+ self
136
+ end
137
+
138
+ # Deserializes the data based on type
139
+ # @param string type Data type
140
+ # @param string value Value to be deserialized
141
+ # @return [Object] Deserialized data
142
+ def _deserialize(type, value)
143
+ case type.to_sym
144
+ when :Time
145
+ Time.parse(value)
146
+ when :Date
147
+ Date.parse(value)
148
+ when :String
149
+ value.to_s
150
+ when :Integer
151
+ value.to_i
152
+ when :Float
153
+ value.to_f
154
+ when :Boolean
155
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
156
+ true
157
+ else
158
+ false
159
+ end
160
+ when :Object
161
+ # generic object (usually a Hash), return directly
162
+ value
163
+ when /\AArray<(?<inner_type>.+)>\z/
164
+ inner_type = Regexp.last_match[:inner_type]
165
+ value.map { |v| _deserialize(inner_type, v) }
166
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
167
+ k_type = Regexp.last_match[:k_type]
168
+ v_type = Regexp.last_match[:v_type]
169
+ {}.tap do |hash|
170
+ value.each do |k, v|
171
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
172
+ end
173
+ end
174
+ else # model
175
+ # models (e.g. Pet) or oneOf
176
+ klass = Hubspot::Crm::Associations::V4.const_get(type)
177
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
178
+ end
179
+ end
180
+
181
+ # Returns the string representation of the object
182
+ # @return [String] String presentation of the object
183
+ def to_s
184
+ to_hash.to_s
185
+ end
186
+
187
+ # to_body is an alias to to_hash (backward compatibility)
188
+ # @return [Hash] Returns the object in the form of hash
189
+ def to_body
190
+ to_hash
191
+ end
192
+
193
+ # Returns the object in the form of hash
194
+ # @return [Hash] Returns the object in the form of hash
195
+ def to_hash
196
+ hash = {}
197
+ self.class.attribute_map.each_pair do |attr, param|
198
+ value = self.send(attr)
199
+ if value.nil?
200
+ is_nullable = self.class.openapi_nullable.include?(attr)
201
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
202
+ end
203
+
204
+ hash[param] = _to_hash(value)
205
+ end
206
+ hash
207
+ end
208
+
209
+ # Outputs non-array value in the form of hash
210
+ # For object, use to_hash. Otherwise, just return the value
211
+ # @param [Object] value Any valid value
212
+ # @return [Hash] Returns the value in the form of hash
213
+ def _to_hash(value)
214
+ if value.is_a?(Array)
215
+ value.compact.map { |v| _to_hash(v) }
216
+ elsif value.is_a?(Hash)
217
+ {}.tap do |hash|
218
+ value.each { |k, v| hash[k] = _to_hash(v) }
219
+ end
220
+ elsif value.respond_to? :to_hash
221
+ value.to_hash
222
+ else
223
+ value
224
+ end
225
+ end
226
+
227
+ end
228
+
229
+ end
230
+ end
231
+ end
232
+ end