carbon_ruby_sdk 0.2.35 → 0.2.37

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +3 -3
  3. data/README.md +335 -2
  4. data/lib/carbon_ruby_sdk/api/crm_api.rb +909 -0
  5. data/lib/carbon_ruby_sdk/models/account.rb +398 -0
  6. data/lib/carbon_ruby_sdk/models/account_filters.rb +226 -0
  7. data/lib/carbon_ruby_sdk/models/account_response.rb +246 -0
  8. data/lib/carbon_ruby_sdk/models/accounts_order_by.rb +39 -0
  9. data/lib/carbon_ruby_sdk/models/accounts_order_by_nullable.rb +39 -0
  10. data/lib/carbon_ruby_sdk/models/accounts_request.rb +293 -0
  11. data/lib/carbon_ruby_sdk/models/address.rb +276 -0
  12. data/lib/carbon_ruby_sdk/models/base_includes.rb +36 -0
  13. data/lib/carbon_ruby_sdk/models/contact.rb +434 -0
  14. data/lib/carbon_ruby_sdk/models/contact_filters.rb +236 -0
  15. data/lib/carbon_ruby_sdk/models/contacts_order_by.rb +39 -0
  16. data/lib/carbon_ruby_sdk/models/contacts_order_by_nullable.rb +39 -0
  17. data/lib/carbon_ruby_sdk/models/contacts_request.rb +293 -0
  18. data/lib/carbon_ruby_sdk/models/contacts_response.rb +246 -0
  19. data/lib/carbon_ruby_sdk/models/data_source_type.rb +2 -1
  20. data/lib/carbon_ruby_sdk/models/data_source_type_nullable.rb +2 -1
  21. data/lib/carbon_ruby_sdk/models/email.rb +230 -0
  22. data/lib/carbon_ruby_sdk/models/event.rb +370 -0
  23. data/lib/carbon_ruby_sdk/models/file_formats.rb +2 -1
  24. data/lib/carbon_ruby_sdk/models/file_formats_nullable.rb +2 -1
  25. data/lib/carbon_ruby_sdk/models/lead.rb +468 -0
  26. data/lib/carbon_ruby_sdk/models/lead_filters.rb +246 -0
  27. data/lib/carbon_ruby_sdk/models/leads_order_by.rb +38 -0
  28. data/lib/carbon_ruby_sdk/models/leads_order_by_nullable.rb +38 -0
  29. data/lib/carbon_ruby_sdk/models/leads_request.rb +293 -0
  30. data/lib/carbon_ruby_sdk/models/leads_response.rb +246 -0
  31. data/lib/carbon_ruby_sdk/models/opportunities_order_by.rb +40 -0
  32. data/lib/carbon_ruby_sdk/models/opportunities_order_by_nullable.rb +40 -0
  33. data/lib/carbon_ruby_sdk/models/opportunities_request.rb +293 -0
  34. data/lib/carbon_ruby_sdk/models/opportunities_response.rb +246 -0
  35. data/lib/carbon_ruby_sdk/models/opportunity.rb +400 -0
  36. data/lib/carbon_ruby_sdk/models/opportunity_filters.rb +246 -0
  37. data/lib/carbon_ruby_sdk/models/opportunity_status.rb +36 -0
  38. data/lib/carbon_ruby_sdk/models/opportunity_status_nullable.rb +36 -0
  39. data/lib/carbon_ruby_sdk/models/order_dir_v2_nullable.rb +36 -0
  40. data/lib/carbon_ruby_sdk/models/partial_account.rb +216 -0
  41. data/lib/carbon_ruby_sdk/models/partial_account_nullable.rb +216 -0
  42. data/lib/carbon_ruby_sdk/models/partial_contact.rb +216 -0
  43. data/lib/carbon_ruby_sdk/models/partial_contact_nullable.rb +216 -0
  44. data/lib/carbon_ruby_sdk/models/partial_owner.rb +216 -0
  45. data/lib/carbon_ruby_sdk/models/partial_owner_nullable.rb +216 -0
  46. data/lib/carbon_ruby_sdk/models/phone_number.rb +230 -0
  47. data/lib/carbon_ruby_sdk/models/sent_webhook_payload.rb +2 -2
  48. data/lib/carbon_ruby_sdk/models/task.rb +346 -0
  49. data/lib/carbon_ruby_sdk/version.rb +1 -1
  50. data/lib/carbon_ruby_sdk.rb +42 -0
  51. data/spec/api/crm_api_spec.rb +129 -0
  52. data/spec/models/account_filters_spec.rb +34 -0
  53. data/spec/models/account_response_spec.rb +40 -0
  54. data/spec/models/account_spec.rb +118 -0
  55. data/spec/models/accounts_order_by_nullable_spec.rb +22 -0
  56. data/spec/models/accounts_order_by_spec.rb +22 -0
  57. data/spec/models/accounts_request_spec.rb +70 -0
  58. data/spec/models/address_spec.rb +64 -0
  59. data/spec/models/base_includes_spec.rb +22 -0
  60. data/spec/models/contact_filters_spec.rb +40 -0
  61. data/spec/models/contact_spec.rb +136 -0
  62. data/spec/models/contacts_order_by_nullable_spec.rb +22 -0
  63. data/spec/models/contacts_order_by_spec.rb +22 -0
  64. data/spec/models/contacts_request_spec.rb +70 -0
  65. data/spec/models/contacts_response_spec.rb +40 -0
  66. data/spec/models/email_spec.rb +34 -0
  67. data/spec/models/event_spec.rb +106 -0
  68. data/spec/models/lead_filters_spec.rb +46 -0
  69. data/spec/models/lead_spec.rb +154 -0
  70. data/spec/models/leads_order_by_nullable_spec.rb +22 -0
  71. data/spec/models/leads_order_by_spec.rb +22 -0
  72. data/spec/models/leads_request_spec.rb +70 -0
  73. data/spec/models/leads_response_spec.rb +40 -0
  74. data/spec/models/opportunities_order_by_nullable_spec.rb +22 -0
  75. data/spec/models/opportunities_order_by_spec.rb +22 -0
  76. data/spec/models/opportunities_request_spec.rb +70 -0
  77. data/spec/models/opportunities_response_spec.rb +40 -0
  78. data/spec/models/opportunity_filters_spec.rb +46 -0
  79. data/spec/models/opportunity_spec.rb +124 -0
  80. data/spec/models/opportunity_status_nullable_spec.rb +22 -0
  81. data/spec/models/opportunity_status_spec.rb +22 -0
  82. data/spec/models/order_dir_v2_nullable_spec.rb +22 -0
  83. data/spec/models/partial_account_nullable_spec.rb +28 -0
  84. data/spec/models/partial_account_spec.rb +28 -0
  85. data/spec/models/partial_contact_nullable_spec.rb +28 -0
  86. data/spec/models/partial_contact_spec.rb +28 -0
  87. data/spec/models/partial_owner_nullable_spec.rb +28 -0
  88. data/spec/models/partial_owner_spec.rb +28 -0
  89. data/spec/models/phone_number_spec.rb +34 -0
  90. data/spec/models/sent_webhook_payload_spec.rb +1 -1
  91. data/spec/models/task_spec.rb +94 -0
  92. metadata +122 -2
