carbon_ruby_sdk 0.2.35 → 0.2.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  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/email.rb +230 -0
  20. data/lib/carbon_ruby_sdk/models/event.rb +370 -0
  21. data/lib/carbon_ruby_sdk/models/lead.rb +468 -0
  22. data/lib/carbon_ruby_sdk/models/lead_filters.rb +246 -0
  23. data/lib/carbon_ruby_sdk/models/leads_order_by.rb +38 -0
  24. data/lib/carbon_ruby_sdk/models/leads_order_by_nullable.rb +38 -0
  25. data/lib/carbon_ruby_sdk/models/leads_request.rb +293 -0
  26. data/lib/carbon_ruby_sdk/models/leads_response.rb +246 -0
  27. data/lib/carbon_ruby_sdk/models/opportunities_order_by.rb +40 -0
  28. data/lib/carbon_ruby_sdk/models/opportunities_order_by_nullable.rb +40 -0
  29. data/lib/carbon_ruby_sdk/models/opportunities_request.rb +293 -0
  30. data/lib/carbon_ruby_sdk/models/opportunities_response.rb +246 -0
  31. data/lib/carbon_ruby_sdk/models/opportunity.rb +400 -0
  32. data/lib/carbon_ruby_sdk/models/opportunity_filters.rb +246 -0
  33. data/lib/carbon_ruby_sdk/models/opportunity_status.rb +36 -0
  34. data/lib/carbon_ruby_sdk/models/opportunity_status_nullable.rb +36 -0
  35. data/lib/carbon_ruby_sdk/models/order_dir_v2_nullable.rb +36 -0
  36. data/lib/carbon_ruby_sdk/models/partial_account.rb +216 -0
  37. data/lib/carbon_ruby_sdk/models/partial_account_nullable.rb +216 -0
  38. data/lib/carbon_ruby_sdk/models/partial_contact.rb +216 -0
  39. data/lib/carbon_ruby_sdk/models/partial_contact_nullable.rb +216 -0
  40. data/lib/carbon_ruby_sdk/models/partial_owner.rb +216 -0
  41. data/lib/carbon_ruby_sdk/models/partial_owner_nullable.rb +216 -0
  42. data/lib/carbon_ruby_sdk/models/phone_number.rb +230 -0
  43. data/lib/carbon_ruby_sdk/models/sent_webhook_payload.rb +2 -2
  44. data/lib/carbon_ruby_sdk/models/task.rb +346 -0
  45. data/lib/carbon_ruby_sdk/version.rb +1 -1
  46. data/lib/carbon_ruby_sdk.rb +42 -0
  47. data/spec/api/crm_api_spec.rb +129 -0
  48. data/spec/models/account_filters_spec.rb +34 -0
  49. data/spec/models/account_response_spec.rb +40 -0
  50. data/spec/models/account_spec.rb +118 -0
  51. data/spec/models/accounts_order_by_nullable_spec.rb +22 -0
  52. data/spec/models/accounts_order_by_spec.rb +22 -0
  53. data/spec/models/accounts_request_spec.rb +70 -0
  54. data/spec/models/address_spec.rb +64 -0
  55. data/spec/models/base_includes_spec.rb +22 -0
  56. data/spec/models/contact_filters_spec.rb +40 -0
  57. data/spec/models/contact_spec.rb +136 -0
  58. data/spec/models/contacts_order_by_nullable_spec.rb +22 -0
  59. data/spec/models/contacts_order_by_spec.rb +22 -0
  60. data/spec/models/contacts_request_spec.rb +70 -0
  61. data/spec/models/contacts_response_spec.rb +40 -0
  62. data/spec/models/email_spec.rb +34 -0
  63. data/spec/models/event_spec.rb +106 -0
  64. data/spec/models/lead_filters_spec.rb +46 -0
  65. data/spec/models/lead_spec.rb +154 -0
  66. data/spec/models/leads_order_by_nullable_spec.rb +22 -0
  67. data/spec/models/leads_order_by_spec.rb +22 -0
  68. data/spec/models/leads_request_spec.rb +70 -0
  69. data/spec/models/leads_response_spec.rb +40 -0
  70. data/spec/models/opportunities_order_by_nullable_spec.rb +22 -0
  71. data/spec/models/opportunities_order_by_spec.rb +22 -0
  72. data/spec/models/opportunities_request_spec.rb +70 -0
  73. data/spec/models/opportunities_response_spec.rb +40 -0
  74. data/spec/models/opportunity_filters_spec.rb +46 -0
  75. data/spec/models/opportunity_spec.rb +124 -0
  76. data/spec/models/opportunity_status_nullable_spec.rb +22 -0
  77. data/spec/models/opportunity_status_spec.rb +22 -0
  78. data/spec/models/order_dir_v2_nullable_spec.rb +22 -0
  79. data/spec/models/partial_account_nullable_spec.rb +28 -0
  80. data/spec/models/partial_account_spec.rb +28 -0
  81. data/spec/models/partial_contact_nullable_spec.rb +28 -0
  82. data/spec/models/partial_contact_spec.rb +28 -0
  83. data/spec/models/partial_owner_nullable_spec.rb +28 -0
  84. data/spec/models/partial_owner_spec.rb +28 -0
  85. data/spec/models/phone_number_spec.rb +34 -0
  86. data/spec/models/sent_webhook_payload_spec.rb +1 -1
  87. data/spec/models/task_spec.rb +94 -0
  88. metadata +122 -2
