carbon_ruby_sdk 0.1.6 → 0.1.7

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 (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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf47c03b0e27651aa516a1b57c87c83324e769fb98dd2d983d0bd89c9c7e87d3
4
- data.tar.gz: f36807e5b7c143e385e0420641ebf791bef641314eae726214446bcfd6c97a7f
3
+ metadata.gz: fd7974b2da45db33f2f9b12525479855314a2a4c894ba085df0e7743052b0e85
4
+ data.tar.gz: 12583c34578f4a0dfe0ea096f471a3d7329305afca38d255bc0f5f1c97f8a6b6
5
5
  SHA512:
6
- metadata.gz: b3a842c472397b3708a9a5517763cdcb3f6cea3dbcbc5af4c5d7f4648f07dae1e2dcd637ba5cdc3b6d1aa2a100483cdcc091cc27f8e4ffbc5e0fd8b066e92fa8
7
- data.tar.gz: fc30a060950f4e7b0e8a30463f5c8529de9edf8e4257ea5e4933b451747e79e1cd375e6b29c34047dd716807a3c804f053863e7a5427d067dfdd09c2ad51b35f
6
+ metadata.gz: 9be2791c4adac413d756ef78aa17e7ad0851293ad7b5ef6ed6ad530e80e6d5e14e97759028870bc04c16e7f5d15bca0a548b4b9710f1c807740b03aa8aae474d
7
+ data.tar.gz: 1e139cb78829fe2757e2b629a08146d7b899e7b542f93ca57b4224200cead60ec641a1152b5339eed9e7353015123545d937f4930b8e5b6444dff186d6906739
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- carbon_ruby_sdk (0.1.6)
4
+ carbon_ruby_sdk (0.1.7)
5
5
  faraday (>= 1.0.1, < 3.0)
6
6
  faraday-multipart (~> 1.0, >= 1.0.4)
7
7
 
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  Connect external data to LLMs, no matter the source.
8
8
 
9
- [![npm](https://img.shields.io/badge/gem-v0.1.6-blue)](https://rubygems.org/gems/carbon_ruby_sdk/versions/0.1.6)
9
+ [![npm](https://img.shields.io/badge/gem-v0.1.7-blue)](https://rubygems.org/gems/carbon_ruby_sdk/versions/0.1.7)
10
10
 
11
11
  </div>
12
12
 
@@ -38,6 +38,7 @@ Connect external data to LLMs, no matter the source.
38
38
  * [`carbon.files.upload_from_url`](#carbonfilesupload_from_url)
39
39
  * [`carbon.files.upload_text`](#carbonfilesupload_text)
40
40
  * [`carbon.health.check`](#carbonhealthcheck)
41
+ * [`carbon.integrations.connect_data_source`](#carbonintegrationsconnect_data_source)
41
42
  * [`carbon.integrations.connect_freshdesk`](#carbonintegrationsconnect_freshdesk)
42
43
  * [`carbon.integrations.connect_gitbook`](#carbonintegrationsconnect_gitbook)
43
44
  * [`carbon.integrations.create_aws_iam_user`](#carbonintegrationscreate_aws_iam_user)
@@ -77,7 +78,7 @@ Connect external data to LLMs, no matter the source.
77
78
  Add to Gemfile:
78
79
 
79
80
  ```ruby
80
- gem 'carbon_ruby_sdk', '~> 0.1.6'
81
+ gem 'carbon_ruby_sdk', '~> 0.1.7'
81
82
  ```
82
83
 
83
84
  ## Getting Started<a id="getting-started"></a>
@@ -1116,6 +1117,49 @@ p result
1116
1117
  ---
1117
1118
 
1118
1119
 
1120
+ ### `carbon.integrations.connect_data_source`<a id="carbonintegrationsconnect_data_source"></a>
1121
+
1122
+ Connect Data Source
1123
+
1124
+ #### 🛠️ Usage<a id="🛠️-usage"></a>
1125
+
1126
+ ```ruby
1127
+ result = carbon.integrations.connect_data_source(
1128
+ authentication: {
1129
+ "source" => "GOOGLE_DRIVE",
1130
+ "access_token" => "access_token_example",
1131
+ },
1132
+ sync_options: {
1133
+ "chunk_size" => 1500,
1134
+ "chunk_overlap" => 20,
1135
+ "skip_embedding_generation" => false,
1136
+ "embedding_model" => "OPENAI",
1137
+ "generate_sparse_vectors" => false,
1138
+ "prepend_filename_to_chunks" => false,
1139
+ "sync_files_on_connection" => true,
1140
+ "set_page_as_boundary" => false,
1141
+ },
1142
+ )
1143
+ p result
1144
+ ```
1145
+
1146
+ #### ⚙️ Parameters<a id="⚙️-parameters"></a>
1147
+
1148
+ ##### authentication: [`AuthenticationProperty`](./lib/carbon_ruby_sdk/models/authentication_property.rb)<a id="authentication-authenticationpropertylibcarbon_ruby_sdkmodelsauthentication_propertyrb"></a>
1149
+ ##### sync_options: [`SyncOptions`](./lib/carbon_ruby_sdk/models/sync_options.rb)<a id="sync_options-syncoptionslibcarbon_ruby_sdkmodelssync_optionsrb"></a>
1150
+ #### 🔄 Return<a id="🔄-return"></a>
1151
+
1152
+ [ConnectDataSourceResponse](./lib/carbon_ruby_sdk/models/connect_data_source_response.rb)
1153
+
1154
+ #### 🌐 Endpoint<a id="🌐-endpoint"></a>
1155
+
1156
+ `/integrations/connect` `POST`
1157
+
1158
+ [🔙 **Back to Table of Contents**](#table-of-contents)
1159
+
1160
+ ---
1161
+
1162
+
1119
1163
  ### `carbon.integrations.connect_freshdesk`<a id="carbonintegrationsconnect_freshdesk"></a>
1120
1164
 
1121
1165
  Refer this article to obtain an API key https://support.freshdesk.com/en/support/solutions/articles/215517.
@@ -16,6 +16,102 @@ module Carbon
16
16
  @api_client = api_client
17
17
  end
18
18
 
19
+ # Connect Data Source
20
+ #
21
+ # @param authentication [AuthenticationProperty]
22
+ # @param sync_options [SyncOptions]
23
+ # @param body [ConnectDataSourceInput]
24
+ # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
25
+ def connect_data_source(authentication:, sync_options: SENTINEL, extra: {})
26
+ _body = {}
27
+ _body[:authentication] = authentication if authentication != SENTINEL
28
+ _body[:sync_options] = sync_options if sync_options != SENTINEL
29
+ connect_data_source_input = _body
30
+ api_response = connect_data_source_with_http_info_impl(connect_data_source_input, extra)
31
+ api_response.data
32
+ end
33
+
34
+ # Connect Data Source
35
+ #
36
+ # @param authentication [AuthenticationProperty]
37
+ # @param sync_options [SyncOptions]
38
+ # @param body [ConnectDataSourceInput]
39
+ # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
40
+ def connect_data_source_with_http_info(authentication:, sync_options: SENTINEL, extra: {})
41
+ _body = {}
42
+ _body[:authentication] = authentication if authentication != SENTINEL
43
+ _body[:sync_options] = sync_options if sync_options != SENTINEL
44
+ connect_data_source_input = _body
45
+ connect_data_source_with_http_info_impl(connect_data_source_input, extra)
46
+ end
47
+
48
+ # Connect Data Source
49
+ # @param connect_data_source_input [ConnectDataSourceInput]
50
+ # @param [Hash] opts the optional parameters
51
+ # @return [ConnectDataSourceResponse]
52
+ private def connect_data_source_impl(connect_data_source_input, opts = {})
53
+ data, _status_code, _headers = connect_data_source_with_http_info(connect_data_source_input, opts)
54
+ data
55
+ end
56
+
57
+ # Connect Data Source
58
+ # @param connect_data_source_input [ConnectDataSourceInput]
59
+ # @param [Hash] opts the optional parameters
60
+ # @return [APIResponse] data is ConnectDataSourceResponse, status code, headers and response
61
+ private def connect_data_source_with_http_info_impl(connect_data_source_input, opts = {})
62
+ if @api_client.config.debugging
63
+ @api_client.config.logger.debug 'Calling API: IntegrationsApi.connect_data_source ...'
64
+ end
65
+ # verify the required parameter 'connect_data_source_input' is set
66
+ if @api_client.config.client_side_validation && connect_data_source_input.nil?
67
+ fail ArgumentError, "Missing the required parameter 'connect_data_source_input' when calling IntegrationsApi.connect_data_source"
68
+ end
69
+ # resource path
70
+ local_var_path = '/integrations/connect'
71
+
72
+ # query parameters
73
+ query_params = opts[:query_params] || {}
74
+
75
+ # header parameters
76
+ header_params = opts[:header_params] || {}
77
+ # HTTP header 'Accept' (if needed)
78
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
79
+ # HTTP header 'Content-Type'
80
+ content_type = @api_client.select_header_content_type(['application/json'])
81
+ if !content_type.nil?
82
+ header_params['Content-Type'] = content_type
83
+ end
84
+
85
+ # form parameters
86
+ form_params = opts[:form_params] || {}
87
+
88
+ # http body (model)
89
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(connect_data_source_input)
90
+
91
+ # return_type
92
+ return_type = opts[:debug_return_type] || 'ConnectDataSourceResponse'
93
+
94
+ # auth_names
95
+ auth_names = opts[:debug_auth_names] || ['accessToken', 'apiKey', 'customerId']
96
+
97
+ new_options = opts.merge(
98
+ :operation => :"IntegrationsApi.connect_data_source",
99
+ :header_params => header_params,
100
+ :query_params => query_params,
101
+ :form_params => form_params,
102
+ :body => post_body,
103
+ :auth_names => auth_names,
104
+ :return_type => return_type
105
+ )
106
+
107
+ data, status_code, headers, response = @api_client.call_api(:POST, local_var_path, new_options)
108
+ if @api_client.config.debugging
109
+ @api_client.config.logger.debug "API called: IntegrationsApi#connect_data_source\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
110
+ end
111
+ APIResponse::new(data, status_code, headers, response)
112
+ end
113
+
114
+
19
115
  # Freshdesk Connect
20
116
  #
21
117
  # Refer this article to obtain an API key https://support.freshdesk.com/en/support/solutions/articles/215517.
@@ -0,0 +1,436 @@
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 AuthenticationProperty
14
+ attr_accessor :source
15
+
16
+ attr_accessor :access_token
17
+
18
+ attr_accessor :refresh_token
19
+
20
+ attr_accessor :workspace_id
21
+
22
+ attr_accessor :tenant_name
23
+
24
+ attr_accessor :site_name
25
+
26
+ attr_accessor :subdomain
27
+
28
+ attr_accessor :access_token_secret
29
+
30
+ attr_accessor :username
31
+
32
+ attr_accessor :zotero_id
33
+
34
+ attr_accessor :organization_name
35
+
36
+ attr_accessor :domain
37
+
38
+ attr_accessor :api_key
39
+
40
+ attr_accessor :access_key
41
+
42
+ attr_accessor :access_key_secret
43
+
44
+ # Attribute mapping from ruby-style variable name to JSON key.
45
+ def self.attribute_map
46
+ {
47
+ :'source' => :'source',
48
+ :'access_token' => :'access_token',
49
+ :'refresh_token' => :'refresh_token',
50
+ :'workspace_id' => :'workspace_id',
51
+ :'tenant_name' => :'tenant_name',
52
+ :'site_name' => :'site_name',
53
+ :'subdomain' => :'subdomain',
54
+ :'access_token_secret' => :'access_token_secret',
55
+ :'username' => :'username',
56
+ :'zotero_id' => :'zotero_id',
57
+ :'organization_name' => :'organization_name',
58
+ :'domain' => :'domain',
59
+ :'api_key' => :'api_key',
60
+ :'access_key' => :'access_key',
61
+ :'access_key_secret' => :'access_key_secret'
62
+ }
63
+ end
64
+
65
+ # Returns all the JSON keys this model knows about
66
+ def self.acceptable_attributes
67
+ attribute_map.values
68
+ end
69
+
70
+ # Attribute type mapping.
71
+ def self.openapi_types
72
+ {
73
+ :'source' => :'Object',
74
+ :'access_token' => :'String',
75
+ :'refresh_token' => :'String',
76
+ :'workspace_id' => :'String',
77
+ :'tenant_name' => :'String',
78
+ :'site_name' => :'String',
79
+ :'subdomain' => :'String',
80
+ :'access_token_secret' => :'String',
81
+ :'username' => :'String',
82
+ :'zotero_id' => :'String',
83
+ :'organization_name' => :'String',
84
+ :'domain' => :'String',
85
+ :'api_key' => :'String',
86
+ :'access_key' => :'String',
87
+ :'access_key_secret' => :'String'
88
+ }
89
+ end
90
+
91
+ # List of attributes with nullable: true
92
+ def self.openapi_nullable
93
+ Set.new([
94
+ :'source',
95
+ :'refresh_token',
96
+ ])
97
+ end
98
+
99
+ # List of class defined in anyOf (OpenAPI v3)
100
+ def self.openapi_any_of
101
+ [
102
+ :'ConfluenceAuthentication',
103
+ :'FreskdeskAuthentication',
104
+ :'GitbookAuthetication',
105
+ :'NotionAuthentication',
106
+ :'OAuthAuthentication',
107
+ :'S3Authentication',
108
+ :'SalesforceAuthentication',
109
+ :'SharepointAuthentication',
110
+ :'ZendeskAuthentication',
111
+ :'ZoteroAuthentication'
112
+ ]
113
+ end
114
+
115
+ # Initializes the object
116
+ # @param [Hash] attributes Model attributes in the form of hash
117
+ def initialize(attributes = {})
118
+ if (!attributes.is_a?(Hash))
119
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Carbon::AuthenticationProperty` initialize method"
120
+ end
121
+
122
+ # check to see if the attribute exists and convert string to symbol for hash key
123
+ attributes = attributes.each_with_object({}) { |(k, v), h|
124
+ if (!self.class.attribute_map.key?(k.to_sym))
125
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Carbon::AuthenticationProperty`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
126
+ end
127
+ h[k.to_sym] = v
128
+ }
129
+
130
+ if attributes.key?(:'source')
131
+ self.source = attributes[:'source']
132
+ end
133
+
134
+ if attributes.key?(:'access_token')
135
+ self.access_token = attributes[:'access_token']
136
+ end
137
+
138
+ if attributes.key?(:'refresh_token')
139
+ self.refresh_token = attributes[:'refresh_token']
140
+ end
141
+
142
+ if attributes.key?(:'workspace_id')
143
+ self.workspace_id = attributes[:'workspace_id']
144
+ end
145
+
146
+ if attributes.key?(:'tenant_name')
147
+ self.tenant_name = attributes[:'tenant_name']
148
+ end
149
+
150
+ if attributes.key?(:'site_name')
151
+ self.site_name = attributes[:'site_name']
152
+ end
153
+
154
+ if attributes.key?(:'subdomain')
155
+ self.subdomain = attributes[:'subdomain']
156
+ end
157
+
158
+ if attributes.key?(:'access_token_secret')
159
+ self.access_token_secret = attributes[:'access_token_secret']
160
+ end
161
+
162
+ if attributes.key?(:'username')
163
+ self.username = attributes[:'username']
164
+ end
165
+
166
+ if attributes.key?(:'zotero_id')
167
+ self.zotero_id = attributes[:'zotero_id']
168
+ end
169
+
170
+ if attributes.key?(:'organization_name')
171
+ self.organization_name = attributes[:'organization_name']
172
+ end
173
+
174
+ if attributes.key?(:'domain')
175
+ self.domain = attributes[:'domain']
176
+ end
177
+
178
+ if attributes.key?(:'api_key')
179
+ self.api_key = attributes[:'api_key']
180
+ end
181
+
182
+ if attributes.key?(:'access_key')
183
+ self.access_key = attributes[:'access_key']
184
+ end
185
+
186
+ if attributes.key?(:'access_key_secret')
187
+ self.access_key_secret = attributes[:'access_key_secret']
188
+ end
189
+ end
190
+
191
+ # Show invalid properties with the reasons. Usually used together with valid?
192
+ # @return Array for valid properties with the reasons
193
+ def list_invalid_properties
194
+ invalid_properties = Array.new
195
+ if @access_token.nil?
196
+ invalid_properties.push('invalid value for "access_token", access_token cannot be nil.')
197
+ end
198
+
199
+ if @workspace_id.nil?
200
+ invalid_properties.push('invalid value for "workspace_id", workspace_id cannot be nil.')
201
+ end
202
+
203
+ if @tenant_name.nil?
204
+ invalid_properties.push('invalid value for "tenant_name", tenant_name cannot be nil.')
205
+ end
206
+
207
+ if @site_name.nil?
208
+ invalid_properties.push('invalid value for "site_name", site_name cannot be nil.')
209
+ end
210
+
211
+ if @subdomain.nil?
212
+ invalid_properties.push('invalid value for "subdomain", subdomain cannot be nil.')
213
+ end
214
+
215
+ if @access_token_secret.nil?
216
+ invalid_properties.push('invalid value for "access_token_secret", access_token_secret cannot be nil.')
217
+ end
218
+
219
+ if @username.nil?
220
+ invalid_properties.push('invalid value for "username", username cannot be nil.')
221
+ end
222
+
223
+ if @zotero_id.nil?
224
+ invalid_properties.push('invalid value for "zotero_id", zotero_id cannot be nil.')
225
+ end
226
+
227
+ if @organization_name.nil?
228
+ invalid_properties.push('invalid value for "organization_name", organization_name cannot be nil.')
229
+ end
230
+
231
+ if @domain.nil?
232
+ invalid_properties.push('invalid value for "domain", domain cannot be nil.')
233
+ end
234
+
235
+ if @api_key.nil?
236
+ invalid_properties.push('invalid value for "api_key", api_key cannot be nil.')
237
+ end
238
+
239
+ if @access_key.nil?
240
+ invalid_properties.push('invalid value for "access_key", access_key cannot be nil.')
241
+ end
242
+
243
+ if @access_key_secret.nil?
244
+ invalid_properties.push('invalid value for "access_key_secret", access_key_secret cannot be nil.')
245
+ end
246
+
247
+ invalid_properties
248
+ end
249
+
250
+ # Check to see if the all the properties in the model are valid
251
+ # @return true if the model is valid
252
+ def valid?
253
+ return false if @access_token.nil?
254
+ return false if @workspace_id.nil?
255
+ return false if @tenant_name.nil?
256
+ return false if @site_name.nil?
257
+ return false if @subdomain.nil?
258
+ return false if @access_token_secret.nil?
259
+ return false if @username.nil?
260
+ return false if @zotero_id.nil?
261
+ return false if @organization_name.nil?
262
+ return false if @domain.nil?
263
+ return false if @api_key.nil?
264
+ return false if @access_key.nil?
265
+ return false if @access_key_secret.nil?
266
+ _any_of_found = false
267
+ self.class.openapi_any_of.each do |_class|
268
+ _any_of = Carbon.const_get(_class).build_from_hash(self.to_hash)
269
+ if _any_of.valid?
270
+ _any_of_found = true
271
+ end
272
+ end
273
+
274
+ if !_any_of_found
275
+ return false
276
+ end
277
+
278
+ true
279
+ end
280
+
281
+ # Checks equality by comparing each attribute.
282
+ # @param [Object] Object to be compared
283
+ def ==(o)
284
+ return true if self.equal?(o)
285
+ self.class == o.class &&
286
+ source == o.source &&
287
+ access_token == o.access_token &&
288
+ refresh_token == o.refresh_token &&
289
+ workspace_id == o.workspace_id &&
290
+ tenant_name == o.tenant_name &&
291
+ site_name == o.site_name &&
292
+ subdomain == o.subdomain &&
293
+ access_token_secret == o.access_token_secret &&
294
+ username == o.username &&
295
+ zotero_id == o.zotero_id &&
296
+ organization_name == o.organization_name &&
297
+ domain == o.domain &&
298
+ api_key == o.api_key &&
299
+ access_key == o.access_key &&
300
+ access_key_secret == o.access_key_secret
301
+ end
302
+
303
+ # @see the `==` method
304
+ # @param [Object] Object to be compared
305
+ def eql?(o)
306
+ self == o
307
+ end
308
+
309
+ # Calculates hash code according to all attributes.
310
+ # @return [Integer] Hash code
311
+ def hash
312
+ [source, access_token, refresh_token, workspace_id, tenant_name, site_name, subdomain, access_token_secret, username, zotero_id, organization_name, domain, api_key, access_key, access_key_secret].hash
313
+ end
314
+
315
+ # Builds the object from hash
316
+ # @param [Hash] attributes Model attributes in the form of hash
317
+ # @return [Object] Returns the model itself
318
+ def self.build_from_hash(attributes)
319
+ new.build_from_hash(attributes)
320
+ end
321
+
322
+ # Builds the object from hash
323
+ # @param [Hash] attributes Model attributes in the form of hash
324
+ # @return [Object] Returns the model itself
325
+ def build_from_hash(attributes)
326
+ return nil unless attributes.is_a?(Hash)
327
+ attributes = attributes.transform_keys(&:to_sym)
328
+ self.class.openapi_types.each_pair do |key, type|
329
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
330
+ self.send("#{key}=", nil)
331
+ elsif type =~ /\AArray<(.*)>/i
332
+ # check to ensure the input is an array given that the attribute
333
+ # is documented as an array but the input is not
334
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
335
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
336
+ end
337
+ elsif !attributes[self.class.attribute_map[key]].nil?
338
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
339
+ end
340
+ end
341
+
342
+ self
343
+ end
344
+
345
+ # Deserializes the data based on type
346
+ # @param string type Data type
347
+ # @param string value Value to be deserialized
348
+ # @return [Object] Deserialized data
349
+ def _deserialize(type, value)
350
+ case type.to_sym
351
+ when :Time
352
+ Time.parse(value)
353
+ when :Date
354
+ Date.parse(value)
355
+ when :String
356
+ value.to_s
357
+ when :Integer
358
+ value.to_i
359
+ when :Float
360
+ value.to_f
361
+ when :Boolean
362
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
363
+ true
364
+ else
365
+ false
366
+ end
367
+ when :Object
368
+ # generic object (usually a Hash), return directly
369
+ value
370
+ when /\AArray<(?<inner_type>.+)>\z/
371
+ inner_type = Regexp.last_match[:inner_type]
372
+ value.map { |v| _deserialize(inner_type, v) }
373
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
374
+ k_type = Regexp.last_match[:k_type]
375
+ v_type = Regexp.last_match[:v_type]
376
+ {}.tap do |hash|
377
+ value.each do |k, v|
378
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
379
+ end
380
+ end
381
+ else # model
382
+ # models (e.g. Pet) or oneOf
383
+ klass = Carbon.const_get(type)
384
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
385
+ end
386
+ end
387
+
388
+ # Returns the string representation of the object
389
+ # @return [String] String presentation of the object
390
+ def to_s
391
+ to_hash.to_s
392
+ end
393
+
394
+ # to_body is an alias to to_hash (backward compatibility)
395
+ # @return [Hash] Returns the object in the form of hash
396
+ def to_body
397
+ to_hash
398
+ end
399
+
400
+ # Returns the object in the form of hash
401
+ # @return [Hash] Returns the object in the form of hash
402
+ def to_hash
403
+ hash = {}
404
+ self.class.attribute_map.each_pair do |attr, param|
405
+ value = self.send(attr)
406
+ if value.nil?
407
+ is_nullable = self.class.openapi_nullable.include?(attr)
408
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
409
+ end
410
+
411
+ hash[param] = _to_hash(value)
412
+ end
413
+ hash
414
+ end
415
+
416
+ # Outputs non-array value in the form of hash
417
+ # For object, use to_hash. Otherwise, just return the value
418
+ # @param [Object] value Any valid value
419
+ # @return [Hash] Returns the value in the form of hash
420
+ def _to_hash(value)
421
+ if value.is_a?(Array)
422
+ value.compact.map { |v| _to_hash(v) }
423
+ elsif value.is_a?(Hash)
424
+ {}.tap do |hash|
425
+ value.each { |k, v| hash[k] = _to_hash(v) }
426
+ end
427
+ elsif value.respond_to? :to_hash
428
+ value.to_hash
429
+ else
430
+ value
431
+ end
432
+ end
433
+
434
+ end
435
+
436
+ end