composio 0.1.17 → 0.1.19

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a4cf91564d95e991ee3d5f5dcb293050aed0655ad449a4ca506880d4d28ed7d
4
- data.tar.gz: 39192d23e7436601684fe59da377100075c53668cd556d6a1babc504218d0552
3
+ metadata.gz: a6296e20891e806f731651123fda035d18bdd11e98af76e60d1b9e243734f1c6
4
+ data.tar.gz: 6868e1f21a2b3bb62439dbf31725fc6cc4e68ac7c819b5c870570afedc400920
5
5
  SHA512:
6
- metadata.gz: 23327875e8115ac18cde1d516ed7a52b823ff17228ed335ce230909d083468a67e5104f7426778e085ef5537eba52c954b51c927957e624867cfc39ea68abb6a
7
- data.tar.gz: c5c51033336dd1b73a488dcc917e32eba5b0881114ef52d9149d10f590a9f3da427d051c6243ab2f58de32029c9241d7eb4def49c2c4606c00fcdb4a35e4005e
6
+ metadata.gz: 1699d5222adf471f852ff8bd2f68a2cae4b28f5f6defa299aa4a0c52bc35e93380f9f0af46f0288bdbc5c248c8c47ef67d10e819124c989429fb83523ed56b44
7
+ data.tar.gz: 71e7013f485d3b83785efdd4a4b975af796061fd3ff90fbbcd081144da73719bebeb4565c75056013c936b4dd885df2912ecb249a4bf7fba7e1373d526c19614
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- composio (0.1.17)
4
+ composio (0.1.18)
5
5
  faraday (>= 1.0.1, < 3.0)
6
6
  faraday-multipart (~> 1.0, >= 1.0.4)
7
7
 
@@ -20,31 +20,31 @@ GEM
20
20
  base64
21
21
  faraday-net_http (>= 2.0, < 3.1)
22
22
  ruby2_keywords (>= 0.0.4)
23
- faraday-multipart (1.0.4)
24
- multipart-post (~> 2)
23
+ faraday-multipart (1.1.0)
24
+ multipart-post (~> 2.0)
25
25
  faraday-net_http (3.0.2)
26
- io-console (0.7.2)
27
- irb (1.6.4)
26
+ io-console (0.8.0)
27
+ irb (1.5.0)
28
28
  reline (>= 0.3.0)
29
29
  method_source (1.1.0)
30
30
  multipart-post (2.4.1)
31
- parallel (1.26.3)
31
+ parallel (1.24.0)
32
32
  parser (3.3.6.0)
33
33
  ast (~> 2.4.1)
34
34
  racc
35
- pry (0.14.2)
35
+ pry (0.13.1)
36
36
  coderay (~> 1.1)
37
37
  method_source (~> 1.0)
38
- pry-byebug (3.10.1)
38
+ pry-byebug (3.9.0)
39
39
  byebug (~> 11.0)
40
- pry (>= 0.13, < 0.15)
40
+ pry (~> 0.13.0)
41
41
  racc (1.8.1)
42
42
  rainbow (3.1.1)
43
43
  rake (13.0.6)
44
- regexp_parser (2.9.2)
45
- reline (0.5.11)
44
+ regexp_parser (2.10.0)
45
+ reline (0.6.0)
46
46
  io-console (~> 0.5)
47
- rexml (3.3.9)
47
+ rexml (3.4.0)
48
48
  rspec (3.13.0)
49
49
  rspec-core (~> 3.13.0)
50
50
  rspec-expectations (~> 3.13.0)
@@ -57,7 +57,7 @@ GEM
57
57
  rspec-mocks (3.13.2)
58
58
  diff-lcs (>= 1.2.0, < 2.0)
59
59
  rspec-support (~> 3.13.0)
60
- rspec-support (3.13.1)
60
+ rspec-support (3.13.2)
61
61
  rubocop (1.12.1)
62
62
  parallel (~> 1.10)
63
63
  parser (>= 3.0.0.0)
@@ -67,23 +67,23 @@ GEM
67
67
  rubocop-ast (>= 1.2.0, < 2.0)
68
68
  ruby-progressbar (~> 1.7)
69
69
  unicode-display_width (>= 1.4.0, < 3.0)
70
- rubocop-ast (1.35.0)
71
- parser (>= 3.3.1.0)
70
+ rubocop-ast (1.30.0)
71
+ parser (>= 3.2.1.0)
72
72
  ruby-progressbar (1.13.0)
73
73
  ruby2_keywords (0.0.5)