@@ -0,0 +1,468 @@
1
+ =begin
2
+ #Carbon
3
+
4
+ #Connect external data to LLMs, no matter the source.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ =end
8
+
9
+ require 'date'
10
+ require 'time'
11
+
12
+ module Carbon
13
+ class Lead
14
+ attr_accessor :title
15
+
16
+ attr_accessor :description
17
+
18
+ attr_accessor :id
19
+
20
+ attr_accessor :owner
21
+
22
+ attr_accessor :source
23
+
24
+ attr_accessor :status
25
+
26
+ attr_accessor :company
27
+
28
+ attr_accessor :first_name
29
+
30
+ attr_accessor :last_name
31
+
32
+ attr_accessor :addresses
33
+
34
+ attr_accessor :phone_numbers
35
+
36
+ attr_accessor :emails
37
+
38
+ attr_accessor :converted_at
39
+
40
+ attr_accessor :converted_account
41
+
42
+ attr_accessor :converted_contact
43
+
44
+ attr_accessor :last_activity_at
45
+
46
+ attr_accessor :created_at
47
+
48
+ attr_accessor :updated_at
49
+
50
+ attr_accessor :is_deleted
51
+
52
+ attr_accessor :tasks
53
+
54
+ attr_accessor :events
55
+
56
+ attr_accessor :remote_data
57
+
58
+ # Attribute mapping from ruby-style variable name to JSON key.
59
+ def self.attribute_map
60
+ {
61
+ :'title' => :'title',
62
+ :'description' => :'description',
63
+ :'id' => :'id',
64
+ :'owner' => :'owner',
65
+ :'source' => :'source',
66
+ :'status' => :'status',
67
+ :'company' => :'company',
68
+ :'first_name' => :'first_name',
69
+ :'last_name' => :'last_name',
70
+ :'addresses' => :'addresses',
71
+ :'phone_numbers' => :'phone_numbers',
72
+ :'emails' => :'emails',
73
+ :'converted_at' => :'converted_at',
74
+ :'converted_account' => :'converted_account',
75
+ :'converted_contact' => :'converted_contact',
76
+ :'last_activity_at' => :'last_activity_at',
77
+ :'created_at' => :'created_at',
78
+ :'updated_at' => :'updated_at',
79
+ :'is_deleted' => :'is_deleted',
80
+ :'tasks' => :'tasks',
81
+ :'events' => :'events',
82
+ :'remote_data' => :'remote_data'
83
+ }
84
+ end
85
+
86
+ # Returns all the JSON keys this model knows about
87
+ def self.acceptable_attributes
88
+ attribute_map.values
89
+ end
90
+
91
+ # Attribute type mapping.
92
+ def self.openapi_types
93
+ {
94
+ :'title' => :'String',
95
+ :'description' => :'String',
96
+ :'id' => :'String',
97
+ :'owner' => :'PartialOwner',
98
+ :'source' => :'String',
99
+ :'status' => :'String',
100
+ :'company' => :'String',
101
+ :'first_name' => :'String',
102
+ :'last_name' => :'String',
103
+ :'addresses' => :'Array<Address>',
104
+ :'phone_numbers' => :'Array<PhoneNumber>',
105
+ :'emails' => :'Array<Email>',
106
+ :'converted_at' => :'String',
107
+ :'converted_account' => :'PartialAccountNullable',
108
+ :'converted_contact' => :'PartialContactNullable',
109
+ :'last_activity_at' => :'String',
110
+ :'created_at' => :'String',
111
+ :'updated_at' => :'String',
112
+ :'is_deleted' => :'Boolean',
113
+ :'tasks' => :'Array<Task>',
114
+ :'events' => :'Array<Event>',
115
+ :'remote_data' => :'Object'
116
+ }
117
+ end
118
+
119
+ # List of attributes with nullable: true
120
+ def self.openapi_nullable
121
+ Set.new([
122
+ :'title',
123
+ :'description',
124
+ :'source',
125
+ :'status',
126
+ :'company',
127
+ :'first_name',
128
+ :'last_name',
129
+ :'converted_at',
130
+ :'converted_account',
131
+ :'converted_contact',
132
+ :'last_activity_at',
133
+ :'tasks',
134
+ :'events',
135
+ :'remote_data'
136
+ ])
137
+ end
138
+
139
+ # Initializes the object
140
+ # @param [Hash] attributes Model attributes in the form of hash
141
+ def initialize(attributes = {})
142
+ if (!attributes.is_a?(Hash))
143
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Carbon::Lead` initialize method"
144
+ end
145
+
146
+ # check to see if the attribute exists and convert string to symbol for hash key
147
+ attributes = attributes.each_with_object({}) { |(k, v), h|
148
+ if (!self.class.attribute_map.key?(k.to_sym))
149
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Carbon::Lead`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
150
+ end
151
+ h[k.to_sym] = v
152
+ }
153
+
154
+ if attributes.key?(:'title')
155
+ self.title = attributes[:'title']
156
+ end
157
+
158
+ if attributes.key?(:'description')
159
+ self.description = attributes[:'description']
160
+ end
161
+
162
+ if attributes.key?(:'id')
163
+ self.id = attributes[:'id']
164
+ end
165
+
166
+ if attributes.key?(:'owner')
167
+ self.owner = attributes[:'owner']
168
+ end
169
+
170
+ if attributes.key?(:'source')
171
+ self.source = attributes[:'source']
172
+ end
173
+
174
+ if attributes.key?(:'status')
175
+ self.status = attributes[:'status']
176
+ end
177
+
178
+ if attributes.key?(:'company')
179
+ self.company = attributes[:'company']
180
+ end
181
+
182
+ if attributes.key?(:'first_name')
183
+ self.first_name = attributes[:'first_name']
184
+ end
185
+
186
+ if attributes.key?(:'last_name')
187
+ self.last_name = attributes[:'last_name']
188
+ end
189
+
190
+ if attributes.key?(:'addresses')
191
+ if (value = attributes[:'addresses']).is_a?(Array)
192
+ self.addresses = value
193
+ end
194
+ end
195
+
196
+ if attributes.key?(:'phone_numbers')
197
+ if (value = attributes[:'phone_numbers']).is_a?(Array)
198
+ self.phone_numbers = value
199
+ end
200
+ end
201
+
202
+ if attributes.key?(:'emails')
203
+ if (value = attributes[:'emails']).is_a?(Array)
204
+ self.emails = value
205
+ end
206
+ end
207
+
208
+ if attributes.key?(:'converted_at')
209
+ self.converted_at = attributes[:'converted_at']
210
+ end
211
+
212
+ if attributes.key?(:'converted_account')
213
+ self.converted_account = attributes[:'converted_account']
214
+ end
215
+
216
+ if attributes.key?(:'converted_contact')
217
+ self.converted_contact = attributes[:'converted_contact']
218
+ end
219
+
220
+ if attributes.key?(:'last_activity_at')
221
+ self.last_activity_at = attributes[:'last_activity_at']
222
+ end
223
+
224
+ if attributes.key?(:'created_at')
225
+ self.created_at = attributes[:'created_at']
226
+ end
227
+
228
+ if attributes.key?(:'updated_at')
229
+ self.updated_at = attributes[:'updated_at']
230
+ end
231
+
232
+ if attributes.key?(:'is_deleted')
233
+ self.is_deleted = attributes[:'is_deleted']
234
+ end
235
+
236
+ if attributes.key?(:'tasks')
237
+ if (value = attributes[:'tasks']).is_a?(Array)
238
+ self.tasks = value
239
+ end
240
+ end
241
+
242
+ if attributes.key?(:'events')
243
+ if (value = attributes[:'events']).is_a?(Array)
244
+ self.events = value
245
+ end
246
+ end
247
+
248
+ if attributes.key?(:'remote_data')
249
+ self.remote_data = attributes[:'remote_data']
250
+ end
251
+ end
252
+
253
+ # Show invalid properties with the reasons. Usually used together with valid?
254
+ # @return Array for valid properties with the reasons
255
+ def list_invalid_properties
256
+ invalid_properties = Array.new
257
+ if @id.nil?
258
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
259
+ end
260
+
261
+ if @owner.nil?
262
+ invalid_properties.push('invalid value for "owner", owner cannot be nil.')
263
+ end
264
+
265
+ if @addresses.nil?
266
+ invalid_properties.push('invalid value for "addresses", addresses cannot be nil.')
267
+ end
268
+
269
+ if @phone_numbers.nil?
270
+ invalid_properties.push('invalid value for "phone_numbers", phone_numbers cannot be nil.')
271
+ end
272
+
273
+ if @emails.nil?
274
+ invalid_properties.push('invalid value for "emails", emails cannot be nil.')
275
+ end
276
+
277
+ if @created_at.nil?
278
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
279
+ end
280
+
281
+ if @updated_at.nil?
282
+ invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
283
+ end
284
+
285
+ if @is_deleted.nil?
286
+ invalid_properties.push('invalid value for "is_deleted", is_deleted cannot be nil.')
287
+ end
288
+
289
+ invalid_properties
290
+ end
291
+
292
+ # Check to see if the all the properties in the model are valid
293
+ # @return true if the model is valid
294
+ def valid?
295
+ return false if @id.nil?
296
+ return false if @owner.nil?
297
+ return false if @addresses.nil?
298
+ return false if @phone_numbers.nil?
299
+ return false if @emails.nil?
300
+ return false if @created_at.nil?
301
+ return false if @updated_at.nil?
302
+ return false if @is_deleted.nil?
303
+ true
304
+ end
305
+
306
+ # Checks equality by comparing each attribute.
307
+ # @param [Object] Object to be compared
308
+ def ==(o)
309
+ return true if self.equal?(o)
310
+ self.class == o.class &&
311
+ title == o.title &&
312
+ description == o.description &&
313
+ id == o.id &&
314
+ owner == o.owner &&
315
+ source == o.source &&
316
+ status == o.status &&
317
+ company == o.company &&
318
+ first_name == o.first_name &&
319
+ last_name == o.last_name &&
320
+ addresses == o.addresses &&
321
+ phone_numbers == o.phone_numbers &&
322
+ emails == o.emails &&
323
+ converted_at == o.converted_at &&
324
+ converted_account == o.converted_account &&
325
+ converted_contact == o.converted_contact &&
326
+ last_activity_at == o.last_activity_at &&
327
+ created_at == o.created_at &&
328
+ updated_at == o.updated_at &&
329
+ is_deleted == o.is_deleted &&
330
+ tasks == o.tasks &&
331
+ events == o.events &&
332
+ remote_data == o.remote_data
333
+ end
334
+
335
+ # @see the `==` method
336
+ # @param [Object] Object to be compared
337
+ def eql?(o)
338
+ self == o
339
+ end
340
+
341
+ # Calculates hash code according to all attributes.
342
+ # @return [Integer] Hash code
343
+ def hash
344
+ [title, description, id, owner, source, status, company, first_name, last_name, addresses, phone_numbers, emails, converted_at, converted_account, converted_contact, last_activity_at, created_at, updated_at, is_deleted, tasks, events, remote_data].hash
345
+ end
346
+
347
+ # Builds the object from hash
348
+ # @param [Hash] attributes Model attributes in the form of hash
349
+ # @return [Object] Returns the model itself
350
+ def self.build_from_hash(attributes)
351
+ new.build_from_hash(attributes)
352
+ end
353
+
354
+ # Builds the object from hash
355
+ # @param [Hash] attributes Model attributes in the form of hash
356
+ # @return [Object] Returns the model itself
357
+ def build_from_hash(attributes)
358
+ return nil unless attributes.is_a?(Hash)
359
+ attributes = attributes.transform_keys(&:to_sym)
360
+ self.class.openapi_types.each_pair do |key, type|
361
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
362
+ self.send("#{key}=", nil)
363
+ elsif type =~ /\AArray<(.*)>/i
364
+ # check to ensure the input is an array given that the attribute
365
+ # is documented as an array but the input is not
366
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
367
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
368
+ end
369
+ elsif !attributes[self.class.attribute_map[key]].nil?
370
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
371
+ end
372
+ end
373
+
374
+ self
375
+ end
376
+
377
+ # Deserializes the data based on type
378
+ # @param string type Data type
379
+ # @param string value Value to be deserialized
380
+ # @return [Object] Deserialized data
381
+ def _deserialize(type, value)
382
+ case type.to_sym
383
+ when :Time
384
+ Time.parse(value)
385
+ when :Date
386
+ Date.parse(value)
387
+ when :String
388
+ value.to_s
389
+ when :Integer
390
+ value.to_i
391
+ when :Float
392
+ value.to_f
393
+ when :Boolean
394
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
395
+ true
396
+ else
397
+ false
398
+ end
399
+ when :Object
400
+ # generic object (usually a Hash), return directly
401
+ value
402
+ when /\AArray<(?<inner_type>.+)>\z/
403
+ inner_type = Regexp.last_match[:inner_type]
404
+ value.map { |v| _deserialize(inner_type, v) }
405
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
406
+ k_type = Regexp.last_match[:k_type]
407
+ v_type = Regexp.last_match[:v_type]
408
+ {}.tap do |hash|
409
+ value.each do |k, v|
410
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
411
+ end
412
+ end
413
+ else # model
414
+ # models (e.g. Pet) or oneOf
415
+ klass = Carbon.const_get(type)
416
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
417
+ end
418
+ end
419
+
420
+ # Returns the string representation of the object
421
+ # @return [String] String presentation of the object
422
+ def to_s
423
+ to_hash.to_s
424
+ end
425
+
426
+ # to_body is an alias to to_hash (backward compatibility)
427
+ # @return [Hash] Returns the object in the form of hash
428
+ def to_body
429
+ to_hash
430
+ end
431
+
432
+ # Returns the object in the form of hash
433
+ # @return [Hash] Returns the object in the form of hash
434
+ def to_hash
435
+ hash = {}
436
+ self.class.attribute_map.each_pair do |attr, param|
437
+ value = self.send(attr)
438
+ if value.nil?
439
+ is_nullable = self.class.openapi_nullable.include?(attr)
440
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
441
+ end
442
+
443
+ hash[param] = _to_hash(value)
444
+ end
445
+ hash
446
+ end
447
+
448
+ # Outputs non-array value in the form of hash
449
+ # For object, use to_hash. Otherwise, just return the value
450
+ # @param [Object] value Any valid value
451
+ # @return [Hash] Returns the value in the form of hash
452
+ def _to_hash(value)
453
+ if value.is_a?(Array)
454
+ value.compact.map { |v| _to_hash(v) }
455
+ elsif value.is_a?(Hash)
456
+ {}.tap do |hash|
457
+ value.each { |k, v| hash[k] = _to_hash(v) }
458
+ end
459
+ elsif value.respond_to? :to_hash
460
+ value.to_hash
461
+ else
462
+ value
463
+ end
464
+ end
465
+
466
+ end
467
+
468
+ end
@@ -0,0 +1,246 @@
1
+ =begin
2
+ #Carbon
3
+
4
+ #Connect external data to LLMs, no matter the source.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ =end
8
+
9
+ require 'date'
10
+ require 'time'
11
+
12
+ module Carbon
13
+ class LeadFilters
14
+ attr_accessor :owner_id
15
+
16
+ attr_accessor :name
17
+
18
+ attr_accessor :converted_account_id
19
+
20
+ attr_accessor :converted_contact_id
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'owner_id' => :'owner_id',
26
+ :'name' => :'name',
27
+ :'converted_account_id' => :'converted_account_id',
28
+ :'converted_contact_id' => :'converted_contact_id'
29
+ }
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'owner_id' => :'String',
41
+ :'name' => :'String',
42
+ :'converted_account_id' => :'String',
43
+ :'converted_contact_id' => :'String'
44
+ }
45
+ end
46
+
47
+ # List of attributes with nullable: true
48
+ def self.openapi_nullable
49
+ Set.new([
50
+ :'owner_id',
51
+ :'name',
52
+ :'converted_account_id',
53
+ :'converted_contact_id'
54
+ ])
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Carbon::LeadFilters` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Carbon::LeadFilters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'owner_id')
73
+ self.owner_id = attributes[:'owner_id']
74
+ end
75
+
76
+ if attributes.key?(:'name')
77
+ self.name = attributes[:'name']
78
+ end
79
+
80
+ if attributes.key?(:'converted_account_id')
81
+ self.converted_account_id = attributes[:'converted_account_id']
82
+ end
83
+
84
+ if attributes.key?(:'converted_contact_id')
85
+ self.converted_contact_id = attributes[:'converted_contact_id']
86
+ end
87
+ end
88
+
89
+ # Show invalid properties with the reasons. Usually used together with valid?
90
+ # @return Array for valid properties with the reasons
91
+ def list_invalid_properties
92
+ invalid_properties = Array.new
93
+ invalid_properties
94
+ end
95
+
96
+ # Check to see if the all the properties in the model are valid
97
+ # @return true if the model is valid
98
+ def valid?
99
+ true
100
+ end
101
+
102
+ # Checks equality by comparing each attribute.
103
+ # @param [Object] Object to be compared
104
+ def ==(o)
105
+ return true if self.equal?(o)
106
+ self.class == o.class &&
107
+ owner_id == o.owner_id &&
108
+ name == o.name &&
109
+ converted_account_id == o.converted_account_id &&
110
+ converted_contact_id == o.converted_contact_id
111
+ end
112
+
113
+ # @see the `==` method
114
+ # @param [Object] Object to be compared
115
+ def eql?(o)
116
+ self == o
117
+ end
118
+
119
+ # Calculates hash code according to all attributes.
120
+ # @return [Integer] Hash code
121
+ def hash
122
+ [owner_id, name, converted_account_id, converted_contact_id].hash
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def self.build_from_hash(attributes)
129
+ new.build_from_hash(attributes)
130
+ end
131
+
132
+ # Builds the object from hash
133
+ # @param [Hash] attributes Model attributes in the form of hash
134
+ # @return [Object] Returns the model itself
135
+ def build_from_hash(attributes)
136
+ return nil unless attributes.is_a?(Hash)
137
+ attributes = attributes.transform_keys(&:to_sym)
138
+ self.class.openapi_types.each_pair do |key, type|
139
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
140
+ self.send("#{key}=", nil)
141
+ elsif type =~ /\AArray<(.*)>/i
142
+ # check to ensure the input is an array given that the attribute
143
+ # is documented as an array but the input is not
144
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
145
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
146
+ end
147
+ elsif !attributes[self.class.attribute_map[key]].nil?
148
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
149
+ end
150
+ end
151
+
152
+ self
153
+ end
154
+
155
+ # Deserializes the data based on type
156
+ # @param string type Data type
157
+ # @param string value Value to be deserialized
158
+ # @return [Object] Deserialized data
159
+ def _deserialize(type, value)
160
+ case type.to_sym
161
+ when :Time
162
+ Time.parse(value)
163
+ when :Date
164
+ Date.parse(value)
165
+ when :String
166
+ value.to_s
167
+ when :Integer
168
+ value.to_i
169
+ when :Float
170
+ value.to_f
171
+ when :Boolean
172
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
173
+ true
174
+ else
175
+ false
176
+ end
177
+ when :Object
178
+ # generic object (usually a Hash), return directly
179
+ value
180
+ when /\AArray<(?<inner_type>.+)>\z/
181
+ inner_type = Regexp.last_match[:inner_type]
182
+ value.map { |v| _deserialize(inner_type, v) }
183
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
184
+ k_type = Regexp.last_match[:k_type]
185
+ v_type = Regexp.last_match[:v_type]
186
+ {}.tap do |hash|
187
+ value.each do |k, v|
188
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
189
+ end
190
+ end
191
+ else # model
192
+ # models (e.g. Pet) or oneOf
193
+ klass = Carbon.const_get(type)
194
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
195
+ end
196
+ end
197
+
198
+ # Returns the string representation of the object
199
+ # @return [String] String presentation of the object
200
+ def to_s
201
+ to_hash.to_s
202
+ end
203
+
204
+ # to_body is an alias to to_hash (backward compatibility)
205
+ # @return [Hash] Returns the object in the form of hash
206
+ def to_body
207
+ to_hash
208
+ end
209
+
210
+ # Returns the object in the form of hash
211
+ # @return [Hash] Returns the object in the form of hash
212
+ def to_hash
213
+ hash = {}
214
+ self.class.attribute_map.each_pair do |attr, param|
215
+ value = self.send(attr)
216
+ if value.nil?
217
+ is_nullable = self.class.openapi_nullable.include?(attr)
218
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
219
+ end
220
+
221
+ hash[param] = _to_hash(value)
222
+ end
223
+ hash
224
+ end
225
+
226
+ # Outputs non-array value in the form of hash
227
+ # For object, use to_hash. Otherwise, just return the value
228
+ # @param [Object] value Any valid value
229
+ # @return [Hash] Returns the value in the form of hash
230
+ def _to_hash(value)
231
+ if value.is_a?(Array)
232
+ value.compact.map { |v| _to_hash(v) }
233
+ elsif value.is_a?(Hash)
234
+ {}.tap do |hash|
235
+ value.each { |k, v| hash[k] = _to_hash(v) }
236
+ end
237
+ elsif value.respond_to? :to_hash
238
+ value.to_hash
239
+ else
240
+ value
241
+ end
242
+ end
243
+
244
+ end
245
+
246
+ end