carbon_ruby_sdk 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +89 -0
- data/README.md +2325 -0
- data/Rakefile +10 -0
- data/carbon_ruby_sdk.gemspec +39 -0
- data/header.png +0 -0
- data/lib/carbon_ruby_sdk/api/auth_api.rb +177 -0
- data/lib/carbon_ruby_sdk/api/data_sources_api.rb +217 -0
- data/lib/carbon_ruby_sdk/api/embeddings_api.rb +565 -0
- data/lib/carbon_ruby_sdk/api/files_api.rb +1526 -0
- data/lib/carbon_ruby_sdk/api/health_api.rb +92 -0
- data/lib/carbon_ruby_sdk/api/integrations_api.rb +2201 -0
- data/lib/carbon_ruby_sdk/api/organizations_api.rb +92 -0
- data/lib/carbon_ruby_sdk/api/users_api.rb +209 -0
- data/lib/carbon_ruby_sdk/api/utilities_api.rb +710 -0
- data/lib/carbon_ruby_sdk/api/webhooks_api.rb +296 -0
- data/lib/carbon_ruby_sdk/api_client.rb +436 -0
- data/lib/carbon_ruby_sdk/api_client_custom.rb +14 -0
- data/lib/carbon_ruby_sdk/api_error.rb +53 -0
- data/lib/carbon_ruby_sdk/configuration.rb +354 -0
- data/lib/carbon_ruby_sdk/models/add_webhook_props.rb +220 -0
- data/lib/carbon_ruby_sdk/models/body_create_upload_file_uploadfile_post.rb +220 -0
- data/lib/carbon_ruby_sdk/models/chunk_properties.rb +248 -0
- data/lib/carbon_ruby_sdk/models/chunk_properties_nullable.rb +248 -0
- data/lib/carbon_ruby_sdk/models/chunks_and_embeddings.rb +246 -0
- data/lib/carbon_ruby_sdk/models/chunks_and_embeddings_upload_input.rb +247 -0
- data/lib/carbon_ruby_sdk/models/data_source_last_sync_actions.rb +38 -0
- data/lib/carbon_ruby_sdk/models/data_source_sync_statuses.rb +38 -0
- data/lib/carbon_ruby_sdk/models/data_source_type.rb +76 -0
- data/lib/carbon_ruby_sdk/models/data_source_type_nullable.rb +76 -0
- data/lib/carbon_ruby_sdk/models/delete_files_query_input.rb +252 -0
- data/lib/carbon_ruby_sdk/models/directory_item.rb +266 -0
- data/lib/carbon_ruby_sdk/models/document_response.rb +328 -0
- data/lib/carbon_ruby_sdk/models/document_response_list.rb +222 -0
- data/lib/carbon_ruby_sdk/models/embedding_and_chunk.rb +256 -0
- data/lib/carbon_ruby_sdk/models/embedding_generators.rb +43 -0
- data/lib/carbon_ruby_sdk/models/embedding_generators_nullable.rb +43 -0
- data/lib/carbon_ruby_sdk/models/embedding_properties.rb +226 -0
- data/lib/carbon_ruby_sdk/models/embeddings_and_chunks_filters.rb +232 -0
- data/lib/carbon_ruby_sdk/models/embeddings_and_chunks_order_by_columns.rb +37 -0
- data/lib/carbon_ruby_sdk/models/embeddings_and_chunks_query_input.rb +262 -0
- data/lib/carbon_ruby_sdk/models/embeddings_and_chunks_response.rb +236 -0
- data/lib/carbon_ruby_sdk/models/external_file_sync_statuses.rb +43 -0
- data/lib/carbon_ruby_sdk/models/external_source_item.rb +420 -0
- data/lib/carbon_ruby_sdk/models/fetch_urls_response.rb +236 -0
- data/lib/carbon_ruby_sdk/models/file_content_types.rb +36 -0
- data/lib/carbon_ruby_sdk/models/file_content_types_nullable.rb +36 -0
- data/lib/carbon_ruby_sdk/models/file_formats.rb +76 -0
- data/lib/carbon_ruby_sdk/models/file_formats_nullable.rb +76 -0
- data/lib/carbon_ruby_sdk/models/file_statistics.rb +256 -0
- data/lib/carbon_ruby_sdk/models/file_statistics_nullable.rb +256 -0
- data/lib/carbon_ruby_sdk/models/fresh_desk_connect_request.rb +316 -0
- data/lib/carbon_ruby_sdk/models/generic_success_response.rb +220 -0
- data/lib/carbon_ruby_sdk/models/get_embedding_documents_body.rb +416 -0
- data/lib/carbon_ruby_sdk/models/gitbook_connect_request.rb +234 -0
- data/lib/carbon_ruby_sdk/models/gitbook_sync_request.rb +336 -0
- data/lib/carbon_ruby_sdk/models/gmail_sync_input.rb +301 -0
- data/lib/carbon_ruby_sdk/models/http_validation_error.rb +217 -0
- data/lib/carbon_ruby_sdk/models/hybrid_search_tuning_params.rb +234 -0
- data/lib/carbon_ruby_sdk/models/hybrid_search_tuning_params_nullable.rb +235 -0
- data/lib/carbon_ruby_sdk/models/list_data_source_items_request.rb +239 -0
- data/lib/carbon_ruby_sdk/models/list_data_source_items_response.rb +236 -0
- data/lib/carbon_ruby_sdk/models/list_request.rb +230 -0
- data/lib/carbon_ruby_sdk/models/list_response.rb +222 -0
- data/lib/carbon_ruby_sdk/models/location_property_inner.rb +226 -0
- data/lib/carbon_ruby_sdk/models/modify_user_configuration_input.rb +234 -0
- data/lib/carbon_ruby_sdk/models/o_auth_url_request.rb +362 -0
- data/lib/carbon_ruby_sdk/models/order_dir.rb +36 -0
- data/lib/carbon_ruby_sdk/models/organization_response.rb +362 -0
- data/lib/carbon_ruby_sdk/models/organization_user_data_source_api.rb +380 -0
- data/lib/carbon_ruby_sdk/models/organization_user_data_source_filters.rb +238 -0
- data/lib/carbon_ruby_sdk/models/organization_user_data_source_order_by_columns.rb +36 -0
- data/lib/carbon_ruby_sdk/models/organization_user_data_source_query_input.rb +246 -0
- data/lib/carbon_ruby_sdk/models/organization_user_data_source_response.rb +236 -0
- data/lib/carbon_ruby_sdk/models/organization_user_file_tag_create.rb +236 -0
- data/lib/carbon_ruby_sdk/models/organization_user_file_tags_remove.rb +236 -0
- data/lib/carbon_ruby_sdk/models/organization_user_files_to_sync_filters.rb +330 -0
- data/lib/carbon_ruby_sdk/models/organization_user_files_to_sync_order_by_types.rb +39 -0
- data/lib/carbon_ruby_sdk/models/organization_user_files_to_sync_query_input.rb +276 -0
- data/lib/carbon_ruby_sdk/models/outlook_sync_input.rb +313 -0
- data/lib/carbon_ruby_sdk/models/pagination.rb +228 -0
- data/lib/carbon_ruby_sdk/models/presigned_url_response.rb +220 -0
- data/lib/carbon_ruby_sdk/models/rank_property.rb +226 -0
- data/lib/carbon_ruby_sdk/models/raw_text_input.rb +295 -0
- data/lib/carbon_ruby_sdk/models/raw_transcript_property_inner_value.rb +226 -0
- data/lib/carbon_ruby_sdk/models/resync_file_query_input.rb +240 -0
- data/lib/carbon_ruby_sdk/models/revoke_access_token_input.rb +220 -0
- data/lib/carbon_ruby_sdk/models/rss_feed_input.rb +301 -0
- data/lib/carbon_ruby_sdk/models/s3_auth_request.rb +234 -0
- data/lib/carbon_ruby_sdk/models/s3_file_sync_input.rb +313 -0
- data/lib/carbon_ruby_sdk/models/s3_get_file_input.rb +226 -0
- data/lib/carbon_ruby_sdk/models/single_chunks_and_embeddings_upload_input.rb +256 -0
- data/lib/carbon_ruby_sdk/models/sitemap_scrape_request.rb +361 -0
- data/lib/carbon_ruby_sdk/models/source_property.rb +226 -0
- data/lib/carbon_ruby_sdk/models/sync_directory_request.rb +220 -0
- data/lib/carbon_ruby_sdk/models/sync_files_request.rb +328 -0
- data/lib/carbon_ruby_sdk/models/tags.rb +232 -0
- data/lib/carbon_ruby_sdk/models/tags1.rb +230 -0
- data/lib/carbon_ruby_sdk/models/text_embedding_generators.rb +42 -0
- data/lib/carbon_ruby_sdk/models/token_response.rb +234 -0
- data/lib/carbon_ruby_sdk/models/upload_file_from_url_input.rb +326 -0
- data/lib/carbon_ruby_sdk/models/user_file.rb +524 -0
- data/lib/carbon_ruby_sdk/models/user_files_v2.rb +236 -0
- data/lib/carbon_ruby_sdk/models/user_request_content.rb +220 -0
- data/lib/carbon_ruby_sdk/models/user_response.rb +354 -0
- data/lib/carbon_ruby_sdk/models/validation_error.rb +250 -0
- data/lib/carbon_ruby_sdk/models/webhook.rb +290 -0
- data/lib/carbon_ruby_sdk/models/webhook_filters.rb +218 -0
- data/lib/carbon_ruby_sdk/models/webhook_no_key.rb +276 -0
- data/lib/carbon_ruby_sdk/models/webhook_order_by_columns.rb +36 -0
- data/lib/carbon_ruby_sdk/models/webhook_query_input.rb +246 -0
- data/lib/carbon_ruby_sdk/models/webhook_query_response.rb +236 -0
- data/lib/carbon_ruby_sdk/models/webscrape_request.rb +375 -0
- data/lib/carbon_ruby_sdk/models/white_labeling_response.rb +234 -0
- data/lib/carbon_ruby_sdk/models/youtube_transcript_response.rb +252 -0
- data/lib/carbon_ruby_sdk/version.rb +11 -0
- data/lib/carbon_ruby_sdk.rb +207 -0
- data/spec/api/auth_api_spec.rb +50 -0
- data/spec/api/data_sources_api_spec.rb +51 -0
- data/spec/api/embeddings_api_spec.rb +63 -0
- data/spec/api/files_api_spec.rb +178 -0
- data/spec/api/health_api_spec.rb +39 -0
- data/spec/api/integrations_api_spec.rb +226 -0
- data/spec/api/organizations_api_spec.rb +39 -0
- data/spec/api/users_api_spec.rb +51 -0
- data/spec/api/utilities_api_spec.rb +102 -0
- data/spec/api/webhooks_api_spec.rb +62 -0
- data/spec/api_client_spec.rb +191 -0
- data/spec/configuration_spec.rb +38 -0
- data/spec/getting_started_spec.rb +196 -0
- data/spec/models/add_webhook_props_spec.rb +28 -0
- data/spec/models/body_create_upload_file_uploadfile_post_spec.rb +28 -0
- data/spec/models/chunk_properties_nullable_spec.rb +40 -0
- data/spec/models/chunk_properties_spec.rb +40 -0
- data/spec/models/chunks_and_embeddings_spec.rb +40 -0
- data/spec/models/chunks_and_embeddings_upload_input_spec.rb +40 -0
- data/spec/models/data_source_last_sync_actions_spec.rb +22 -0
- data/spec/models/data_source_sync_statuses_spec.rb +22 -0
- data/spec/models/data_source_type_nullable_spec.rb +22 -0
- data/spec/models/data_source_type_spec.rb +22 -0
- data/spec/models/delete_files_query_input_spec.rb +46 -0
- data/spec/models/directory_item_spec.rb +46 -0
- data/spec/models/document_response_list_spec.rb +28 -0
- data/spec/models/document_response_spec.rb +88 -0
- data/spec/models/embedding_and_chunk_spec.rb +46 -0
- data/spec/models/embedding_generators_nullable_spec.rb +22 -0
- data/spec/models/embedding_generators_spec.rb +22 -0
- data/spec/models/embedding_properties_spec.rb +34 -0
- data/spec/models/embeddings_and_chunks_filters_spec.rb +34 -0
- data/spec/models/embeddings_and_chunks_order_by_columns_spec.rb +22 -0
- data/spec/models/embeddings_and_chunks_query_input_spec.rb +52 -0
- data/spec/models/embeddings_and_chunks_response_spec.rb +34 -0
- data/spec/models/external_file_sync_statuses_spec.rb +22 -0
- data/spec/models/external_source_item_spec.rb +124 -0
- data/spec/models/fetch_urls_response_spec.rb +34 -0
- data/spec/models/file_content_types_nullable_spec.rb +22 -0
- data/spec/models/file_content_types_spec.rb +22 -0
- data/spec/models/file_formats_nullable_spec.rb +22 -0
- data/spec/models/file_formats_spec.rb +22 -0
- data/spec/models/file_statistics_nullable_spec.rb +52 -0
- data/spec/models/file_statistics_spec.rb +52 -0
- data/spec/models/fresh_desk_connect_request_spec.rb +76 -0
- data/spec/models/generic_success_response_spec.rb +28 -0
- data/spec/models/get_embedding_documents_body_spec.rb +106 -0
- data/spec/models/gitbook_connect_request_spec.rb +34 -0
- data/spec/models/gitbook_sync_request_spec.rb +76 -0
- data/spec/models/gmail_sync_input_spec.rb +70 -0
- data/spec/models/http_validation_error_spec.rb +28 -0
- data/spec/models/hybrid_search_tuning_params_nullable_spec.rb +34 -0
- data/spec/models/hybrid_search_tuning_params_spec.rb +34 -0
- data/spec/models/list_data_source_items_request_spec.rb +40 -0
- data/spec/models/list_data_source_items_response_spec.rb +34 -0
- data/spec/models/list_request_spec.rb +34 -0
- data/spec/models/list_response_spec.rb +28 -0
- data/spec/models/location_property_inner_spec.rb +22 -0
- data/spec/models/modify_user_configuration_input_spec.rb +34 -0
- data/spec/models/o_auth_url_request_spec.rb +106 -0
- data/spec/models/order_dir_spec.rb +22 -0
- data/spec/models/organization_response_spec.rb +94 -0
- data/spec/models/organization_user_data_source_api_spec.rb +100 -0
- data/spec/models/organization_user_data_source_filters_spec.rb +40 -0
- data/spec/models/organization_user_data_source_order_by_columns_spec.rb +22 -0
- data/spec/models/organization_user_data_source_query_input_spec.rb +46 -0
- data/spec/models/organization_user_data_source_response_spec.rb +34 -0
- data/spec/models/organization_user_file_tag_create_spec.rb +34 -0
- data/spec/models/organization_user_file_tags_remove_spec.rb +34 -0
- data/spec/models/organization_user_files_to_sync_filters_spec.rb +88 -0
- data/spec/models/organization_user_files_to_sync_order_by_types_spec.rb +22 -0
- data/spec/models/organization_user_files_to_sync_query_input_spec.rb +64 -0
- data/spec/models/outlook_sync_input_spec.rb +76 -0
- data/spec/models/pagination_spec.rb +34 -0
- data/spec/models/presigned_url_response_spec.rb +28 -0
- data/spec/models/rank_property_spec.rb +22 -0
- data/spec/models/raw_text_input_spec.rb +70 -0
- data/spec/models/raw_transcript_property_inner_value_spec.rb +22 -0
- data/spec/models/resync_file_query_input_spec.rb +40 -0
- data/spec/models/revoke_access_token_input_spec.rb +28 -0
- data/spec/models/rss_feed_input_spec.rb +70 -0
- data/spec/models/s3_auth_request_spec.rb +34 -0
- data/spec/models/s3_file_sync_input_spec.rb +76 -0
- data/spec/models/s3_get_file_input_spec.rb +34 -0
- data/spec/models/single_chunks_and_embeddings_upload_input_spec.rb +46 -0
- data/spec/models/sitemap_scrape_request_spec.rb +100 -0
- data/spec/models/source_property_spec.rb +22 -0
- data/spec/models/sync_directory_request_spec.rb +28 -0
- data/spec/models/sync_files_request_spec.rb +82 -0
- data/spec/models/tags1_spec.rb +22 -0
- data/spec/models/tags_spec.rb +22 -0
- data/spec/models/text_embedding_generators_spec.rb +22 -0
- data/spec/models/token_response_spec.rb +34 -0
- data/spec/models/upload_file_from_url_input_spec.rb +88 -0
- data/spec/models/user_file_spec.rb +190 -0
- data/spec/models/user_files_v2_spec.rb +34 -0
- data/spec/models/user_request_content_spec.rb +28 -0
- data/spec/models/user_response_spec.rb +88 -0
- data/spec/models/validation_error_spec.rb +40 -0
- data/spec/models/webhook_filters_spec.rb +28 -0
- data/spec/models/webhook_no_key_spec.rb +52 -0
- data/spec/models/webhook_order_by_columns_spec.rb +22 -0
- data/spec/models/webhook_query_input_spec.rb +46 -0
- data/spec/models/webhook_query_response_spec.rb +34 -0
- data/spec/models/webhook_spec.rb +58 -0
- data/spec/models/webscrape_request_spec.rb +106 -0
- data/spec/models/white_labeling_response_spec.rb +34 -0
- data/spec/models/youtube_transcript_response_spec.rb +46 -0
- data/spec/spec_helper.rb +107 -0
- metadata +440 -0
@@ -0,0 +1,220 @@
|
|
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 BodyCreateUploadFileUploadfilePost
|
14
|
+
attr_accessor :file
|
15
|
+
|
16
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
17
|
+
def self.attribute_map
|
18
|
+
{
|
19
|
+
:'file' => :'file'
|
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
|
+
:'file' => :'File'
|
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::BodyCreateUploadFileUploadfilePost` 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::BodyCreateUploadFileUploadfilePost`. 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?(:'file')
|
57
|
+
self.file = attributes[:'file']
|
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
|
+
if @file.nil?
|
66
|
+
invalid_properties.push('invalid value for "file", file cannot be nil.')
|
67
|
+
end
|
68
|
+
|
69
|
+
invalid_properties
|
70
|
+
end
|
71
|
+
|
72
|
+
# Check to see if the all the properties in the model are valid
|
73
|
+
# @return true if the model is valid
|
74
|
+
def valid?
|
75
|
+
return false if @file.nil?
|
76
|
+
true
|
77
|
+
end
|
78
|
+
|
79
|
+
# Checks equality by comparing each attribute.
|
80
|
+
# @param [Object] Object to be compared
|
81
|
+
def ==(o)
|
82
|
+
return true if self.equal?(o)
|
83
|
+
self.class == o.class &&
|
84
|
+
file == o.file
|
85
|
+
end
|
86
|
+
|
87
|
+
# @see the `==` method
|
88
|
+
# @param [Object] Object to be compared
|
89
|
+
def eql?(o)
|
90
|
+
self == o
|
91
|
+
end
|
92
|
+
|
93
|
+
# Calculates hash code according to all attributes.
|
94
|
+
# @return [Integer] Hash code
|
95
|
+
def hash
|
96
|
+
[file].hash
|
97
|
+
end
|
98
|
+
|
99
|
+
# Builds the object from hash
|
100
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
101
|
+
# @return [Object] Returns the model itself
|
102
|
+
def self.build_from_hash(attributes)
|
103
|
+
new.build_from_hash(attributes)
|
104
|
+
end
|
105
|
+
|
106
|
+
# Builds the object from hash
|
107
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
108
|
+
# @return [Object] Returns the model itself
|
109
|
+
def build_from_hash(attributes)
|
110
|
+
return nil unless attributes.is_a?(Hash)
|
111
|
+
attributes = attributes.transform_keys(&:to_sym)
|
112
|
+
self.class.openapi_types.each_pair do |key, type|
|
113
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
114
|
+
self.send("#{key}=", nil)
|
115
|
+
elsif type =~ /\AArray<(.*)>/i
|
116
|
+
# check to ensure the input is an array given that the attribute
|
117
|
+
# is documented as an array but the input is not
|
118
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
119
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
120
|
+
end
|
121
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
122
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
self
|
127
|
+
end
|
128
|
+
|
129
|
+
# Deserializes the data based on type
|
130
|
+
# @param string type Data type
|
131
|
+
# @param string value Value to be deserialized
|
132
|
+
# @return [Object] Deserialized data
|
133
|
+
def _deserialize(type, value)
|
134
|
+
case type.to_sym
|
135
|
+
when :Time
|
136
|
+
Time.parse(value)
|
137
|
+
when :Date
|
138
|
+
Date.parse(value)
|
139
|
+
when :String
|
140
|
+
value.to_s
|
141
|
+
when :Integer
|
142
|
+
value.to_i
|
143
|
+
when :Float
|
144
|
+
value.to_f
|
145
|
+
when :Boolean
|
146
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
147
|
+
true
|
148
|
+
else
|
149
|
+
false
|
150
|
+
end
|
151
|
+
when :Object
|
152
|
+
# generic object (usually a Hash), return directly
|
153
|
+
value
|
154
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
155
|
+
inner_type = Regexp.last_match[:inner_type]
|
156
|
+
value.map { |v| _deserialize(inner_type, v) }
|
157
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
158
|
+
k_type = Regexp.last_match[:k_type]
|
159
|
+
v_type = Regexp.last_match[:v_type]
|
160
|
+
{}.tap do |hash|
|
161
|
+
value.each do |k, v|
|
162
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
else # model
|
166
|
+
# models (e.g. Pet) or oneOf
|
167
|
+
klass = Carbon.const_get(type)
|
168
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
# Returns the string representation of the object
|
173
|
+
# @return [String] String presentation of the object
|
174
|
+
def to_s
|
175
|
+
to_hash.to_s
|
176
|
+
end
|
177
|
+
|
178
|
+
# to_body is an alias to to_hash (backward compatibility)
|
179
|
+
# @return [Hash] Returns the object in the form of hash
|
180
|
+
def to_body
|
181
|
+
to_hash
|
182
|
+
end
|
183
|
+
|
184
|
+
# Returns the object in the form of hash
|
185
|
+
# @return [Hash] Returns the object in the form of hash
|
186
|
+
def to_hash
|
187
|
+
hash = {}
|
188
|
+
self.class.attribute_map.each_pair do |attr, param|
|
189
|
+
value = self.send(attr)
|
190
|
+
if value.nil?
|
191
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
192
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
193
|
+
end
|
194
|
+
|
195
|
+
hash[param] = _to_hash(value)
|
196
|
+
end
|
197
|
+
hash
|
198
|
+
end
|
199
|
+
|
200
|
+
# Outputs non-array value in the form of hash
|
201
|
+
# For object, use to_hash. Otherwise, just return the value
|
202
|
+
# @param [Object] value Any valid value
|
203
|
+
# @return [Hash] Returns the value in the form of hash
|
204
|
+
def _to_hash(value)
|
205
|
+
if value.is_a?(Array)
|
206
|
+
value.compact.map { |v| _to_hash(v) }
|
207
|
+
elsif value.is_a?(Hash)
|
208
|
+
{}.tap do |hash|
|
209
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
210
|
+
end
|
211
|
+
elsif value.respond_to? :to_hash
|
212
|
+
value.to_hash
|
213
|
+
else
|
214
|
+
value
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|
@@ -0,0 +1,248 @@
|
|
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 ChunkProperties
|
14
|
+
attr_accessor :set_page_as_boundary
|
15
|
+
|
16
|
+
attr_accessor :prepend_filename_to_chunks
|
17
|
+
|
18
|
+
attr_accessor :max_items_per_chunk
|
19
|
+
|
20
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
21
|
+
def self.attribute_map
|
22
|
+
{
|
23
|
+
:'set_page_as_boundary' => :'set_page_as_boundary',
|
24
|
+
:'prepend_filename_to_chunks' => :'prepend_filename_to_chunks',
|
25
|
+
:'max_items_per_chunk' => :'max_items_per_chunk'
|
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
|
+
:'set_page_as_boundary' => :'Boolean',
|
38
|
+
:'prepend_filename_to_chunks' => :'Boolean',
|
39
|
+
:'max_items_per_chunk' => :'Integer'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# List of attributes with nullable: true
|
44
|
+
def self.openapi_nullable
|
45
|
+
Set.new([
|
46
|
+
:'max_items_per_chunk'
|
47
|
+
])
|
48
|
+
end
|
49
|
+
|
50
|
+
# Initializes the object
|
51
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
52
|
+
def initialize(attributes = {})
|
53
|
+
if (!attributes.is_a?(Hash))
|
54
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Carbon::ChunkProperties` initialize method"
|
55
|
+
end
|
56
|
+
|
57
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
58
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
59
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
60
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Carbon::ChunkProperties`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
61
|
+
end
|
62
|
+
h[k.to_sym] = v
|
63
|
+
}
|
64
|
+
|
65
|
+
if attributes.key?(:'set_page_as_boundary')
|
66
|
+
self.set_page_as_boundary = attributes[:'set_page_as_boundary']
|
67
|
+
else
|
68
|
+
self.set_page_as_boundary = false
|
69
|
+
end
|
70
|
+
|
71
|
+
if attributes.key?(:'prepend_filename_to_chunks')
|
72
|
+
self.prepend_filename_to_chunks = attributes[:'prepend_filename_to_chunks']
|
73
|
+
else
|
74
|
+
self.prepend_filename_to_chunks = false
|
75
|
+
end
|
76
|
+
|
77
|
+
if attributes.key?(:'max_items_per_chunk')
|
78
|
+
self.max_items_per_chunk = attributes[:'max_items_per_chunk']
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
83
|
+
# @return Array for valid properties with the reasons
|
84
|
+
def list_invalid_properties
|
85
|
+
invalid_properties = Array.new
|
86
|
+
if @set_page_as_boundary.nil?
|
87
|
+
invalid_properties.push('invalid value for "set_page_as_boundary", set_page_as_boundary cannot be nil.')
|
88
|
+
end
|
89
|
+
|
90
|
+
if @prepend_filename_to_chunks.nil?
|
91
|
+
invalid_properties.push('invalid value for "prepend_filename_to_chunks", prepend_filename_to_chunks cannot be nil.')
|
92
|
+
end
|
93
|
+
|
94
|
+
invalid_properties
|
95
|
+
end
|
96
|
+
|
97
|
+
# Check to see if the all the properties in the model are valid
|
98
|
+
# @return true if the model is valid
|
99
|
+
def valid?
|
100
|
+
return false if @set_page_as_boundary.nil?
|
101
|
+
return false if @prepend_filename_to_chunks.nil?
|
102
|
+
true
|
103
|
+
end
|
104
|
+
|
105
|
+
# Checks equality by comparing each attribute.
|
106
|
+
# @param [Object] Object to be compared
|
107
|
+
def ==(o)
|
108
|
+
return true if self.equal?(o)
|
109
|
+
self.class == o.class &&
|
110
|
+
set_page_as_boundary == o.set_page_as_boundary &&
|
111
|
+
prepend_filename_to_chunks == o.prepend_filename_to_chunks &&
|
112
|
+
max_items_per_chunk == o.max_items_per_chunk
|
113
|
+
end
|
114
|
+
|
115
|
+
# @see the `==` method
|
116
|
+
# @param [Object] Object to be compared
|
117
|
+
def eql?(o)
|
118
|
+
self == o
|
119
|
+
end
|
120
|
+
|
121
|
+
# Calculates hash code according to all attributes.
|
122
|
+
# @return [Integer] Hash code
|
123
|
+
def hash
|
124
|
+
[set_page_as_boundary, prepend_filename_to_chunks, max_items_per_chunk].hash
|
125
|
+
end
|
126
|
+
|
127
|
+
# Builds the object from hash
|
128
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
129
|
+
# @return [Object] Returns the model itself
|
130
|
+
def self.build_from_hash(attributes)
|
131
|
+
new.build_from_hash(attributes)
|
132
|
+
end
|
133
|
+
|
134
|
+
# Builds the object from hash
|
135
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
136
|
+
# @return [Object] Returns the model itself
|
137
|
+
def build_from_hash(attributes)
|
138
|
+
return nil unless attributes.is_a?(Hash)
|
139
|
+
attributes = attributes.transform_keys(&:to_sym)
|
140
|
+
self.class.openapi_types.each_pair do |key, type|
|
141
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
142
|
+
self.send("#{key}=", nil)
|
143
|
+
elsif type =~ /\AArray<(.*)>/i
|
144
|
+
# check to ensure the input is an array given that the attribute
|
145
|
+
# is documented as an array but the input is not
|
146
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
147
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
148
|
+
end
|
149
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
150
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
self
|
155
|
+
end
|
156
|
+
|
157
|
+
# Deserializes the data based on type
|
158
|
+
# @param string type Data type
|
159
|
+
# @param string value Value to be deserialized
|
160
|
+
# @return [Object] Deserialized data
|
161
|
+
def _deserialize(type, value)
|
162
|
+
case type.to_sym
|
163
|
+
when :Time
|
164
|
+
Time.parse(value)
|
165
|
+
when :Date
|
166
|
+
Date.parse(value)
|
167
|
+
when :String
|
168
|
+
value.to_s
|
169
|
+
when :Integer
|
170
|
+
value.to_i
|
171
|
+
when :Float
|
172
|
+
value.to_f
|
173
|
+
when :Boolean
|
174
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
175
|
+
true
|
176
|
+
else
|
177
|
+
false
|
178
|
+
end
|
179
|
+
when :Object
|
180
|
+
# generic object (usually a Hash), return directly
|
181
|
+
value
|
182
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
183
|
+
inner_type = Regexp.last_match[:inner_type]
|
184
|
+
value.map { |v| _deserialize(inner_type, v) }
|
185
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
186
|
+
k_type = Regexp.last_match[:k_type]
|
187
|
+
v_type = Regexp.last_match[:v_type]
|
188
|
+
{}.tap do |hash|
|
189
|
+
value.each do |k, v|
|
190
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
else # model
|
194
|
+
# models (e.g. Pet) or oneOf
|
195
|
+
klass = Carbon.const_get(type)
|
196
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
# Returns the string representation of the object
|
201
|
+
# @return [String] String presentation of the object
|
202
|
+
def to_s
|
203
|
+
to_hash.to_s
|
204
|
+
end
|
205
|
+
|
206
|
+
# to_body is an alias to to_hash (backward compatibility)
|
207
|
+
# @return [Hash] Returns the object in the form of hash
|
208
|
+
def to_body
|
209
|
+
to_hash
|
210
|
+
end
|
211
|
+
|
212
|
+
# Returns the object in the form of hash
|
213
|
+
# @return [Hash] Returns the object in the form of hash
|
214
|
+
def to_hash
|
215
|
+
hash = {}
|
216
|
+
self.class.attribute_map.each_pair do |attr, param|
|
217
|
+
value = self.send(attr)
|
218
|
+
if value.nil?
|
219
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
220
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
221
|
+
end
|
222
|
+
|
223
|
+
hash[param] = _to_hash(value)
|
224
|
+
end
|
225
|
+
hash
|
226
|
+
end
|
227
|
+
|
228
|
+
# Outputs non-array value in the form of hash
|
229
|
+
# For object, use to_hash. Otherwise, just return the value
|
230
|
+
# @param [Object] value Any valid value
|
231
|
+
# @return [Hash] Returns the value in the form of hash
|
232
|
+
def _to_hash(value)
|
233
|
+
if value.is_a?(Array)
|
234
|
+
value.compact.map { |v| _to_hash(v) }
|
235
|
+
elsif value.is_a?(Hash)
|
236
|
+
{}.tap do |hash|
|
237
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
238
|
+
end
|
239
|
+
elsif value.respond_to? :to_hash
|
240
|
+
value.to_hash
|
241
|
+
else
|
242
|
+
value
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
end
|
247
|
+
|
248
|
+
end
|
@@ -0,0 +1,248 @@
|
|
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 ChunkPropertiesNullable
|
14
|
+
attr_accessor :set_page_as_boundary
|
15
|
+
|
16
|
+
attr_accessor :prepend_filename_to_chunks
|
17
|
+
|
18
|
+
attr_accessor :max_items_per_chunk
|
19
|
+
|
20
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
21
|
+
def self.attribute_map
|
22
|
+
{
|
23
|
+
:'set_page_as_boundary' => :'set_page_as_boundary',
|
24
|
+
:'prepend_filename_to_chunks' => :'prepend_filename_to_chunks',
|
25
|
+
:'max_items_per_chunk' => :'max_items_per_chunk'
|
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
|
+
:'set_page_as_boundary' => :'Boolean',
|
38
|
+
:'prepend_filename_to_chunks' => :'Boolean',
|
39
|
+
:'max_items_per_chunk' => :'Integer'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# List of attributes with nullable: true
|
44
|
+
def self.openapi_nullable
|
45
|
+
Set.new([
|
46
|
+
:'max_items_per_chunk'
|
47
|
+
])
|
48
|
+
end
|
49
|
+
|
50
|
+
# Initializes the object
|
51
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
52
|
+
def initialize(attributes = {})
|
53
|
+
if (!attributes.is_a?(Hash))
|
54
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Carbon::ChunkPropertiesNullable` initialize method"
|
55
|
+
end
|
56
|
+
|
57
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
58
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
59
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
60
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Carbon::ChunkPropertiesNullable`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
61
|
+
end
|
62
|
+
h[k.to_sym] = v
|
63
|
+
}
|
64
|
+
|
65
|
+
if attributes.key?(:'set_page_as_boundary')
|
66
|
+
self.set_page_as_boundary = attributes[:'set_page_as_boundary']
|
67
|
+
else
|
68
|
+
self.set_page_as_boundary = false
|
69
|
+
end
|
70
|
+
|
71
|
+
if attributes.key?(:'prepend_filename_to_chunks')
|
72
|
+
self.prepend_filename_to_chunks = attributes[:'prepend_filename_to_chunks']
|
73
|
+
else
|
74
|
+
self.prepend_filename_to_chunks = false
|
75
|
+
end
|
76
|
+
|
77
|
+
if attributes.key?(:'max_items_per_chunk')
|
78
|
+
self.max_items_per_chunk = attributes[:'max_items_per_chunk']
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
83
|
+
# @return Array for valid properties with the reasons
|
84
|
+
def list_invalid_properties
|
85
|
+
invalid_properties = Array.new
|
86
|
+
if @set_page_as_boundary.nil?
|
87
|
+
invalid_properties.push('invalid value for "set_page_as_boundary", set_page_as_boundary cannot be nil.')
|
88
|
+
end
|
89
|
+
|
90
|
+
if @prepend_filename_to_chunks.nil?
|
91
|
+
invalid_properties.push('invalid value for "prepend_filename_to_chunks", prepend_filename_to_chunks cannot be nil.')
|
92
|
+
end
|
93
|
+
|
94
|
+
invalid_properties
|
95
|
+
end
|
96
|
+
|
97
|
+
# Check to see if the all the properties in the model are valid
|
98
|
+
# @return true if the model is valid
|
99
|
+
def valid?
|
100
|
+
return false if @set_page_as_boundary.nil?
|
101
|
+
return false if @prepend_filename_to_chunks.nil?
|
102
|
+
true
|
103
|
+
end
|
104
|
+
|
105
|
+
# Checks equality by comparing each attribute.
|
106
|
+
# @param [Object] Object to be compared
|
107
|
+
def ==(o)
|
108
|
+
return true if self.equal?(o)
|
109
|
+
self.class == o.class &&
|
110
|
+
set_page_as_boundary == o.set_page_as_boundary &&
|
111
|
+
prepend_filename_to_chunks == o.prepend_filename_to_chunks &&
|
112
|
+
max_items_per_chunk == o.max_items_per_chunk
|
113
|
+
end
|
114
|
+
|
115
|
+
# @see the `==` method
|
116
|
+
# @param [Object] Object to be compared
|
117
|
+
def eql?(o)
|
118
|
+
self == o
|
119
|
+
end
|
120
|
+
|
121
|
+
# Calculates hash code according to all attributes.
|
122
|
+
# @return [Integer] Hash code
|
123
|
+
def hash
|
124
|
+
[set_page_as_boundary, prepend_filename_to_chunks, max_items_per_chunk].hash
|
125
|
+
end
|
126
|
+
|
127
|
+
# Builds the object from hash
|
128
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
129
|
+
# @return [Object] Returns the model itself
|
130
|
+
def self.build_from_hash(attributes)
|
131
|
+
new.build_from_hash(attributes)
|
132
|
+
end
|
133
|
+
|
134
|
+
# Builds the object from hash
|
135
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
136
|
+
# @return [Object] Returns the model itself
|
137
|
+
def build_from_hash(attributes)
|
138
|
+
return nil unless attributes.is_a?(Hash)
|
139
|
+
attributes = attributes.transform_keys(&:to_sym)
|
140
|
+
self.class.openapi_types.each_pair do |key, type|
|
141
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
142
|
+
self.send("#{key}=", nil)
|
143
|
+
elsif type =~ /\AArray<(.*)>/i
|
144
|
+
# check to ensure the input is an array given that the attribute
|
145
|
+
# is documented as an array but the input is not
|
146
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
147
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
148
|
+
end
|
149
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
150
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
self
|
155
|
+
end
|
156
|
+
|
157
|
+
# Deserializes the data based on type
|
158
|
+
# @param string type Data type
|
159
|
+
# @param string value Value to be deserialized
|
160
|
+
# @return [Object] Deserialized data
|
161
|
+
def _deserialize(type, value)
|
162
|
+
case type.to_sym
|
163
|
+
when :Time
|
164
|
+
Time.parse(value)
|
165
|
+
when :Date
|
166
|
+
Date.parse(value)
|
167
|
+
when :String
|
168
|
+
value.to_s
|
169
|
+
when :Integer
|
170
|
+
value.to_i
|
171
|
+
when :Float
|
172
|
+
value.to_f
|
173
|
+
when :Boolean
|
174
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
175
|
+
true
|
176
|
+
else
|
177
|
+
false
|
178
|
+
end
|
179
|
+
when :Object
|
180
|
+
# generic object (usually a Hash), return directly
|
181
|
+
value
|
182
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
183
|
+
inner_type = Regexp.last_match[:inner_type]
|
184
|
+
value.map { |v| _deserialize(inner_type, v) }
|
185
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
186
|
+
k_type = Regexp.last_match[:k_type]
|
187
|
+
v_type = Regexp.last_match[:v_type]
|
188
|
+
{}.tap do |hash|
|
189
|
+
value.each do |k, v|
|
190
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
else # model
|
194
|
+
# models (e.g. Pet) or oneOf
|
195
|
+
klass = Carbon.const_get(type)
|
196
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
# Returns the string representation of the object
|
201
|
+
# @return [String] String presentation of the object
|
202
|
+
def to_s
|
203
|
+
to_hash.to_s
|
204
|
+
end
|
205
|
+
|
206
|
+
# to_body is an alias to to_hash (backward compatibility)
|
207
|
+
# @return [Hash] Returns the object in the form of hash
|
208
|
+
def to_body
|
209
|
+
to_hash
|
210
|
+
end
|
211
|
+
|
212
|
+
# Returns the object in the form of hash
|
213
|
+
# @return [Hash] Returns the object in the form of hash
|
214
|
+
def to_hash
|
215
|
+
hash = {}
|
216
|
+
self.class.attribute_map.each_pair do |attr, param|
|
217
|
+
value = self.send(attr)
|
218
|
+
if value.nil?
|
219
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
220
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
221
|
+
end
|
222
|
+
|
223
|
+
hash[param] = _to_hash(value)
|
224
|
+
end
|
225
|
+
hash
|
226
|
+
end
|
227
|
+
|
228
|
+
# Outputs non-array value in the form of hash
|
229
|
+
# For object, use to_hash. Otherwise, just return the value
|
230
|
+
# @param [Object] value Any valid value
|
231
|
+
# @return [Hash] Returns the value in the form of hash
|
232
|
+
def _to_hash(value)
|
233
|
+
if value.is_a?(Array)
|
234
|
+
value.compact.map { |v| _to_hash(v) }
|
235
|
+
elsif value.is_a?(Hash)
|
236
|
+
{}.tap do |hash|
|
237
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
238
|
+
end
|
239
|
+
elsif value.respond_to? :to_hash
|
240
|
+
value.to_hash
|
241
|
+
else
|
242
|
+
value
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
end
|
247
|
+
|
248
|
+
end
|