carbon_ruby_sdk 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +46 -2
  4. data/lib/carbon_ruby_sdk/api/integrations_api.rb +96 -0
  5. data/lib/carbon_ruby_sdk/models/authentication_property.rb +436 -0
  6. data/lib/carbon_ruby_sdk/models/confluence_authentication.rb +254 -0
  7. data/lib/carbon_ruby_sdk/models/connect_data_source_input.rb +229 -0
  8. data/lib/carbon_ruby_sdk/models/connect_data_source_response.rb +230 -0
  9. data/lib/carbon_ruby_sdk/models/freskdesk_authentication.rb +244 -0
  10. data/lib/carbon_ruby_sdk/models/gitbook_authetication.rb +244 -0
  11. data/lib/carbon_ruby_sdk/models/notion_authentication.rb +244 -0
  12. data/lib/carbon_ruby_sdk/models/o_auth_authentication.rb +244 -0
  13. data/lib/carbon_ruby_sdk/models/organization_user_data_source_api.rb +11 -1
  14. data/lib/carbon_ruby_sdk/models/s3_authentication.rb +244 -0
  15. data/lib/carbon_ruby_sdk/models/salesforce_authentication.rb +254 -0
  16. data/lib/carbon_ruby_sdk/models/sharepoint_authentication.rb +268 -0
  17. data/lib/carbon_ruby_sdk/models/simple_o_auth_data_sources.rb +41 -0
  18. data/lib/carbon_ruby_sdk/models/sitemap_scrape_request.rb +15 -0
  19. data/lib/carbon_ruby_sdk/models/sync_options.rb +322 -0
  20. data/lib/carbon_ruby_sdk/models/webscrape_request.rb +30 -0
  21. data/lib/carbon_ruby_sdk/models/zendesk_authentication.rb +244 -0
  22. data/lib/carbon_ruby_sdk/models/zotero_authentication.rb +272 -0
  23. data/lib/carbon_ruby_sdk/version.rb +1 -1
  24. data/lib/carbon_ruby_sdk.rb +15 -0
  25. data/spec/api/integrations_api_spec.rb +11 -0
  26. data/spec/models/authentication_property_spec.rb +112 -0
  27. data/spec/models/confluence_authentication_spec.rb +46 -0
  28. data/spec/models/connect_data_source_input_spec.rb +34 -0
  29. data/spec/models/connect_data_source_response_spec.rb +34 -0
  30. data/spec/models/freskdesk_authentication_spec.rb +40 -0
  31. data/spec/models/gitbook_authetication_spec.rb +40 -0
  32. data/spec/models/notion_authentication_spec.rb +40 -0
  33. data/spec/models/o_auth_authentication_spec.rb +40 -0
  34. data/spec/models/organization_user_data_source_api_spec.rb +6 -0
  35. data/spec/models/s3_authentication_spec.rb +40 -0
  36. data/spec/models/salesforce_authentication_spec.rb +46 -0
  37. data/spec/models/sharepoint_authentication_spec.rb +52 -0
  38. data/spec/models/simple_o_auth_data_sources_spec.rb +22 -0
  39. data/spec/models/sync_options_spec.rb +82 -0
  40. data/spec/models/zendesk_authentication_spec.rb +40 -0
  41. data/spec/models/zotero_authentication_spec.rb +52 -0
  42. metadata +47 -2