@@ -0,0 +1,400 @@
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 Opportunity
14
+ attr_accessor :description
15
+
16
+ attr_accessor :id
17
+
18
+ attr_accessor :owner
19
+
20
+ attr_accessor :name
21
+
22
+ attr_accessor :amount
23
+
24
+ attr_accessor :account
25
+
26
+ attr_accessor :contact
27
+
28
+ attr_accessor :stage
29
+
30
+ attr_accessor :status
31
+
32
+ attr_accessor :close_date
33
+
34
+ attr_accessor :last_activity_at
35
+
36
+ attr_accessor :created_at
37
+
38
+ attr_accessor :updated_at
39
+
40
+ attr_accessor :is_deleted
41
+
42
+ attr_accessor :tasks
43
+
44
+ attr_accessor :events
45
+
46
+ attr_accessor :remote_data
47
+
48
+ # Attribute mapping from ruby-style variable name to JSON key.
49
+ def self.attribute_map
50
+ {
51
+ :'description' => :'description',
52
+ :'id' => :'id',
53
+ :'owner' => :'owner',
54
+ :'name' => :'name',
55
+ :'amount' => :'amount',
56
+ :'account' => :'account',
57
+ :'contact' => :'contact',
58
+ :'stage' => :'stage',
59
+ :'status' => :'status',
60
+ :'close_date' => :'close_date',
61
+ :'last_activity_at' => :'last_activity_at',
62
+ :'created_at' => :'created_at',
63
+ :'updated_at' => :'updated_at',
64
+ :'is_deleted' => :'is_deleted',
65
+ :'tasks' => :'tasks',
66
+ :'events' => :'events',
67
+ :'remote_data' => :'remote_data'
68
+ }
69
+ end
70
+
71
+ # Returns all the JSON keys this model knows about
72
+ def self.acceptable_attributes
73
+ attribute_map.values
74
+ end
75
+
76
+ # Attribute type mapping.
77
+ def self.openapi_types
78
+ {
79
+ :'description' => :'String',
80
+ :'id' => :'String',
81
+ :'owner' => :'PartialOwner',
82
+ :'name' => :'String',
83
+ :'amount' => :'Integer',
84
+ :'account' => :'PartialAccountNullable',
85
+ :'contact' => :'PartialContactNullable',
86
+ :'stage' => :'String',
87
+ :'status' => :'OpportunityStatusNullable',
88
+ :'close_date' => :'String',
89
+ :'last_activity_at' => :'String',
90
+ :'created_at' => :'String',
91
+ :'updated_at' => :'String',
92
+ :'is_deleted' => :'Boolean',
93
+ :'tasks' => :'Array<Task>',
94
+ :'events' => :'Array<Event>',
95
+ :'remote_data' => :'Object'
96
+ }
97
+ end
98
+
99
+ # List of attributes with nullable: true
100
+ def self.openapi_nullable
101
+ Set.new([
102
+ :'description',
103
+ :'name',
104
+ :'amount',
105
+ :'account',
106
+ :'contact',
107
+ :'stage',
108
+ :'status',
109
+ :'close_date',
110
+ :'last_activity_at',
111
+ :'tasks',
112
+ :'events',
113
+ :'remote_data'
114
+ ])
115
+ end
116
+
117
+ # Initializes the object
118
+ # @param [Hash] attributes Model attributes in the form of hash
119
+ def initialize(attributes = {})
120
+ if (!attributes.is_a?(Hash))
121
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Carbon::Opportunity` initialize method"
122
+ end
123
+
124
+ # check to see if the attribute exists and convert string to symbol for hash key
125
+ attributes = attributes.each_with_object({}) { |(k, v), h|
126
+ if (!self.class.attribute_map.key?(k.to_sym))
127
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Carbon::Opportunity`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
128
+ end
129
+ h[k.to_sym] = v
130
+ }
131
+
132
+ if attributes.key?(:'description')
133
+ self.description = attributes[:'description']
134
+ end
135
+
136
+ if attributes.key?(:'id')
137
+ self.id = attributes[:'id']
138
+ end
139
+
140
+ if attributes.key?(:'owner')
141
+ self.owner = attributes[:'owner']
142
+ end
143
+
144
+ if attributes.key?(:'name')
145
+ self.name = attributes[:'name']
146
+ end
147
+
148
+ if attributes.key?(:'amount')
149
+ self.amount = attributes[:'amount']
150
+ end
151
+
152
+ if attributes.key?(:'account')
153
+ self.account = attributes[:'account']
154
+ end
155
+
156
+ if attributes.key?(:'contact')
157
+ self.contact = attributes[:'contact']
158
+ end
159
+
160
+ if attributes.key?(:'stage')
161
+ self.stage = attributes[:'stage']
162
+ end
163
+
164
+ if attributes.key?(:'status')
165
+ self.status = attributes[:'status']
166
+ end
167
+
168
+ if attributes.key?(:'close_date')
169
+ self.close_date = attributes[:'close_date']
170
+ end
171
+
172
+ if attributes.key?(:'last_activity_at')
173
+ self.last_activity_at = attributes[:'last_activity_at']
174
+ end
175
+
176
+ if attributes.key?(:'created_at')
177
+ self.created_at = attributes[:'created_at']
178
+ end
179
+
180
+ if attributes.key?(:'updated_at')
181
+ self.updated_at = attributes[:'updated_at']
182
+ end
183
+
184
+ if attributes.key?(:'is_deleted')
185
+ self.is_deleted = attributes[:'is_deleted']
186
+ end
187
+
188
+ if attributes.key?(:'tasks')
189
+ if (value = attributes[:'tasks']).is_a?(Array)
190
+ self.tasks = value
191
+ end
192
+ end
193
+
194
+ if attributes.key?(:'events')
195
+ if (value = attributes[:'events']).is_a?(Array)
196
+ self.events = value
197
+ end
198
+ end
199
+
200
+ if attributes.key?(:'remote_data')
201
+ self.remote_data = attributes[:'remote_data']
202
+ end
203
+ end
204
+
205
+ # Show invalid properties with the reasons. Usually used together with valid?
206
+ # @return Array for valid properties with the reasons
207
+ def list_invalid_properties
208
+ invalid_properties = Array.new
209
+ if @id.nil?
210
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
211
+ end
212
+
213
+ if @owner.nil?
214
+ invalid_properties.push('invalid value for "owner", owner cannot be nil.')
215
+ end
216
+
217
+ if @created_at.nil?
218
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
219
+ end
220
+
221
+ if @updated_at.nil?
222
+ invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
223
+ end
224
+
225
+ if @is_deleted.nil?
226
+ invalid_properties.push('invalid value for "is_deleted", is_deleted cannot be nil.')
227
+ end
228
+
229
+ invalid_properties
230
+ end
231
+
232
+ # Check to see if the all the properties in the model are valid
233
+ # @return true if the model is valid
234
+ def valid?
235
+ return false if @id.nil?
236
+ return false if @owner.nil?
237
+ return false if @created_at.nil?
238
+ return false if @updated_at.nil?
239
+ return false if @is_deleted.nil?
240
+ true
241
+ end
242
+
243
+ # Checks equality by comparing each attribute.
244
+ # @param [Object] Object to be compared
245
+ def ==(o)
246
+ return true if self.equal?(o)
247
+ self.class == o.class &&
248
+ description == o.description &&
249
+ id == o.id &&
250
+ owner == o.owner &&
251
+ name == o.name &&
252
+ amount == o.amount &&
253
+ account == o.account &&
254
+ contact == o.contact &&
255
+ stage == o.stage &&
256
+ status == o.status &&
257
+ close_date == o.close_date &&
258
+ last_activity_at == o.last_activity_at &&
259
+ created_at == o.created_at &&
260
+ updated_at == o.updated_at &&
261
+ is_deleted == o.is_deleted &&
262
+ tasks == o.tasks &&
263
+ events == o.events &&
264
+ remote_data == o.remote_data
265
+ end
266
+
267
+ # @see the `==` method
268
+ # @param [Object] Object to be compared
269
+ def eql?(o)
270
+ self == o
271
+ end
272
+
273
+ # Calculates hash code according to all attributes.
274
+ # @return [Integer] Hash code
275
+ def hash
276
+ [description, id, owner, name, amount, account, contact, stage, status, close_date, last_activity_at, created_at, updated_at, is_deleted, tasks, events, remote_data].hash
277
+ end
278
+
279
+ # Builds the object from hash
280
+ # @param [Hash] attributes Model attributes in the form of hash
281
+ # @return [Object] Returns the model itself
282
+ def self.build_from_hash(attributes)
283
+ new.build_from_hash(attributes)
284
+ end
285
+
286
+ # Builds the object from hash
287
+ # @param [Hash] attributes Model attributes in the form of hash
288
+ # @return [Object] Returns the model itself
289
+ def build_from_hash(attributes)
290
+ return nil unless attributes.is_a?(Hash)
291
+ attributes = attributes.transform_keys(&:to_sym)
292
+ self.class.openapi_types.each_pair do |key, type|
293
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
294
+ self.send("#{key}=", nil)
295
+ elsif type =~ /\AArray<(.*)>/i
296
+ # check to ensure the input is an array given that the attribute
297
+ # is documented as an array but the input is not
298
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
299
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
300
+ end
301
+ elsif !attributes[self.class.attribute_map[key]].nil?
302
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
303
+ end
304
+ end
305
+
306
+ self
307
+ end
308
+
309
+ # Deserializes the data based on type
310
+ # @param string type Data type
311
+ # @param string value Value to be deserialized
312
+ # @return [Object] Deserialized data
313
+ def _deserialize(type, value)
314
+ case type.to_sym
315
+ when :Time
316
+ Time.parse(value)
317
+ when :Date
318
+ Date.parse(value)
319
+ when :String
320
+ value.to_s
321
+ when :Integer
322
+ value.to_i
323
+ when :Float
324
+ value.to_f
325
+ when :Boolean
326
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
327
+ true
328
+ else
329
+ false
330
+ end
331
+ when :Object
332
+ # generic object (usually a Hash), return directly
333
+ value
334
+ when /\AArray<(?<inner_type>.+)>\z/
335
+ inner_type = Regexp.last_match[:inner_type]
336
+ value.map { |v| _deserialize(inner_type, v) }
337
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
338
+ k_type = Regexp.last_match[:k_type]
339
+ v_type = Regexp.last_match[:v_type]
340
+ {}.tap do |hash|
341
+ value.each do |k, v|
342
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
343
+ end
344
+ end
345
+ else # model
346
+ # models (e.g. Pet) or oneOf
347
+ klass = Carbon.const_get(type)
348
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
349
+ end
350
+ end
351
+
352
+ # Returns the string representation of the object
353
+ # @return [String] String presentation of the object
354
+ def to_s
355
+ to_hash.to_s
356
+ end
357
+
358
+ # to_body is an alias to to_hash (backward compatibility)
359
+ # @return [Hash] Returns the object in the form of hash
360
+ def to_body
361
+ to_hash
362
+ end
363
+
364
+ # Returns the object in the form of hash
365
+ # @return [Hash] Returns the object in the form of hash
366
+ def to_hash
367
+ hash = {}
368
+ self.class.attribute_map.each_pair do |attr, param|
369
+ value = self.send(attr)
370
+ if value.nil?
371
+ is_nullable = self.class.openapi_nullable.include?(attr)
372
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
373
+ end
374
+
375
+ hash[param] = _to_hash(value)
376
+ end
377
+ hash
378
+ end
379
+
380
+ # Outputs non-array value in the form of hash
381
+ # For object, use to_hash. Otherwise, just return the value
382
+ # @param [Object] value Any valid value
383
+ # @return [Hash] Returns the value in the form of hash
384
+ def _to_hash(value)
385
+ if value.is_a?(Array)
386
+ value.compact.map { |v| _to_hash(v) }
387
+ elsif value.is_a?(Hash)
388
+ {}.tap do |hash|
389
+ value.each { |k, v| hash[k] = _to_hash(v) }
390
+ end
391
+ elsif value.respond_to? :to_hash
392
+ value.to_hash
393
+ else
394
+ value
395
+ end
396
+ end
397
+
398
+ end
399
+
400
+ 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 OpportunityFilters
14
+ attr_accessor :owner_id
15
+
16
+ attr_accessor :account_id
17
+
18
+ attr_accessor :status
19
+
20
+ attr_accessor :stage
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'owner_id' => :'owner_id',
26
+ :'account_id' => :'account_id',
27
+ :'status' => :'status',
28
+ :'stage' => :'stage'
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
+ :'account_id' => :'String',
42
+ :'status' => :'OpportunityStatusNullable',
43
+ :'stage' => :'String'
44
+ }
45
+ end
46
+
47
+ # List of attributes with nullable: true
48
+ def self.openapi_nullable
49
+ Set.new([
50
+ :'owner_id',
51
+ :'account_id',
52
+ :'status',
53
+ :'stage'
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::OpportunityFilters` 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::OpportunityFilters`. 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?(:'account_id')
77
+ self.account_id = attributes[:'account_id']
78
+ end
79
+
80
+ if attributes.key?(:'status')
81
+ self.status = attributes[:'status']
82
+ end
83
+
84
+ if attributes.key?(:'stage')
85
+ self.stage = attributes[:'stage']
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
+ account_id == o.account_id &&
109
+ status == o.status &&
110
+ stage == o.stage
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, account_id, status, stage].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
@@ -0,0 +1,36 @@
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 OpportunityStatus
14
+ WON = "WON".freeze
15
+ OPEN = "OPEN".freeze
16
+
17
+ def self.all_vars
18
+ @all_vars ||= [WON, OPEN].freeze
19
+ end
20
+
21
+ # Builds the enum from string
22
+ # @param [String] The enum value in the form of the string
23
+ # @return [String] The enum value
24
+ def self.build_from_hash(value)
25
+ new.build_from_hash(value)
26
+ end
27
+
28
+ # Builds the enum from string
29
+ # @param [String] The enum value in the form of the string
30
+ # @return [String] The enum value
31
+ def build_from_hash(value)
32
+ return value if OpportunityStatus.all_vars.include?(value)
33
+ raise "Invalid ENUM value #{value} for class #OpportunityStatus"
34
+ end
35
+ end
36
+ end