carbon_ruby_sdk 0.2.16 → 0.2.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +16 -20
  3. data/README.md +28 -7
  4. data/lib/carbon_ruby_sdk/api/embeddings_api.rb +6 -2
  5. data/lib/carbon_ruby_sdk/api/files_api.rb +15 -4
  6. data/lib/carbon_ruby_sdk/api/integrations_api.rb +8 -8
  7. data/lib/carbon_ruby_sdk/models/file_sync_config.rb +11 -1
  8. data/lib/carbon_ruby_sdk/models/file_sync_config_nullable.rb +11 -1
  9. data/lib/carbon_ruby_sdk/models/get_embedding_documents_body.rb +18 -5
  10. data/lib/carbon_ruby_sdk/models/o_auth_url_request.rb +2 -2
  11. data/lib/carbon_ruby_sdk/models/object_type.rb +42 -0
  12. data/lib/carbon_ruby_sdk/models/organization_user_files_to_sync_filters.rb +18 -5
  13. data/lib/carbon_ruby_sdk/models/sent_webhook_payload.rb +276 -0
  14. data/lib/carbon_ruby_sdk/models/sent_webhook_payload_object.rb +235 -0
  15. data/lib/carbon_ruby_sdk/models/sent_webhook_payload_object_additional_information.rb +101 -0
  16. data/lib/carbon_ruby_sdk/models/sent_webhook_payload_object_object_id.rb +103 -0
  17. data/lib/carbon_ruby_sdk/models/sent_webhook_request_body.rb +215 -0
  18. data/lib/carbon_ruby_sdk/models/sync_files_request.rb +1 -1
  19. data/lib/carbon_ruby_sdk/models/sync_options.rb +1 -1
  20. data/lib/carbon_ruby_sdk/models/transcription_service.rb +36 -0
  21. data/lib/carbon_ruby_sdk/models/transcription_service_nullable.rb +36 -0
  22. data/lib/carbon_ruby_sdk/models/upload_file_from_url_input.rb +11 -1
  23. data/lib/carbon_ruby_sdk/version.rb +1 -1
  24. data/lib/carbon_ruby_sdk.rb +8 -0
  25. data/spec/api/files_api_spec.rb +1 -0
  26. data/spec/models/file_sync_config_nullable_spec.rb +6 -0
  27. data/spec/models/file_sync_config_spec.rb +6 -0
  28. data/spec/models/get_embedding_documents_body_spec.rb +6 -0
  29. data/spec/models/object_type_spec.rb +22 -0
  30. data/spec/models/organization_user_files_to_sync_filters_spec.rb +6 -0
  31. data/spec/models/sent_webhook_payload_object_additional_information_spec.rb +25 -0
  32. data/spec/models/sent_webhook_payload_object_object_id_spec.rb +25 -0
  33. data/spec/models/sent_webhook_payload_object_spec.rb +40 -0
  34. data/spec/models/sent_webhook_payload_spec.rb +50 -0
  35. data/spec/models/sent_webhook_request_body_spec.rb +28 -0
  36. data/spec/models/transcription_service_nullable_spec.rb +22 -0
  37. data/spec/models/transcription_service_spec.rb +22 -0
  38. data/spec/models/upload_file_from_url_input_spec.rb +6 -0
  39. metadata +27 -3