@@ -0,0 +1,268 @@
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 SharepointAuthentication
14
+ attr_accessor :source
15
+
16
+ attr_accessor :access_token
17
+
18
+ attr_accessor :refresh_token
19
+
20
+ attr_accessor :tenant_name
21
+
22
+ attr_accessor :site_name
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'source' => :'source',
28
+ :'access_token' => :'access_token',
29
+ :'refresh_token' => :'refresh_token',
30
+ :'tenant_name' => :'tenant_name',
31
+ :'site_name' => :'site_name'
32
+ }
33
+ end
34
+
35
+ # Returns all the JSON keys this model knows about
36
+ def self.acceptable_attributes
37
+ attribute_map.values
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.openapi_types
42
+ {
43
+ :'source' => :'Object',
44
+ :'access_token' => :'String',
45
+ :'refresh_token' => :'String',
46
+ :'tenant_name' => :'String',
47
+ :'site_name' => :'String'
48
+ }
49
+ end
50
+
51
+ # List of attributes with nullable: true
52
+ def self.openapi_nullable
53
+ Set.new([
54
+ :'source',
55
+ :'refresh_token',
56
+ ])
57
+ end
58
+
59
+ # Initializes the object
60
+ # @param [Hash] attributes Model attributes in the form of hash
61
+ def initialize(attributes = {})
62
+ if (!attributes.is_a?(Hash))
63
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Carbon::SharepointAuthentication` initialize method"
64
+ end
65
+
66
+ # check to see if the attribute exists and convert string to symbol for hash key
67
+ attributes = attributes.each_with_object({}) { |(k, v), h|
68
+ if (!self.class.attribute_map.key?(k.to_sym))
69
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Carbon::SharepointAuthentication`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
70
+ end
71
+ h[k.to_sym] = v
72
+ }
73
+
74
+ if attributes.key?(:'source')
75
+ self.source = attributes[:'source']
76
+ end
77
+
78
+ if attributes.key?(:'access_token')
79
+ self.access_token = attributes[:'access_token']
80
+ end
81
+
82
+ if attributes.key?(:'refresh_token')
83
+ self.refresh_token = attributes[:'refresh_token']
84
+ end
85
+
86
+ if attributes.key?(:'tenant_name')
87
+ self.tenant_name = attributes[:'tenant_name']
88
+ end
89
+
90
+ if attributes.key?(:'site_name')
91
+ self.site_name = attributes[:'site_name']
92
+ end
93
+ end
94
+
95
+ # Show invalid properties with the reasons. Usually used together with valid?
96
+ # @return Array for valid properties with the reasons
97
+ def list_invalid_properties
98
+ invalid_properties = Array.new
99
+ if @access_token.nil?
100
+ invalid_properties.push('invalid value for "access_token", access_token cannot be nil.')
101
+ end
102
+
103
+ if @tenant_name.nil?
104
+ invalid_properties.push('invalid value for "tenant_name", tenant_name cannot be nil.')
105
+ end
106
+
107
+ if @site_name.nil?
108
+ invalid_properties.push('invalid value for "site_name", site_name cannot be nil.')
109
+ end
110
+
111
+ invalid_properties
112
+ end
113
+
114
+ # Check to see if the all the properties in the model are valid
115
+ # @return true if the model is valid
116
+ def valid?
117
+ return false if @access_token.nil?
118
+ return false if @tenant_name.nil?
119
+ return false if @site_name.nil?
120
+ true
121
+ end
122
+
123
+ # Checks equality by comparing each attribute.
124
+ # @param [Object] Object to be compared
125
+ def ==(o)
126
+ return true if self.equal?(o)
127
+ self.class == o.class &&
128
+ source == o.source &&
129
+ access_token == o.access_token &&
130
+ refresh_token == o.refresh_token &&
131
+ tenant_name == o.tenant_name &&
132
+ site_name == o.site_name
133
+ end
134
+
135
+ # @see the `==` method
136
+ # @param [Object] Object to be compared
137
+ def eql?(o)
138
+ self == o
139
+ end
140
+
141
+ # Calculates hash code according to all attributes.
142
+ # @return [Integer] Hash code
143
+ def hash
144
+ [source, access_token, refresh_token, tenant_name, site_name].hash
145
+ end
146
+
147
+ # Builds the object from hash
148
+ # @param [Hash] attributes Model attributes in the form of hash
149
+ # @return [Object] Returns the model itself
150
+ def self.build_from_hash(attributes)
151
+ new.build_from_hash(attributes)
152
+ end
153
+
154
+ # Builds the object from hash
155
+ # @param [Hash] attributes Model attributes in the form of hash
156
+ # @return [Object] Returns the model itself
157
+ def build_from_hash(attributes)
158
+ return nil unless attributes.is_a?(Hash)
159
+ attributes = attributes.transform_keys(&:to_sym)
160
+ self.class.openapi_types.each_pair do |key, type|
161
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
162
+ self.send("#{key}=", nil)
163
+ elsif type =~ /\AArray<(.*)>/i
164
+ # check to ensure the input is an array given that the attribute
165
+ # is documented as an array but the input is not
166
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
167
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
168
+ end
169
+ elsif !attributes[self.class.attribute_map[key]].nil?
170
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
171
+ end
172
+ end
173
+
174
+ self
175
+ end
176
+
177
+ # Deserializes the data based on type
178
+ # @param string type Data type
179
+ # @param string value Value to be deserialized
180
+ # @return [Object] Deserialized data
181
+ def _deserialize(type, value)
182
+ case type.to_sym
183
+ when :Time
184
+ Time.parse(value)
185
+ when :Date
186
+ Date.parse(value)
187
+ when :String
188
+ value.to_s
189
+ when :Integer
190
+ value.to_i
191
+ when :Float
192
+ value.to_f
193
+ when :Boolean
194
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
195
+ true
196
+ else
197
+ false
198
+ end
199
+ when :Object
200
+ # generic object (usually a Hash), return directly
201
+ value
202
+ when /\AArray<(?<inner_type>.+)>\z/
203
+ inner_type = Regexp.last_match[:inner_type]
204
+ value.map { |v| _deserialize(inner_type, v) }
205
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
206
+ k_type = Regexp.last_match[:k_type]
207
+ v_type = Regexp.last_match[:v_type]
208
+ {}.tap do |hash|
209
+ value.each do |k, v|
210
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
211
+ end
212
+ end
213
+ else # model
214
+ # models (e.g. Pet) or oneOf
215
+ klass = Carbon.const_get(type)
216
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
217
+ end
218
+ end
219
+
220
+ # Returns the string representation of the object
221
+ # @return [String] String presentation of the object
222
+ def to_s
223
+ to_hash.to_s
224
+ end
225
+
226
+ # to_body is an alias to to_hash (backward compatibility)
227
+ # @return [Hash] Returns the object in the form of hash
228
+ def to_body
229
+ to_hash
230
+ end
231
+
232
+ # Returns the object in the form of hash
233
+ # @return [Hash] Returns the object in the form of hash
234
+ def to_hash
235
+ hash = {}
236
+ self.class.attribute_map.each_pair do |attr, param|
237
+ value = self.send(attr)
238
+ if value.nil?
239
+ is_nullable = self.class.openapi_nullable.include?(attr)
240
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
241
+ end
242
+
243
+ hash[param] = _to_hash(value)
244
+ end
245
+ hash
246
+ end
247
+
248
+ # Outputs non-array value in the form of hash
249
+ # For object, use to_hash. Otherwise, just return the value
250
+ # @param [Object] value Any valid value
251
+ # @return [Hash] Returns the value in the form of hash
252
+ def _to_hash(value)
253
+ if value.is_a?(Array)
254
+ value.compact.map { |v| _to_hash(v) }
255
+ elsif value.is_a?(Hash)
256
+ {}.tap do |hash|
257
+ value.each { |k, v| hash[k] = _to_hash(v) }
258
+ end
259
+ elsif value.respond_to? :to_hash
260
+ value.to_hash
261
+ else
262
+ value
263
+ end
264
+ end
265
+
266
+ end
267
+
268
+ end
@@ -0,0 +1,41 @@
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 SimpleOAuthDataSources
14
+ GOOGLE_DRIVE = "GOOGLE_DRIVE".freeze
15
+ INTERCOM = "INTERCOM".freeze
16
+ DROPBOX = "DROPBOX".freeze
17
+ ONEDRIVE = "ONEDRIVE".freeze
18
+ BOX = "BOX".freeze
19
+ GMAIL = "GMAIL".freeze
20
+ OUTLOOK = "OUTLOOK".freeze
21
+
22
+ def self.all_vars
23
+ @all_vars ||= [GOOGLE_DRIVE, INTERCOM, DROPBOX, ONEDRIVE, BOX, GMAIL, OUTLOOK].freeze
24
+ end
25
+
26
+ # Builds the enum from string
27
+ # @param [String] The enum value in the form of the string
28
+ # @return [String] The enum value
29
+ def self.build_from_hash(value)
30
+ new.build_from_hash(value)
31
+ end
32
+
33
+ # Builds the enum from string
34
+ # @param [String] The enum value in the form of the string
35
+ # @return [String] The enum value
36
+ def build_from_hash(value)
37
+ return value if SimpleOAuthDataSources.all_vars.include?(value)
38
+ raise "Invalid ENUM value #{value} for class #SimpleOAuthDataSources"
39
+ end
40
+ end
41
+ end
@@ -195,6 +195,10 @@ module Carbon
195
195
  invalid_properties.push('invalid value for "url", url cannot be nil.')