74
74
  unicode-display_width (2.6.0)
75
75
 
76
76
  PLATFORMS
77
- x86_64-linux
77
+ ruby
78
78
 
79
79
  DEPENDENCIES
80
80
  composio!
81
81
  debug (~> 1.8)
82
- irb (= 1.6.4)
82
+ irb (= 1.5.0)
83
83
  pry-byebug
84
84
  rake (~> 13.0.1)
85
85
  rspec (~> 3.6, >= 3.6.0)
86
86
  rubocop (~> 1.12.1)
87
87
 
88
88
  BUNDLED WITH
89
- 2.4.22
89
+ 1.17.2
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  Composio SDK: Equip your agent with high-quality tools and build your real-world usecase
8
8
 
9
- [![npm](https://img.shields.io/badge/gem-v0.1.17-blue)](https://rubygems.org/gems/composio/versions/0.1.17)
9
+ [![npm](https://img.shields.io/badge/gem-v0.1.18-blue)](https://rubygems.org/gems/composio/versions/0.1.18)
10
10
  [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://composio.dev)
11
11
 
12
12
  </div>
@@ -77,7 +77,7 @@ Composio SDK: Equip your agent with high-quality tools and build your real-world
77
77
  Add to Gemfile:
78
78
 
79
79
  ```ruby
80
- gem 'composio', '~> 0.1.17'
80
+ gem 'composio', '~> 0.1.18'
81
81
  ```
82
82
 
83
83
  ## Getting Started<a id="getting-started"></a>
@@ -214,7 +214,7 @@ result = composio.actions.execute(
214
214
  "parameters" => [
215
215
  {
216
216
  "name" => "name_example",
217
- "_in" => "_in_example",
217
+ "_in" => "query",
218
218
  "value" => "value_example",
219
219
  }
220
220
  ],
@@ -260,16 +260,38 @@ Execute an action with direct auth.
260
260
 
261
261
  ```ruby
262
262
  result = composio.actions.execute_action_proxy(
263
- endpoint: "endpoint_example",
264
- connected_account_id: "connectedAccountId_example",
263
+ parameters: [
264
+ {
265
+ "name" => "name_example",
266
+ "_in" => "query",
267
+ "value" => "value_example",
268
+ }
269
+ ],
270
+ connected_account_id: "string_example",
271
+ endpoint: "string_example",
272
+ method: "GET",
273
+ body: {},
265
274
  )
266
275
  p result
267
276
  ```
268
277
 
269
278
  #### ⚙️ Parameters<a id="⚙️-parameters"></a>
270
279
 
280
+ ##### parameters: Array<[`Parameter`](./lib/composio/models/parameter.rb)><a id="parameters-array"></a>
281
+ ##### connectedAccountId: `String`<a id="connectedaccountid-string"></a>
282
+ The connected account uuid to use for the action.
283
+
271
284
  ##### endpoint: `String`<a id="endpoint-string"></a>
272
- ##### connected_account_id: `String`<a id="connected_account_id-string"></a>
285
+ The endpoint to call for the action. If the given url is relative, it will be
286
+ resolved relative to the base_url set in the connected account info.
287
+
288
+ ##### method: [`Method`](./lib/composio/models/method.rb)<a id="method-methodlibcomposiomodelsmethodrb"></a>
289
+ The HTTP method to use for the action.
290
+
291
+ ##### body: `Object`<a id="body-object"></a>
292
+ The body to be sent to the endpoint. This can either be a JSON field or a
293
+ string.
294
+
273
295
  #### 🔄 Return<a id="🔄-return"></a>
274
296
 
275
297
  [ActionExecutionResDto](./lib/composio/models/action_execution_res_dto.rb)
@@ -163,11 +163,22 @@ module Composio
163
163
  #
164
164
  # Execute an action with direct auth.
165
165
  #
166
- # @param endpoint [String]
167
- # @param connected_account_id [String]
166
+ # @param parameters [Array<Parameter>]
167
+ # @param connected_account_id [String] The connected account uuid to use for the action.
168
+ # @param endpoint [String] The endpoint to call for the action. If the given url is relative, it will be resolved relative to the base_url set in the connected account info.
169
+ # @param method [Method] The HTTP method to use for the action.
170
+ # @param body [Object] The body to be sent to the endpoint. This can either be a JSON field or a string.
171
+ # @param body [ActionProxyRequestConfigDTO]
168
172
  # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
169
- def execute_action_proxy(endpoint:, connected_account_id:, extra: {})
170
- api_response = execute_action_proxy_with_http_info_impl(endpoint, connected_account_id, extra)
173
+ def execute_action_proxy(parameters:, connected_account_id:, endpoint:, method:, body: SENTINEL, extra: {})
174
+ _body = {}
175
+ _body[:parameters] = parameters if parameters != SENTINEL
176
+ _body[:connectedAccountId] = connected_account_id if connected_account_id != SENTINEL
177
+ _body[:endpoint] = endpoint if endpoint != SENTINEL
178
+ _body[:method] = method if method != SENTINEL
179
+ _body[:body] = body if body != SENTINEL
180
+ extra[:action_proxy_request_config_dto] = _body if !_body.empty?
181
+ api_response = execute_action_proxy_with_http_info_impl(extra)
171
182
  api_response.data
172
183
  end
173
184
 
@@ -175,60 +186,64 @@ module Composio
175
186
  #
176
187
  # Execute an action with direct auth.
177
188
  #
178
- # @param endpoint [String]
179
- # @param connected_account_id [String]
189
+ # @param parameters [Array<Parameter>]
190
+ # @param connected_account_id [String] The connected account uuid to use for the action.
191
+ # @param endpoint [String] The endpoint to call for the action. If the given url is relative, it will be resolved relative to the base_url set in the connected account info.
192
+ # @param method [Method] The HTTP method to use for the action.
193
+ # @param body [Object] The body to be sent to the endpoint. This can either be a JSON field or a string.
194
+ # @param body [ActionProxyRequestConfigDTO]
180
195
  # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
181
- def execute_action_proxy_with_http_info(endpoint:, connected_account_id:, extra: {})
182
- execute_action_proxy_with_http_info_impl(endpoint, connected_account_id, extra)
196
+ def execute_action_proxy_with_http_info(parameters:, connected_account_id:, endpoint:, method:, body: SENTINEL, extra: {})
197
+ _body = {}
198
+ _body[:parameters] = parameters if parameters != SENTINEL
199
+ _body[:connectedAccountId] = connected_account_id if connected_account_id != SENTINEL
200
+ _body[:endpoint] = endpoint if endpoint != SENTINEL
201
+ _body[:method] = method if method != SENTINEL
202
+ _body[:body] = body if body != SENTINEL
203
+ extra[:action_proxy_request_config_dto] = _body if !_body.empty?
204
+ execute_action_proxy_with_http_info_impl(extra)
183
205
  end
184
206
 
185
207
  # Execute action proxy
186
208
  # Execute an action with direct auth.
187
- # @param endpoint [String]
188
- # @param connected_account_id [String]
189
209
  # @param [Hash] opts the optional parameters
210
+ # @option opts [ActionProxyRequestConfigDTO] :action_proxy_request_config_dto ActionProxyRequestConfigDTO
190
211
  # @return [ActionExecutionResDto]
191
- private def execute_action_proxy_impl(endpoint, connected_account_id, opts = {})
192
- data, _status_code, _headers = execute_action_proxy_with_http_info(endpoint, connected_account_id, opts)
212
+ private def execute_action_proxy_impl(opts = {})
213
+ data, _status_code, _headers = execute_action_proxy_with_http_info(opts)
193
214
  data
194
215
  end
195
216
 
196
217
  # Execute action proxy
197
218
  # Execute an action with direct auth.
198
- # @param endpoint [String]
199
- # @param connected_account_id [String]
200
219
  # @param [Hash] opts the optional parameters
220
+ # @option opts [ActionProxyRequestConfigDTO] :action_proxy_request_config_dto ActionProxyRequestConfigDTO
201
221
  # @return [APIResponse] data is ActionExecutionResDto, status code, headers and response
202
- private def execute_action_proxy_with_http_info_impl(endpoint, connected_account_id, opts = {})
222
+ private def execute_action_proxy_with_http_info_impl(opts = {})
203
223
  if @api_client.config.debugging
204
224
  @api_client.config.logger.debug 'Calling API: ActionsApi.execute_action_proxy ...'
205
225
  end
206
- # verify the required parameter 'endpoint' is set
207
- if @api_client.config.client_side_validation && endpoint.nil?
208
- fail ArgumentError, "Missing the required parameter 'endpoint' when calling ActionsApi.execute_action_proxy"
209
- end
210
- # verify the required parameter 'connected_account_id' is set
211
- if @api_client.config.client_side_validation && connected_account_id.nil?
212
- fail ArgumentError, "Missing the required parameter 'connected_account_id' when calling ActionsApi.execute_action_proxy"
213
- end
214
226
  # resource path
215
227
  local_var_path = '/api/v2/actions/proxy'
216
228
 
217
229
  # query parameters
218
230
  query_params = opts[:query_params] || {}
219
- query_params[:'endpoint'] = endpoint
220
- query_params[:'connectedAccountId'] = connected_account_id
221
231
 
222
232
  # header parameters
223
233
  header_params = opts[:header_params] || {}
224
234
  # HTTP header 'Accept' (if needed)
225
235
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
236
+ # HTTP header 'Content-Type'
237
+ content_type = @api_client.select_header_content_type(['application/json'])
238
+ if !content_type.nil?
239
+ header_params['Content-Type'] = content_type
240
+ end
226
241
 
227
242
  # form parameters
228
243
  form_params = opts[:form_params] || {}
229
244
 
230
245
  # http body (model)
231
- post_body = opts[:debug_body]
246
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'action_proxy_request_config_dto'])
232
247
 
233
248
  # return_type
234
249
  return_type = opts[:debug_return_type] || 'ActionExecutionResDto'
@@ -316,10 +316,13 @@ module Composio
316
316
 
317
317
  # List all connectors
318
318
  #
319
- # List all connectors
320
- #
319
+ # @param page [Float]
320
+ # @param page_size [Float]
321
321
  # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
322
- def list_global_connectors(extra: {})
322
+ def list_global_connectors(page: SENTINEL, page_size: SENTINEL, extra: {})
323
+ extra[:page] = page if page != SENTINEL
324
+ extra[:page_size] = page_size if page_size != SENTINEL
325
+
323
326
  api_response = list_global_connectors_with_http_info_impl(extra)
324
327
  api_response.data
325
328
  end
@@ -333,18 +336,20 @@ module Composio
333
336
  list_global_connectors_with_http_info_impl(extra)
334
337
  end
335
338
 
336
- # List all connectors
337
339
  # List all connectors
338
340
  # @param [Hash] opts the optional parameters
341
+ # @option opts [Float] :page
342
+ # @option opts [Float] :page_size
339
343
  # @return [GetConnectorListResDTO]
340
344
  private def list_global_connectors_impl(opts = {})
341
345
  data, _status_code, _headers = list_global_connectors_with_http_info(opts)
342
346
  data
343
347
  end
344
348
 
345
- # List all connectors
346
349
  # List all connectors
347
350
  # @param [Hash] opts the optional parameters
351
+ # @option opts [Float] :page
352
+ # @option opts [Float] :page_size
348
353
  # @return [APIResponse] data is GetConnectorListResDTO, status code, headers and response
349
354
  private def list_global_connectors_with_http_info_impl(opts = {})
350
355
  if @api_client.config.debugging
@@ -355,6 +360,8 @@ module Composio
355
360
 
356
361
  # query parameters
357
362
  query_params = opts[:query_params] || {}
363
+ query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
364
+ query_params[:'pageSize'] = opts[:'page_size'] if !opts[:'page_size'].nil?
358
365
 
359
366
  # header parameters
360
367
  header_params = opts[:header_params] || {}
@@ -653,7 +653,7 @@ module Composio
653
653
  # Get Trigger Info
654
654
  # @param trigger_name [String]
655
655
  # @param [Hash] opts the optional parameters
656
- # @return [Array<SingleTriggerResDTO>]
656
+ # @return [SingleTriggerResDTO]
657
657
  private def get_trigger_info_impl(trigger_name, opts = {})
658
658
  data, _status_code, _headers = get_trigger_info_with_http_info(trigger_name, opts)
659
659
  data
@@ -663,7 +663,7 @@ module Composio
663
663
  # Get Trigger Info
664
664
  # @param trigger_name [String]
665
665
  # @param [Hash] opts the optional parameters
666
- # @return [APIResponse] data is Array<SingleTriggerResDTO>, status code, headers and response
666
+ # @return [APIResponse] data is SingleTriggerResDTO, status code, headers and response
667
667
  private def get_trigger_info_with_http_info_impl(trigger_name, opts = {})
668
668
  if @api_client.config.debugging
669
669
  @api_client.config.logger.debug 'Calling API: TriggersApi.get_trigger_info ...'
@@ -695,7 +695,7 @@ module Composio
695
695
  post_body = opts[:debug_body]
696
696
 
697
697
  # return_type
698
- return_type = opts[:debug_return_type] || 'Array<SingleTriggerResDTO>'
698
+ return_type = opts[:debug_return_type] || 'SingleTriggerResDTO'
699
699
 
700
700
  # auth_names
701
701
  auth_names = opts[:debug_auth_names] || ['api_key']
@@ -0,0 +1,277 @@
1
+ =begin
2
+ #Composio OpenAPI
3
+
4
+ #Composio SDK: Equip your agent with high-quality tools and build your real-world usecase
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ =end
8
+
9
+ require 'date'
10
+ require 'time'
11
+
12
+ module Composio
13
+ class ActionProxyRequestConfigDTO
14
+ attr_accessor :parameters
15
+
16
+ # The connected account uuid to use for the action.
17
+ attr_accessor :connected_account_id
18
+
19
+ # The endpoint to call for the action. If the given url is relative, it will be resolved relative to the base_url set in the connected account info.
20
+ attr_accessor :endpoint
21
+
22
+ # The HTTP method to use for the action.
23
+ attr_accessor :method
24
+
25
+ # The body to be sent to the endpoint. This can either be a JSON field or a string.
26
+ attr_accessor :body
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'parameters' => :'parameters',
32
+ :'connected_account_id' => :'connectedAccountId',
33
+ :'endpoint' => :'endpoint',
34
+ :'method' => :'method',
35
+ :'body' => :'body'
36
+ }
37
+ end
38
+
39
+ # Returns all the JSON keys this model knows about
40
+ def self.acceptable_attributes
41
+ attribute_map.values
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.openapi_types
46
+ {
47
+ :'parameters' => :'Array<Parameter>',
48
+ :'connected_account_id' => :'String',
49
+ :'endpoint' => :'String',
50
+ :'method' => :'Method',
51
+ :'body' => :'Object'
52
+ }
53
+ end
54
+
55
+ # List of attributes with nullable: true
56
+ def self.openapi_nullable
57
+ Set.new([
58
+ ])
59
+ end
60
+
61
+ # Initializes the object
62
+ # @param [Hash] attributes Model attributes in the form of hash
63
+ def initialize(attributes = {})
64
+ if (!attributes.is_a?(Hash))
65
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Composio::ActionProxyRequestConfigDTO` initialize method"
66
+ end
67
+
68
+ # check to see if the attribute exists and convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h|
70
+ if (!self.class.attribute_map.key?(k.to_sym))
71
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Composio::ActionProxyRequestConfigDTO`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
72
+ end
73
+ h[k.to_sym] = v
74
+ }
75
+
76
+ if attributes.key?(:'parameters')
77
+ if (value = attributes[:'parameters']).is_a?(Array)
78
+ self.parameters = value
79
+ end
80
+ end
81
+
82
+ if attributes.key?(:'connected_account_id')
83
+ self.connected_account_id = attributes[:'connected_account_id']
84
+ end
85
+
86
+ if attributes.key?(:'endpoint')
87
+ self.endpoint = attributes[:'endpoint']
88
+ end
89
+
90
+ if attributes.key?(:'method')
91
+ self.method = attributes[:'method']
92
+ end
93
+
94
+ if attributes.key?(:'body')
95
+ self.body = attributes[:'body']
96
+ end
97
+ end
98
+
99
+ # Show invalid properties with the reasons. Usually used together with valid?
100
+ # @return Array for valid properties with the reasons
101
+ def list_invalid_properties
102
+ invalid_properties = Array.new
103
+ if @parameters.nil?
104
+ invalid_properties.push('invalid value for "parameters", parameters cannot be nil.')
105
+ end
106
+
107
+ if @connected_account_id.nil?
108
+ invalid_properties.push('invalid value for "connected_account_id", connected_account_id cannot be nil.')
109
+ end
110
+
111
+ if @endpoint.nil?
112
+ invalid_properties.push('invalid value for "endpoint", endpoint cannot be nil.')
113
+ end
114
+
115
+ if @method.nil?
116
+ invalid_properties.push('invalid value for "method", method cannot be nil.')
117
+ end
118
+
119
+ invalid_properties
120
+ end
121
+
122
+ # Check to see if the all the properties in the model are valid
123
+ # @return true if the model is valid
124
+ def valid?
125
+ return false if @parameters.nil?
126
+ return false if @connected_account_id.nil?
127
+ return false if @endpoint.nil?
128
+ return false if @method.nil?
129
+ true
130
+ end
131
+
132
+ # Checks equality by comparing each attribute.
133
+ # @param [Object] Object to be compared
134
+ def ==(o)
135
+ return true if self.equal?(o)
136
+ self.class == o.class &&
137
+ parameters == o.parameters &&
138
+ connected_account_id == o.connected_account_id &&
139
+ endpoint == o.endpoint &&
140
+ method == o.method &&
141
+ body == o.body
142
+ end
143
+
144
+ # @see the `==` method
145
+ # @param [Object] Object to be compared
146
+ def eql?(o)
147
+ self == o
148
+ end
149
+
150
+ # Calculates hash code according to all attributes.
151
+ # @return [Integer] Hash code
152
+ def hash
153
+ [parameters, connected_account_id, endpoint, method, body].hash
154
+ end
155
+
156
+ # Builds the object from hash
157
+ # @param [Hash] attributes Model attributes in the form of hash
158
+ # @return [Object] Returns the model itself
159
+ def self.build_from_hash(attributes)
160
+ new.build_from_hash(attributes)
161
+ end
162
+
163
+ # Builds the object from hash
164
+ # @param [Hash] attributes Model attributes in the form of hash
165
+ # @return [Object] Returns the model itself
166
+ def build_from_hash(attributes)
167
+ return nil unless attributes.is_a?(Hash)
168
+ attributes = attributes.transform_keys(&:to_sym)
169
+ self.class.openapi_types.each_pair do |key, type|
170
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
171
+ self.send("#{key}=", nil)
172
+ elsif type =~ /\AArray<(.*)>/i
173
+ # check to ensure the input is an array given that the attribute
174
+ # is documented as an array but the input is not
175
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
176
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
177
+ end
178
+ elsif !attributes[self.class.attribute_map[key]].nil?
179
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
180
+ end
181
+ end
182
+
183
+ self
184
+ end
185
+
186
+ # Deserializes the data based on type
187
+ # @param string type Data type
188
+ # @param string value Value to be deserialized
189
+ # @return [Object] Deserialized data
190
+ def _deserialize(type, value)
191
+ case type.to_sym
192
+ when :Time
193
+ Time.parse(value)
194
+ when :Date
195
+ Date.parse(value)
196
+ when :String
197
+ value.to_s
198
+ when :Integer
199
+ value.to_i
200
+ when :Float
201
+ value.to_f
202
+ when :Boolean
203
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
204
+ true
205
+ else
206
+ false
207
+ end
208
+ when :Object
209
+ # generic object (usually a Hash), return directly
210
+ value
211
+ when /\AArray<(?<inner_type>.+)>\z/
212
+ inner_type = Regexp.last_match[:inner_type]
213
+ value.map { |v| _deserialize(inner_type, v) }
214
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
215
+ k_type = Regexp.last_match[:k_type]
216
+ v_type = Regexp.last_match[:v_type]
217
+ {}.tap do |hash|
218
+ value.each do |k, v|
219
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
220
+ end
221
+ end
222
+ else # model
223
+ # models (e.g. Pet) or oneOf
224
+ klass = Composio.const_get(type)
225
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
226
+ end
227
+ end
228
+
229
+ # Returns the string representation of the object
230
+ # @return [String] String presentation of the object
231
+ def to_s
232
+ to_hash.to_s
233
+ end
234
+
235
+ # to_body is an alias to to_hash (backward compatibility)
236
+ # @return [Hash] Returns the object in the form of hash
237
+ def to_body
238
+ to_hash
239
+ end
240
+
241
+ # Returns the object in the form of hash
242
+ # @return [Hash] Returns the object in the form of hash
243
+ def to_hash
244
+ hash = {}
245
+ self.class.attribute_map.each_pair do |attr, param|
246
+ value = self.send(attr)
247
+ if value.nil?
248
+ is_nullable = self.class.openapi_nullable.include?(attr)
249
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
250
+ end
251
+
252
+ hash[param] = _to_hash(value)
253
+ end
254
+ hash
255
+ end
256
+
257
+ # Outputs non-array value in the form of hash
258
+ # For object, use to_hash. Otherwise, just return the value
259
+ # @param [Object] value Any valid value
260
+ # @return [Hash] Returns the value in the form of hash
261
+ def _to_hash(value)
262
+ if value.is_a?(Array)
263
+ value.compact.map { |v| _to_hash(v) }
264
+ elsif value.is_a?(Hash)
265
+ {}.tap do |hash|
266
+ value.each { |k, v| hash[k] = _to_hash(v) }
267
+ end
268
+ elsif value.respond_to? :to_hash
269
+ value.to_hash
270
+ else
271
+ value
272
+ end
273
+ end
274
+
275
+ end
276
+
277
+ end