@@ -0,0 +1,235 @@
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 SentWebhookPayloadObject
14
+ attr_accessor :object_type
15
+
16
+ attr_accessor :object_id
17
+
18
+ attr_accessor :additional_information
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'object_type' => :'object_type',
24
+ :'object_id' => :'object_id',
25
+ :'additional_information' => :'additional_information'
26
+ }
27
+ end
28
+
29
+ # Returns all the JSON keys this model knows about
30
+ def self.acceptable_attributes
31
+ attribute_map.values
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.openapi_types
36
+ {
37
+ :'object_type' => :'ObjectType',
38
+ :'object_id' => :'SentWebhookPayloadObjectObjectId',
39
+ :'additional_information' => :'SentWebhookPayloadObjectAdditionalInformation'
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new([
46
+ :'object_id',
47
+ :'additional_information'
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Carbon::SentWebhookPayloadObject` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Carbon::SentWebhookPayloadObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'object_type')
67
+ self.object_type = attributes[:'object_type']
68
+ end
69
+
70
+ if attributes.key?(:'object_id')
71
+ self.object_id = attributes[:'object_id']
72
+ end
73
+
74
+ if attributes.key?(:'additional_information')
75
+ self.additional_information = attributes[:'additional_information']
76
+ end
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ invalid_properties = Array.new
83
+ invalid_properties
84
+ end
85
+
86
+ # Check to see if the all the properties in the model are valid
87
+ # @return true if the model is valid
88
+ def valid?
89
+ true
90
+ end
91
+
92
+ # Checks equality by comparing each attribute.
93
+ # @param [Object] Object to be compared
94
+ def ==(o)
95
+ return true if self.equal?(o)
96
+ self.class == o.class &&
97
+ object_type == o.object_type &&
98
+ object_id == o.object_id &&
99
+ additional_information == o.additional_information
100
+ end
101
+
102
+ # @see the `==` method
103
+ # @param [Object] Object to be compared
104
+ def eql?(o)
105
+ self == o
106
+ end
107
+
108
+ # Calculates hash code according to all attributes.
109
+ # @return [Integer] Hash code
110
+ def hash
111
+ [object_type, object_id, additional_information].hash
112
+ end
113
+
114
+ # Builds the object from hash
115
+ # @param [Hash] attributes Model attributes in the form of hash
116
+ # @return [Object] Returns the model itself
117
+ def self.build_from_hash(attributes)
118
+ new.build_from_hash(attributes)
119
+ end
120
+
121
+ # Builds the object from hash
122
+ # @param [Hash] attributes Model attributes in the form of hash
123
+ # @return [Object] Returns the model itself
124
+ def build_from_hash(attributes)
125
+ return nil unless attributes.is_a?(Hash)
126
+ attributes = attributes.transform_keys(&:to_sym)
127
+ self.class.openapi_types.each_pair do |key, type|
128
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
129
+ self.send("#{key}=", nil)
130
+ elsif type =~ /\AArray<(.*)>/i
131
+ # check to ensure the input is an array given that the attribute
132
+ # is documented as an array but the input is not
133
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
134
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
135
+ end
136
+ elsif !attributes[self.class.attribute_map[key]].nil?
137
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
138
+ end
139
+ end
140
+
141
+ self
142
+ end
143
+
144
+ # Deserializes the data based on type
145
+ # @param string type Data type
146
+ # @param string value Value to be deserialized
147
+ # @return [Object] Deserialized data
148
+ def _deserialize(type, value)
149
+ case type.to_sym
150
+ when :Time
151
+ Time.parse(value)
152
+ when :Date
153
+ Date.parse(value)
154
+ when :String
155
+ value.to_s
156
+ when :Integer
157
+ value.to_i
158
+ when :Float
159
+ value.to_f
160
+ when :Boolean
161
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
162
+ true
163
+ else
164
+ false
165
+ end
166
+ when :Object
167
+ # generic object (usually a Hash), return directly
168
+ value
169
+ when /\AArray<(?<inner_type>.+)>\z/
170
+ inner_type = Regexp.last_match[:inner_type]
171
+ value.map { |v| _deserialize(inner_type, v) }
172
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
173
+ k_type = Regexp.last_match[:k_type]
174
+ v_type = Regexp.last_match[:v_type]
175
+ {}.tap do |hash|
176
+ value.each do |k, v|
177
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
178
+ end
179
+ end
180
+ else # model
181
+ # models (e.g. Pet) or oneOf
182
+ klass = Carbon.const_get(type)
183
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
184
+ end
185
+ end
186
+
187
+ # Returns the string representation of the object
188
+ # @return [String] String presentation of the object
189
+ def to_s
190
+ to_hash.to_s
191
+ end
192
+
193
+ # to_body is an alias to to_hash (backward compatibility)
194
+ # @return [Hash] Returns the object in the form of hash
195
+ def to_body
196
+ to_hash
197
+ end
198
+
199
+ # Returns the object in the form of hash
200
+ # @return [Hash] Returns the object in the form of hash
201
+ def to_hash
202
+ hash = {}
203
+ self.class.attribute_map.each_pair do |attr, param|
204
+ value = self.send(attr)
205
+ if value.nil?
206
+ is_nullable = self.class.openapi_nullable.include?(attr)
207
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
208
+ end
209
+
210
+ hash[param] = _to_hash(value)
211
+ end
212
+ hash
213
+ end
214
+
215
+ # Outputs non-array value in the form of hash
216
+ # For object, use to_hash. Otherwise, just return the value
217
+ # @param [Object] value Any valid value
218
+ # @return [Hash] Returns the value in the form of hash
219
+ def _to_hash(value)
220
+ if value.is_a?(Array)
221
+ value.compact.map { |v| _to_hash(v) }
222
+ elsif value.is_a?(Hash)
223
+ {}.tap do |hash|
224
+ value.each { |k, v| hash[k] = _to_hash(v) }
225
+ end
226
+ elsif value.respond_to? :to_hash
227
+ value.to_hash
228
+ else
229
+ value
230
+ end
231
+ end
232
+
233
+ end
234
+
235
+ end
@@ -0,0 +1,101 @@
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
+ module SentWebhookPayloadObjectAdditionalInformation
14
+ class << self
15
+ # List of class defined in oneOf (OpenAPI v3)
16
+ def openapi_one_of
17
+ [
18
+ :'Object',
19
+ :'String'
20
+ ]
21
+ end
22
+
23
+ # Builds the object
24
+ # @param [Mixed] Data to be matched against the list of oneOf items
25
+ # @return [Object] Returns the model or the data itself
26
+ def build(data)
27
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
28
+ # Note:
29
+ # - We do not attempt to check whether exactly one item matches.
30
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
31
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
32
+ # - TODO: scalar values are de facto behaving as if they were nullable.
33
+ # - TODO: logging when debugging is set.
34
+ openapi_one_of.each do |klass|
35
+ begin
36
+ next if klass == :AnyType # "nullable: true"
37
+ typed_data = find_and_cast_into_type(klass, data)
38
+ return typed_data if typed_data
39
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
40
+ end
41
+ end
42
+
43
+ openapi_one_of.include?(:AnyType) ? data : nil
44
+ end
45
+
46
+ private
47
+
48
+ SchemaMismatchError = Class.new(StandardError)
49
+
50
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
51
+ def find_and_cast_into_type(klass, data)
52
+ return if data.nil?
53
+
54
+ case klass.to_s
55
+ when 'Boolean'
56
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
57
+ when 'Float'
58
+ return data if data.instance_of?(Float)
59
+ when 'Integer'
60
+ return data if data.instance_of?(Integer)
61
+ when 'Time'
62
+ return Time.parse(data)
63
+ when 'Date'
64
+ return Date.parse(data)
65
+ when 'String'
66
+ return data if data.instance_of?(String)
67
+ when 'Object' # "type: object"
68
+ return data if data.instance_of?(Hash)
69
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
70
+ if data.instance_of?(Array)
71
+ sub_type = Regexp.last_match[:sub_type]
72
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
73
+ end
74
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
75
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
76
+ sub_type = Regexp.last_match[:sub_type]
77
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
78
+ end
79
+ else # model
80
+ const = Carbon.const_get(klass)
81
+ if const
82
+ if const.respond_to?(:openapi_one_of) # nested oneOf model
83
+ model = const.build(data)
84
+ return model if model
85
+ else
86
+ # raise if data contains keys that are not known to the model
87
+ raise unless (data.keys - const.acceptable_attributes).empty?
88
+ model = const.build_from_hash(data)
89
+ return model if model && model.valid?
90
+ end
91
+ end
92
+ end
93
+
94
+ raise # if no match by now, raise
95
+ rescue
96
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
97
+ end
98
+ end
99
+ end
100
+
101
+ end
@@ -0,0 +1,103 @@
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
+ module SentWebhookPayloadObjectObjectId
14
+ class << self
15
+ # List of class defined in oneOf (OpenAPI v3)
16
+ def openapi_one_of
17
+ [
18
+ :'Array<Integer>',
19
+ :'Array<String>',
20
+ :'Integer',
21
+ :'String'
22
+ ]
23
+ end
24
+
25
+ # Builds the object
26
+ # @param [Mixed] Data to be matched against the list of oneOf items
27
+ # @return [Object] Returns the model or the data itself
28
+ def build(data)
29
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
30
+ # Note:
31
+ # - We do not attempt to check whether exactly one item matches.
32
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
33
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
34
+ # - TODO: scalar values are de facto behaving as if they were nullable.
35
+ # - TODO: logging when debugging is set.
36
+ openapi_one_of.each do |klass|
37
+ begin
38
+ next if klass == :AnyType # "nullable: true"
39
+ typed_data = find_and_cast_into_type(klass, data)
40
+ return typed_data if typed_data
41
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
42
+ end
43
+ end
44
+
45
+ openapi_one_of.include?(:AnyType) ? data : nil
46
+ end
47
+
48
+ private
49
+
50
+ SchemaMismatchError = Class.new(StandardError)
51
+
52
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
53
+ def find_and_cast_into_type(klass, data)
54
+ return if data.nil?
55
+
56
+ case klass.to_s
57
+ when 'Boolean'
58
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
59
+ when 'Float'
60
+ return data if data.instance_of?(Float)
61
+ when 'Integer'
62
+ return data if data.instance_of?(Integer)
63
+ when 'Time'
64
+ return Time.parse(data)
65
+ when 'Date'
66
+ return Date.parse(data)
67
+ when 'String'
68
+ return data if data.instance_of?(String)
69
+ when 'Object' # "type: object"
70
+ return data if data.instance_of?(Hash)
71
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
72
+ if data.instance_of?(Array)
73
+ sub_type = Regexp.last_match[:sub_type]
74
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
75
+ end
76
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
77
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
78
+ sub_type = Regexp.last_match[:sub_type]
79
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
80
+ end
81
+ else # model
82
+ const = Carbon.const_get(klass)
83
+ if const
84
+ if const.respond_to?(:openapi_one_of) # nested oneOf model
85
+ model = const.build(data)
86
+ return model if model
87
+ else
88
+ # raise if data contains keys that are not known to the model
89
+ raise unless (data.keys - const.acceptable_attributes).empty?
90
+ model = const.build_from_hash(data)
91
+ return model if model && model.valid?
92
+ end
93
+ end
94
+ end
95
+
96
+ raise # if no match by now, raise
97
+ rescue
98
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
99
+ end
100
+ end
101
+ end
102
+
103
+ end
@@ -0,0 +1,215 @@
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 SentWebhookRequestBody
14
+ attr_accessor :payload
15
+
16
+ # Attribute mapping from ruby-style variable name to JSON key.
17
+ def self.attribute_map
18
+ {
19
+ :'payload' => :'payload'
20
+ }
21
+ end
22
+
23
+ # Returns all the JSON keys this model knows about
24
+ def self.acceptable_attributes
25
+ attribute_map.values
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.openapi_types
30
+ {
31
+ :'payload' => :'String'
32
+ }
33
+ end
34
+
35
+ # List of attributes with nullable: true
36
+ def self.openapi_nullable
37
+ Set.new([
38
+ ])
39
+ end
40
+
41
+ # Initializes the object
42
+ # @param [Hash] attributes Model attributes in the form of hash
43
+ def initialize(attributes = {})
44
+ if (!attributes.is_a?(Hash))
45
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Carbon::SentWebhookRequestBody` initialize method"
46
+ end
47
+
48
+ # check to see if the attribute exists and convert string to symbol for hash key
49
+ attributes = attributes.each_with_object({}) { |(k, v), h|
50
+ if (!self.class.attribute_map.key?(k.to_sym))
51
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Carbon::SentWebhookRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
52
+ end
53
+ h[k.to_sym] = v
54
+ }
55
+
56
+ if attributes.key?(:'payload')
57
+ self.payload = attributes[:'payload']
58
+ end
59
+ end
60
+
61
+ # Show invalid properties with the reasons. Usually used together with valid?
62
+ # @return Array for valid properties with the reasons
63
+ def list_invalid_properties
64
+ invalid_properties = Array.new
65
+ invalid_properties
66
+ end
67
+
68
+ # Check to see if the all the properties in the model are valid
69
+ # @return true if the model is valid
70
+ def valid?
71
+ true
72
+ end
73
+
74
+ # Checks equality by comparing each attribute.
75
+ # @param [Object] Object to be compared
76
+ def ==(o)
77
+ return true if self.equal?(o)
78
+ self.class == o.class &&
79
+ payload == o.payload
80
+ end
81
+
82
+ # @see the `==` method
83
+ # @param [Object] Object to be compared
84
+ def eql?(o)
85
+ self == o
86
+ end
87
+
88
+ # Calculates hash code according to all attributes.
89
+ # @return [Integer] Hash code
90
+ def hash
91
+ [payload].hash
92
+ end
93
+
94
+ # Builds the object from hash
95
+ # @param [Hash] attributes Model attributes in the form of hash
96
+ # @return [Object] Returns the model itself
97
+ def self.build_from_hash(attributes)
98
+ new.build_from_hash(attributes)
99
+ end
100
+
101
+ # Builds the object from hash
102
+ # @param [Hash] attributes Model attributes in the form of hash
103
+ # @return [Object] Returns the model itself
104
+ def build_from_hash(attributes)
105
+ return nil unless attributes.is_a?(Hash)
106
+ attributes = attributes.transform_keys(&:to_sym)
107
+ self.class.openapi_types.each_pair do |key, type|
108
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
109
+ self.send("#{key}=", nil)
110
+ elsif type =~ /\AArray<(.*)>/i
111
+ # check to ensure the input is an array given that the attribute
112
+ # is documented as an array but the input is not
113
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
114
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
115
+ end
116
+ elsif !attributes[self.class.attribute_map[key]].nil?
117
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
118
+ end
119
+ end
120
+
121
+ self
122
+ end
123
+
124
+ # Deserializes the data based on type
125
+ # @param string type Data type
126
+ # @param string value Value to be deserialized
127
+ # @return [Object] Deserialized data
128
+ def _deserialize(type, value)
129
+ case type.to_sym
130
+ when :Time
131
+ Time.parse(value)
132
+ when :Date
133
+ Date.parse(value)
134
+ when :String
135
+ value.to_s
136
+ when :Integer
137
+ value.to_i
138
+ when :Float
139
+ value.to_f
140
+ when :Boolean
141
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
142
+ true
143
+ else
144
+ false
145
+ end
146
+ when :Object
147
+ # generic object (usually a Hash), return directly
148
+ value
149
+ when /\AArray<(?<inner_type>.+)>\z/
150
+ inner_type = Regexp.last_match[:inner_type]
151
+ value.map { |v| _deserialize(inner_type, v) }
152
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
153
+ k_type = Regexp.last_match[:k_type]
154
+ v_type = Regexp.last_match[:v_type]
155
+ {}.tap do |hash|
156
+ value.each do |k, v|
157
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
158
+ end
159
+ end
160
+ else # model
161
+ # models (e.g. Pet) or oneOf
162
+ klass = Carbon.const_get(type)
163
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
164
+ end
165
+ end
166
+
167
+ # Returns the string representation of the object
168
+ # @return [String] String presentation of the object
169
+ def to_s
170
+ to_hash.to_s
171
+ end
172
+
173
+ # to_body is an alias to to_hash (backward compatibility)
174
+ # @return [Hash] Returns the object in the form of hash
175
+ def to_body
176
+ to_hash
177
+ end
178
+
179
+ # Returns the object in the form of hash
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_hash
182
+ hash = {}
183
+ self.class.attribute_map.each_pair do |attr, param|
184
+ value = self.send(attr)
185
+ if value.nil?
186
+ is_nullable = self.class.openapi_nullable.include?(attr)
187
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
188
+ end
189
+
190
+ hash[param] = _to_hash(value)
191
+ end
192
+ hash
193
+ end
194
+
195
+ # Outputs non-array value in the form of hash
196
+ # For object, use to_hash. Otherwise, just return the value
197
+ # @param [Object] value Any valid value
198
+ # @return [Hash] Returns the value in the form of hash
199
+ def _to_hash(value)
200
+ if value.is_a?(Array)
201
+ value.compact.map { |v| _to_hash(v) }
202
+ elsif value.is_a?(Hash)
203
+ {}.tap do |hash|
204
+ value.each { |k, v| hash[k] = _to_hash(v) }
205
+ end
206
+ elsif value.respond_to? :to_hash
207
+ value.to_hash
208
+ else
209
+ value
210
+ end
211
+ end
212
+
213
+ end
214
+
215
+ end
@@ -187,7 +187,7 @@ module Carbon
187
187
  if attributes.key?(:'request_id')
188
188
  self.request_id = attributes[:'request_id']
189
189
  else
190
- self.request_id = '77b56048-a895-4377-b0d3-e190d1b7de32'
190
+ self.request_id = '991e89b6-1e71-41e1-bdc4-4dd475f21696'
191
191
  end
192
192
 
193
193
  if attributes.key?(:'use_ocr')
@@ -182,7 +182,7 @@ module Carbon
182
182
  if attributes.key?(:'request_id')
183
183
  self.request_id = attributes[:'request_id']
184
184
  else
185
- self.request_id = 'e38a7eee-02b7-4f73-be14-ea9bb1f09e85'
185
+ self.request_id = 'f5e8c193-f7e1-4e45-9be5-6aa157dfe3c3'
186
186
  end
187
187
 
188
188
  if attributes.key?(:'enable_file_picker')