196
196
  end
197
197
 
198
+ if !@max_pages_to_scrape.nil? && @max_pages_to_scrape < 1
199
+ invalid_properties.push('invalid value for "max_pages_to_scrape", must be greater than or equal to 1.')
200
+ end
201
+
198
202
  invalid_properties
199
203
  end
200
204
 
@@ -202,9 +206,20 @@ module Carbon
202
206
  # @return true if the model is valid
203
207
  def valid?
204
208
  return false if @url.nil?
209
+ return false if !@max_pages_to_scrape.nil? && @max_pages_to_scrape < 1
205
210
  true
206
211
  end
207
212
 
213
+ # Custom attribute writer method with validation
214
+ # @param [Object] max_pages_to_scrape Value to be assigned
215
+ def max_pages_to_scrape=(max_pages_to_scrape)
216
+ if !max_pages_to_scrape.nil? && max_pages_to_scrape < 1
217
+ fail ArgumentError, 'invalid value for "max_pages_to_scrape", must be greater than or equal to 1.'
218
+ end
219
+
220
+ @max_pages_to_scrape = max_pages_to_scrape
221
+ end
222
+
208
223
  # Checks equality by comparing each attribute.
209
224
  # @param [Object] Object to be compared
210
225
  def ==(o)
@@ -0,0 +1,322 @@
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 SyncOptions
14
+ attr_accessor :tags
15
+
16
+ attr_accessor :chunk_size
17
+
18
+ attr_accessor :chunk_overlap
19
+
20
+ attr_accessor :skip_embedding_generation
21
+
22
+ attr_accessor :embedding_model
23
+
24
+ attr_accessor :generate_sparse_vectors
25
+
26
+ attr_accessor :prepend_filename_to_chunks
27
+
28
+ attr_accessor :max_items_per_chunk
29
+
30
+ # Used to specify whether Carbon should attempt to sync all your files automatically when authorization is complete. This is only supported for a subset of connectors and will be ignored for the rest. Supported connectors: Intercom, Zendesk, Gitbook, Confluence, Salesforce, Freshdesk
31
+ attr_accessor :sync_files_on_connection
32
+
33
+ attr_accessor :set_page_as_boundary
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+ :'tags' => :'tags',
39
+ :'chunk_size' => :'chunk_size',
40
+ :'chunk_overlap' => :'chunk_overlap',
41
+ :'skip_embedding_generation' => :'skip_embedding_generation',
42
+ :'embedding_model' => :'embedding_model',
43
+ :'generate_sparse_vectors' => :'generate_sparse_vectors',
44
+ :'prepend_filename_to_chunks' => :'prepend_filename_to_chunks',
45
+ :'max_items_per_chunk' => :'max_items_per_chunk',
46
+ :'sync_files_on_connection' => :'sync_files_on_connection',
47
+ :'set_page_as_boundary' => :'set_page_as_boundary'
48
+ }
49
+ end
50
+
51
+ # Returns all the JSON keys this model knows about
52
+ def self.acceptable_attributes
53
+ attribute_map.values
54
+ end
55
+
56
+ # Attribute type mapping.
57
+ def self.openapi_types
58
+ {
59
+ :'tags' => :'Object',
60
+ :'chunk_size' => :'Integer',
61
+ :'chunk_overlap' => :'Integer',
62
+ :'skip_embedding_generation' => :'Boolean',
63
+ :'embedding_model' => :'EmbeddingGeneratorsNullable',
64
+ :'generate_sparse_vectors' => :'Boolean',
65
+ :'prepend_filename_to_chunks' => :'Boolean',
66
+ :'max_items_per_chunk' => :'Integer',
67
+ :'sync_files_on_connection' => :'Boolean',
68
+ :'set_page_as_boundary' => :'Boolean'
69
+ }
70
+ end
71
+
72
+ # List of attributes with nullable: true
73
+ def self.openapi_nullable
74
+ Set.new([
75
+ :'tags',
76
+ :'chunk_size',
77
+ :'chunk_overlap',
78
+ :'skip_embedding_generation',
79
+ :'embedding_model',
80
+ :'generate_sparse_vectors',
81
+ :'prepend_filename_to_chunks',
82
+ :'max_items_per_chunk',
83
+ :'sync_files_on_connection',
84
+ ])
85
+ end
86
+
87
+ # Initializes the object
88
+ # @param [Hash] attributes Model attributes in the form of hash
89
+ def initialize(attributes = {})
90
+ if (!attributes.is_a?(Hash))
91
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Carbon::SyncOptions` initialize method"
92
+ end
93
+
94
+ # check to see if the attribute exists and convert string to symbol for hash key
95
+ attributes = attributes.each_with_object({}) { |(k, v), h|
96
+ if (!self.class.attribute_map.key?(k.to_sym))
97
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Carbon::SyncOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
98
+ end
99
+ h[k.to_sym] = v
100
+ }
101
+
102
+ if attributes.key?(:'tags')
103
+ self.tags = attributes[:'tags']
104
+ end
105
+
106
+ if attributes.key?(:'chunk_size')
107
+ self.chunk_size = attributes[:'chunk_size']
108
+ else
109
+ self.chunk_size = 1500
110
+ end
111
+
112
+ if attributes.key?(:'chunk_overlap')
113
+ self.chunk_overlap = attributes[:'chunk_overlap']
114
+ else
115
+ self.chunk_overlap = 20
116
+ end
117
+
118
+ if attributes.key?(:'skip_embedding_generation')
119
+ self.skip_embedding_generation = attributes[:'skip_embedding_generation']
120
+ else
121
+ self.skip_embedding_generation = false
122
+ end
123
+
124
+ if attributes.key?(:'embedding_model')
125
+ self.embedding_model = attributes[:'embedding_model']
126
+ else
127
+ self.embedding_model = 'OPENAI'
128
+ end
129
+
130
+ if attributes.key?(:'generate_sparse_vectors')
131
+ self.generate_sparse_vectors = attributes[:'generate_sparse_vectors']
132
+ else
133
+ self.generate_sparse_vectors = false
134
+ end
135
+
136
+ if attributes.key?(:'prepend_filename_to_chunks')
137
+ self.prepend_filename_to_chunks = attributes[:'prepend_filename_to_chunks']
138
+ else
139
+ self.prepend_filename_to_chunks = false
140
+ end
141
+
142
+ if attributes.key?(:'max_items_per_chunk')
143
+ self.max_items_per_chunk = attributes[:'max_items_per_chunk']
144
+ end
145
+
146
+ if attributes.key?(:'sync_files_on_connection')
147
+ self.sync_files_on_connection = attributes[:'sync_files_on_connection']
148
+ else
149
+ self.sync_files_on_connection = true
150
+ end
151
+
152
+ if attributes.key?(:'set_page_as_boundary')
153
+ self.set_page_as_boundary = attributes[:'set_page_as_boundary']
154
+ else
155
+ self.set_page_as_boundary = false
156
+ end
157
+ end
158
+
159
+ # Show invalid properties with the reasons. Usually used together with valid?
160
+ # @return Array for valid properties with the reasons
161
+ def list_invalid_properties
162
+ invalid_properties = Array.new
163
+ invalid_properties
164
+ end
165
+
166
+ # Check to see if the all the properties in the model are valid
167
+ # @return true if the model is valid
168
+ def valid?
169
+ true
170
+ end
171
+
172
+ # Checks equality by comparing each attribute.
173
+ # @param [Object] Object to be compared
174
+ def ==(o)
175
+ return true if self.equal?(o)
176
+ self.class == o.class &&
177
+ tags == o.tags &&
178
+ chunk_size == o.chunk_size &&
179
+ chunk_overlap == o.chunk_overlap &&
180
+ skip_embedding_generation == o.skip_embedding_generation &&
181
+ embedding_model == o.embedding_model &&
182
+ generate_sparse_vectors == o.generate_sparse_vectors &&
183
+ prepend_filename_to_chunks == o.prepend_filename_to_chunks &&
184
+ max_items_per_chunk == o.max_items_per_chunk &&
185
+ sync_files_on_connection == o.sync_files_on_connection &&
186
+ set_page_as_boundary == o.set_page_as_boundary
187
+ end
188
+
189
+ # @see the `==` method
190
+ # @param [Object] Object to be compared
191
+ def eql?(o)
192
+ self == o
193
+ end
194
+
195
+ # Calculates hash code according to all attributes.
196
+ # @return [Integer] Hash code
197
+ def hash
198
+ [tags, chunk_size, chunk_overlap, skip_embedding_generation, embedding_model, generate_sparse_vectors, prepend_filename_to_chunks, max_items_per_chunk, sync_files_on_connection, set_page_as_boundary].hash
199
+ end
200
+
201
+ # Builds the object from hash
202
+ # @param [Hash] attributes Model attributes in the form of hash
203
+ # @return [Object] Returns the model itself
204
+ def self.build_from_hash(attributes)
205
+ new.build_from_hash(attributes)
206
+ end
207
+
208
+ # Builds the object from hash
209
+ # @param [Hash] attributes Model attributes in the form of hash
210
+ # @return [Object] Returns the model itself
211
+ def build_from_hash(attributes)
212
+ return nil unless attributes.is_a?(Hash)
213
+ attributes = attributes.transform_keys(&:to_sym)
214
+ self.class.openapi_types.each_pair do |key, type|
215
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
216
+ self.send("#{key}=", nil)
217
+ elsif type =~ /\AArray<(.*)>/i
218
+ # check to ensure the input is an array given that the attribute
219
+ # is documented as an array but the input is not
220
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
221
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
222
+ end
223
+ elsif !attributes[self.class.attribute_map[key]].nil?
224
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
225
+ end
226
+ end
227
+
228
+ self
229
+ end
230
+
231
+ # Deserializes the data based on type
232
+ # @param string type Data type
233
+ # @param string value Value to be deserialized
234
+ # @return [Object] Deserialized data
235
+ def _deserialize(type, value)
236
+ case type.to_sym
237
+ when :Time
238
+ Time.parse(value)
239
+ when :Date
240
+ Date.parse(value)
241
+ when :String
242
+ value.to_s
243
+ when :Integer
244
+ value.to_i
245
+ when :Float
246
+ value.to_f
247
+ when :Boolean
248
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
249
+ true
250
+ else
251
+ false
252
+ end
253
+ when :Object
254
+ # generic object (usually a Hash), return directly
255
+ value
256
+ when /\AArray<(?<inner_type>.+)>\z/
257
+ inner_type = Regexp.last_match[:inner_type]
258
+ value.map { |v| _deserialize(inner_type, v) }
259
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
260
+ k_type = Regexp.last_match[:k_type]
261
+ v_type = Regexp.last_match[:v_type]
262
+ {}.tap do |hash|
263
+ value.each do |k, v|
264
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
265
+ end
266
+ end
267
+ else # model
268
+ # models (e.g. Pet) or oneOf
269
+ klass = Carbon.const_get(type)
270
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
271
+ end
272
+ end
273
+
274
+ # Returns the string representation of the object
275
+ # @return [String] String presentation of the object
276
+ def to_s
277
+ to_hash.to_s
278
+ end
279
+
280
+ # to_body is an alias to to_hash (backward compatibility)
281
+ # @return [Hash] Returns the object in the form of hash
282
+ def to_body
283
+ to_hash
284
+ end
285
+
286
+ # Returns the object in the form of hash
287
+ # @return [Hash] Returns the object in the form of hash
288
+ def to_hash
289
+ hash = {}
290
+ self.class.attribute_map.each_pair do |attr, param|
291
+ value = self.send(attr)
292
+ if value.nil?
293
+ is_nullable = self.class.openapi_nullable.include?(attr)
294
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
295
+ end
296
+
297
+ hash[param] = _to_hash(value)
298
+ end
299
+ hash
300
+ end
301
+
302
+ # Outputs non-array value in the form of hash
303
+ # For object, use to_hash. Otherwise, just return the value
304
+ # @param [Object] value Any valid value
305
+ # @return [Hash] Returns the value in the form of hash
306
+ def _to_hash(value)
307
+ if value.is_a?(Array)
308
+ value.compact.map { |v| _to_hash(v) }
309
+ elsif value.is_a?(Hash)
310
+ {}.tap do |hash|
311
+ value.each { |k, v| hash[k] = _to_hash(v) }
312
+ end
313
+ elsif value.respond_to? :to_hash
314
+ value.to_hash
315
+ else
316
+ value
317
+ end
318
+ end
319
+
320
+ end
321
+
322
+ end
@@ -208,6 +208,14 @@ module Carbon
208
208
  invalid_properties.push('invalid value for "url", url cannot be nil.')
209
209
  end
210
210
 
211
+ if !@recursion_depth.nil? && @recursion_depth < 0
212
+ invalid_properties.push('invalid value for "recursion_depth", must be greater than or equal to 0.')
213
+ end
214
+
215
+ if !@max_pages_to_scrape.nil? && @max_pages_to_scrape < 1
216
+ invalid_properties.push('invalid value for "max_pages_to_scrape", must be greater than or equal to 1.')
217
+ end
218
+
211
219
  invalid_properties
212
220
  end
213
221
 
@@ -215,9 +223,31 @@ module Carbon
215
223
  # @return true if the model is valid
216
224
  def valid?
217
225
  return false if @url.nil?
226
+ return false if !@recursion_depth.nil? && @recursion_depth < 0
227
+ return false if !@max_pages_to_scrape.nil? && @max_pages_to_scrape < 1
218
228
  true
219
229
  end
220
230
 
231
+ # Custom attribute writer method with validation
232
+ # @param [Object] recursion_depth Value to be assigned
233
+ def recursion_depth=(recursion_depth)
234
+ if !recursion_depth.nil? && recursion_depth < 0
235
+ fail ArgumentError, 'invalid value for "recursion_depth", must be greater than or equal to 0.'
236
+ end
237
+
238
+ @recursion_depth = recursion_depth
239
+ end
240
+
241
+ # Custom attribute writer method with validation
242
+ # @param [Object] max_pages_to_scrape Value to be assigned
243
+ def max_pages_to_scrape=(max_pages_to_scrape)
244
+ if !max_pages_to_scrape.nil? && max_pages_to_scrape < 1
245
+ fail ArgumentError, 'invalid value for "max_pages_to_scrape", must be greater than or equal to 1.'
246
+ end
247
+
248
+ @max_pages_to_scrape = max_pages_to_scrape
249
+ end
250
+
221
251
  # Checks equality by comparing each attribute.
222
252
  # @param [Object] Object to be compared
223
253
  def ==(o)