composio 0.1.7 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +44 -2
- data/lib/composio/api/actions_api.rb +6 -2
- data/lib/composio/api/connections_api.rb +84 -0
- data/lib/composio/models/action_execution_req_dto.rb +10 -1
- data/lib/composio/models/additional_info.rb +220 -0
- data/lib/composio/models/data.rb +234 -0
- data/lib/composio/models/get_connection_info_response_dto.rb +250 -0
- data/lib/composio/models/parameter.rb +248 -0
- data/lib/composio/version.rb +1 -1
- data/lib/composio.rb +4 -0
- data/spec/api/connections_api_spec.rb +11 -0
- data/spec/models/action_execution_req_dto_spec.rb +6 -0
- data/spec/models/additional_info_spec.rb +28 -0
- data/spec/models/data_spec.rb +34 -0
- data/spec/models/get_connection_info_response_dto_spec.rb +40 -0
- data/spec/models/parameter_spec.rb +40 -0
- metadata +140 -128
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12bca9fcaf3ed64d8a9fc4ae997d474f9512a6342f635813652d56fed502cd70
|
4
|
+
data.tar.gz: a1ed487a3dc4cdc2d8612a0c38145f73321610469b07fce41ccbcfa3e2e9ec02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66f00bd57d5c0684e623f86ab625f985639a49780d69c9139fc066a0f056424ee334ce50573bb971315a898fc83f14e6eeefe09ba7bb36d38ec2c67d9fc43b7b
|
7
|
+
data.tar.gz: e123dc3761333a513fd6a955e6d8b72ac6c2ac45dc738afdbd51d154d5c1f20f1778bafedd62164a71f0c67f174ca0540243895c7248ecb09c05b5abb3e370e1
|
data/Gemfile.lock
CHANGED
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.
|
9
|
+
[![npm](https://img.shields.io/badge/gem-v0.1.9-blue)](https://rubygems.org/gems/composio/versions/0.1.9)
|
10
10
|
[![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://composio.dev)
|
11
11
|
|
12
12
|
</div>
|
@@ -40,6 +40,7 @@ Composio SDK: Equip your agent with high-quality tools and build your real-world
|
|
40
40
|
* [`composio.connections.disable`](#composioconnectionsdisable)
|
41
41
|
* [`composio.connections.enable`](#composioconnectionsenable)
|
42
42
|
* [`composio.connections.get`](#composioconnectionsget)
|
43
|
+
* [`composio.connections.get_info`](#composioconnectionsget_info)
|
43
44
|
* [`composio.connections.initiate`](#composioconnectionsinitiate)
|
44
45
|
* [`composio.connections.list`](#composioconnectionslist)
|
45
46
|
* [`composio.event_logs.get_events`](#composioevent_logsget_events)
|
@@ -77,7 +78,7 @@ Composio SDK: Equip your agent with high-quality tools and build your real-world
|
|
77
78
|
Add to Gemfile:
|
78
79
|
|
79
80
|
```ruby
|
80
|
-
gem 'composio', '~> 0.1.
|
81
|
+
gem 'composio', '~> 0.1.9'
|
81
82
|
```
|
82
83
|
|
83
84
|
## Getting Started<a id="getting-started"></a>
|
@@ -208,6 +209,17 @@ result = composio.actions.execute(
|
|
208
209
|
entity_id: "string_example",
|
209
210
|
endpoint: "string_example",
|
210
211
|
input: {},
|
212
|
+
auth_config: {
|
213
|
+
"parameters" => [
|
214
|
+
{
|
215
|
+
"name" => "name_example",
|
216
|
+
"_in" => "_in_example",
|
217
|
+
"value" => "value_example",
|
218
|
+
}
|
219
|
+
],
|
220
|
+
"base_url" => "base_url_example",
|
221
|
+
"body" => {},
|
222
|
+
},
|
211
223
|
text: "string_example",
|
212
224
|
)
|
213
225
|
p result
|
@@ -221,6 +233,7 @@ p result
|
|
221
233
|
##### entityId: `String`<a id="entityid-string"></a>
|
222
234
|
##### endpoint: `String`<a id="endpoint-string"></a>
|
223
235
|
##### input: `Object`<a id="input-object"></a>
|
236
|
+
##### authConfig: [`GetConnectionInfoResponseDTO`](./lib/composio/models/get_connection_info_response_dto.rb)<a id="authconfig-getconnectioninforesponsedtolibcomposiomodelsget_connection_info_response_dtorb"></a>
|
224
237
|
##### text: `String`<a id="text-string"></a>
|
225
238
|
#### 🔄 Return<a id="🔄-return"></a>
|
226
239
|
|
@@ -738,6 +751,35 @@ p result
|
|
738
751
|
---
|
739
752
|
|
740
753
|
|
754
|
+
### `composio.connections.get_info`<a id="composioconnectionsget_info"></a>
|
755
|
+
|
756
|
+
Get connection info
|
757
|
+
|
758
|
+
#### 🛠️ Usage<a id="🛠️-usage"></a>
|
759
|
+
|
760
|
+
```ruby
|
761
|
+
result = composio.connections.get_info(
|
762
|
+
connected_account_id: "'+j>6",
|
763
|
+
)
|
764
|
+
p result
|
765
|
+
```
|
766
|
+
|
767
|
+
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
768
|
+
|
769
|
+
##### connected_account_id: `String`<a id="connected_account_id-string"></a>
|
770
|
+
#### 🔄 Return<a id="🔄-return"></a>
|
771
|
+
|
772
|
+
[GetConnectionInfoResponseDTO](./lib/composio/models/get_connection_info_response_dto.rb)
|
773
|
+
|
774
|
+
#### 🌐 Endpoint<a id="🌐-endpoint"></a>
|
775
|
+
|
776
|
+
`/api/v1/connectedAccounts/{connectedAccountId}/info` `GET`
|
777
|
+
|
778
|
+
[🔙 **Back to Table of Contents**](#table-of-contents)
|
779
|
+
|
780
|
+
---
|
781
|
+
|
782
|
+
|
741
783
|
### `composio.connections.initiate`<a id="composioconnectionsinitiate"></a>
|
742
784
|
|
743
785
|
Initiate connection
|
@@ -26,16 +26,18 @@ module Composio
|
|
26
26
|
# @param entity_id [String]
|
27
27
|
# @param endpoint [String]
|
28
28
|
# @param input [Object]
|
29
|
+
# @param auth_config [GetConnectionInfoResponseDTO]
|
29
30
|
# @param text [String]
|
30
31
|
# @param body [ActionExecutionReqDTO]
|
31
32
|
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
32
|
-
def execute(action_id:, connected_account_id: SENTINEL, app_name: SENTINEL, entity_id: SENTINEL, endpoint: SENTINEL, input: SENTINEL, text: SENTINEL, extra: {})
|
33
|
+
def execute(action_id:, connected_account_id: SENTINEL, app_name: SENTINEL, entity_id: SENTINEL, endpoint: SENTINEL, input: SENTINEL, auth_config: SENTINEL, text: SENTINEL, extra: {})
|
33
34
|
_body = {}
|
34
35
|
_body[:connectedAccountId] = connected_account_id if connected_account_id != SENTINEL
|
35
36
|
_body[:appName] = app_name if app_name != SENTINEL
|
36
37
|
_body[:entityId] = entity_id if entity_id != SENTINEL
|
37
38
|
_body[:endpoint] = endpoint if endpoint != SENTINEL
|
38
39
|
_body[:input] = input if input != SENTINEL
|
40
|
+
_body[:authConfig] = auth_config if auth_config != SENTINEL
|
39
41
|
_body[:text] = text if text != SENTINEL
|
40
42
|
extra[:action_execution_req_dto] = _body if !_body.empty?
|
41
43
|
api_response = execute_with_http_info_impl(action_id, extra)
|
@@ -52,16 +54,18 @@ module Composio
|
|
52
54
|
# @param entity_id [String]
|
53
55
|
# @param endpoint [String]
|
54
56
|
# @param input [Object]
|
57
|
+
# @param auth_config [GetConnectionInfoResponseDTO]
|
55
58
|
# @param text [String]
|
56
59
|
# @param body [ActionExecutionReqDTO]
|
57
60
|
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
58
|
-
def execute_with_http_info(action_id:, connected_account_id: SENTINEL, app_name: SENTINEL, entity_id: SENTINEL, endpoint: SENTINEL, input: SENTINEL, text: SENTINEL, extra: {})
|
61
|
+
def execute_with_http_info(action_id:, connected_account_id: SENTINEL, app_name: SENTINEL, entity_id: SENTINEL, endpoint: SENTINEL, input: SENTINEL, auth_config: SENTINEL, text: SENTINEL, extra: {})
|
59
62
|
_body = {}
|
60
63
|
_body[:connectedAccountId] = connected_account_id if connected_account_id != SENTINEL
|
61
64
|
_body[:appName] = app_name if app_name != SENTINEL
|
62
65
|
_body[:entityId] = entity_id if entity_id != SENTINEL
|
63
66
|
_body[:endpoint] = endpoint if endpoint != SENTINEL
|
64
67
|
_body[:input] = input if input != SENTINEL
|
68
|
+
_body[:authConfig] = auth_config if auth_config != SENTINEL
|
65
69
|
_body[:text] = text if text != SENTINEL
|
66
70
|
extra[:action_execution_req_dto] = _body if !_body.empty?
|
67
71
|
execute_with_http_info_impl(action_id, extra)
|
@@ -352,6 +352,90 @@ module Composio
|
|
352
352
|
end
|
353
353
|
|
354
354
|
|
355
|
+
# Get connection info
|
356
|
+
#
|
357
|
+
# @param connected_account_id [String]
|
358
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
359
|
+
def get_info(connected_account_id:, extra: {})
|
360
|
+
api_response = get_info_with_http_info_impl(connected_account_id, extra)
|
361
|
+
api_response.data
|
362
|
+
end
|
363
|
+
|
364
|
+
# Get connection info
|
365
|
+
#
|
366
|
+
# @param connected_account_id [String]
|
367
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
368
|
+
def get_info_with_http_info(connected_account_id:, extra: {})
|
369
|
+
get_info_with_http_info_impl(connected_account_id, extra)
|
370
|
+
end
|
371
|
+
|
372
|
+
# Get connection info
|
373
|
+
# @param connected_account_id [String]
|
374
|
+
# @param [Hash] opts the optional parameters
|
375
|
+
# @return [GetConnectionInfoResponseDTO]
|
376
|
+
private def get_info_impl(connected_account_id, opts = {})
|
377
|
+
data, _status_code, _headers = get_info_with_http_info(connected_account_id, opts)
|
378
|
+
data
|
379
|
+
end
|
380
|
+
|
381
|
+
# Get connection info
|
382
|
+
# @param connected_account_id [String]
|
383
|
+
# @param [Hash] opts the optional parameters
|
384
|
+
# @return [APIResponse] data is GetConnectionInfoResponseDTO, status code, headers and response
|
385
|
+
private def get_info_with_http_info_impl(connected_account_id, opts = {})
|
386
|
+
if @api_client.config.debugging
|
387
|
+
@api_client.config.logger.debug 'Calling API: ConnectionsApi.get_info ...'
|
388
|
+
end
|
389
|
+
# verify the required parameter 'connected_account_id' is set
|
390
|
+
if @api_client.config.client_side_validation && connected_account_id.nil?
|
391
|
+
fail ArgumentError, "Missing the required parameter 'connected_account_id' when calling ConnectionsApi.get_info"
|
392
|
+
end
|
393
|
+
pattern = Regexp.new(/[^\/#\?]+?/)
|
394
|
+
if @api_client.config.client_side_validation && connected_account_id !~ pattern
|
395
|
+
fail ArgumentError, "invalid value for 'connected_account_id' when calling ConnectionsApi.get_info, must conform to the pattern #{pattern}."
|
396
|
+
end
|
397
|
+
|
398
|
+
# resource path
|
399
|
+
local_var_path = '/api/v1/connectedAccounts/{connectedAccountId}/info'.sub('{' + 'connectedAccountId' + '}', CGI.escape(connected_account_id.to_s))
|
400
|
+
|
401
|
+
# query parameters
|
402
|
+
query_params = opts[:query_params] || {}
|
403
|
+
|
404
|
+
# header parameters
|
405
|
+
header_params = opts[:header_params] || {}
|
406
|
+
# HTTP header 'Accept' (if needed)
|
407
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
408
|
+
|
409
|
+
# form parameters
|
410
|
+
form_params = opts[:form_params] || {}
|
411
|
+
|
412
|
+
# http body (model)
|
413
|
+
post_body = opts[:debug_body]
|
414
|
+
|
415
|
+
# return_type
|
416
|
+
return_type = opts[:debug_return_type] || 'GetConnectionInfoResponseDTO'
|
417
|
+
|
418
|
+
# auth_names
|
419
|
+
auth_names = opts[:debug_auth_names] || ['api_key']
|
420
|
+
|
421
|
+
new_options = opts.merge(
|
422
|
+
:operation => :"ConnectionsApi.get_info",
|
423
|
+
:header_params => header_params,
|
424
|
+
:query_params => query_params,
|
425
|
+
:form_params => form_params,
|
426
|
+
:body => post_body,
|
427
|
+
:auth_names => auth_names,
|
428
|
+
:return_type => return_type
|
429
|
+
)
|
430
|
+
|
431
|
+
data, status_code, headers, response = @api_client.call_api(:GET, local_var_path, new_options)
|
432
|
+
if @api_client.config.debugging
|
433
|
+
@api_client.config.logger.debug "API called: ConnectionsApi#get_info\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
434
|
+
end
|
435
|
+
APIResponse::new(data, status_code, headers, response)
|
436
|
+
end
|
437
|
+
|
438
|
+
|
355
439
|
# Initiate connection
|
356
440
|
#
|
357
441
|
# @param integration_id [String]
|
@@ -21,6 +21,8 @@ module Composio
|
|
21
21
|
|
22
22
|
attr_accessor :input
|
23
23
|
|
24
|
+
attr_accessor :auth_config
|
25
|
+
|
24
26
|
attr_accessor :text
|
25
27
|
|
26
28
|
# Attribute mapping from ruby-style variable name to JSON key.
|
@@ -31,6 +33,7 @@ module Composio
|
|
31
33
|
:'entity_id' => :'entityId',
|
32
34
|
:'endpoint' => :'endpoint',
|
33
35
|
:'input' => :'input',
|
36
|
+
:'auth_config' => :'authConfig',
|
34
37
|
:'text' => :'text'
|
35
38
|
}
|
36
39
|
end
|
@@ -48,6 +51,7 @@ module Composio
|
|
48
51
|
:'entity_id' => :'String',
|
49
52
|
:'endpoint' => :'String',
|
50
53
|
:'input' => :'Object',
|
54
|
+
:'auth_config' => :'GetConnectionInfoResponseDTO',
|
51
55
|
:'text' => :'String'
|
52
56
|
}
|
53
57
|
end
|
@@ -93,6 +97,10 @@ module Composio
|
|
93
97
|
self.input = attributes[:'input']
|
94
98
|
end
|
95
99
|
|
100
|
+
if attributes.key?(:'auth_config')
|
101
|
+
self.auth_config = attributes[:'auth_config']
|
102
|
+
end
|
103
|
+
|
96
104
|
if attributes.key?(:'text')
|
97
105
|
self.text = attributes[:'text']
|
98
106
|
end
|
@@ -121,6 +129,7 @@ module Composio
|
|
121
129
|
entity_id == o.entity_id &&
|
122
130
|
endpoint == o.endpoint &&
|
123
131
|
input == o.input &&
|
132
|
+
auth_config == o.auth_config &&
|
124
133
|
text == o.text
|
125
134
|
end
|
126
135
|
|
@@ -133,7 +142,7 @@ module Composio
|
|
133
142
|
# Calculates hash code according to all attributes.
|
134
143
|
# @return [Integer] Hash code
|
135
144
|
def hash
|
136
|
-
[connected_account_id, app_name, entity_id, endpoint, input, text].hash
|
145
|
+
[connected_account_id, app_name, entity_id, endpoint, input, auth_config, text].hash
|
137
146
|
end
|
138
147
|
|
139
148
|
# Builds the object from hash
|
@@ -0,0 +1,220 @@
|
|
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 AdditionalInfo
|
14
|
+
attr_accessor :meta
|
15
|
+
|
16
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
17
|
+
def self.attribute_map
|
18
|
+
{
|
19
|
+
:'meta' => :'meta'
|
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
|
+
:'meta' => :'String'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# List of attributes with nullable: true
|
36
|
+
def self.openapi_nullable
|
37
|
+
Set.new([
|
38
|
+
])
|
39
|
+
end
|
40
|
+
|
41
|
+
# Initializes the object
|
42
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
43
|
+
def initialize(attributes = {})
|
44
|
+
if (!attributes.is_a?(Hash))
|
45
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Composio::AdditionalInfo` 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 `Composio::AdditionalInfo`. 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?(:'meta')
|
57
|
+
self.meta = attributes[:'meta']
|
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 @meta.nil?
|
66
|
+
invalid_properties.push('invalid value for "meta", meta 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 @meta.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
|
+
meta == o.meta
|
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
|
+
[meta].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 = Composio.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
|