ultracart_api 3.11.29 → 3.11.31

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.
@@ -93,6 +93,66 @@ module UltracartClient
93
93
  end
94
94
  return data, status_code, headers
95
95
  end
96
+ # Delete an agent MCP server
97
+ # Delete an agent MCP server
98
+ # @param user_id
99
+ # @param mcp_server_uuid
100
+ # @param [Hash] opts the optional parameters
101
+ # @return [nil]
102
+ def delete_agent_profile_mcp(user_id, mcp_server_uuid, opts = {})
103
+ delete_agent_profile_mcp_with_http_info(user_id, mcp_server_uuid, opts)
104
+ nil
105
+ end
106
+
107
+ # Delete an agent MCP server
108
+ # Delete an agent MCP server
109
+ # @param user_id
110
+ # @param mcp_server_uuid
111
+ # @param [Hash] opts the optional parameters
112
+ # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
113
+ def delete_agent_profile_mcp_with_http_info(user_id, mcp_server_uuid, opts = {})
114
+ if @api_client.config.debugging
115
+ @api_client.config.logger.debug 'Calling API: ConversationApi.delete_agent_profile_mcp ...'
116
+ end
117
+ # verify the required parameter 'user_id' is set
118
+ if @api_client.config.client_side_validation && user_id.nil?
119
+ fail ArgumentError, "Missing the required parameter 'user_id' when calling ConversationApi.delete_agent_profile_mcp"
120
+ end
121
+ # verify the required parameter 'mcp_server_uuid' is set
122
+ if @api_client.config.client_side_validation && mcp_server_uuid.nil?
123
+ fail ArgumentError, "Missing the required parameter 'mcp_server_uuid' when calling ConversationApi.delete_agent_profile_mcp"
124
+ end
125
+ # resource path
126
+ local_var_path = '/conversation/agent/profiles/{user_id}/mcps/{mcp_server_uuid}'.sub('{' + 'user_id' + '}', user_id.to_s).sub('{' + 'mcp_server_uuid' + '}', mcp_server_uuid.to_s)
127
+
128
+ # query parameters
129
+ query_params = {}
130
+
131
+ # header parameters
132
+ header_params = {}
133
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
134
+ # HTTP header 'Accept' (if needed)
135
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
136
+ # HTTP header 'Content-Type'
137
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
138
+
139
+ # form parameters
140
+ form_params = {}
141
+
142
+ # http body (model)
143
+ post_body = nil
144
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
145
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
146
+ :header_params => header_params,
147
+ :query_params => query_params,
148
+ :form_params => form_params,
149
+ :body => post_body,
150
+ :auth_names => auth_names)
151
+ if @api_client.config.debugging
152
+ @api_client.config.logger.debug "API called: ConversationApi#delete_agent_profile_mcp\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
153
+ end
154
+ return data, status_code, headers
155
+ end
96
156
  # Delete a conversation canned message
97
157
  # Delete a conversation canned message
98
158
  # @param conversation_canned_message_oid
@@ -851,6 +911,183 @@ module UltracartClient
851
911
  end
852
912
  return data, status_code, headers
853
913
  end
914
+ # Get an MCP server associated with this agent
915
+ # Retrieve MCP server associated with this agent
916
+ # @param user_id
917
+ # @param mcp_server_uuid
918
+ # @param [Hash] opts the optional parameters
919
+ # @return [ConversationMcpServerResponse]
920
+ def get_agent_profile_mcp(user_id, mcp_server_uuid, opts = {})
921
+ data, _status_code, _headers = get_agent_profile_mcp_with_http_info(user_id, mcp_server_uuid, opts)
922
+ data
923
+ end
924
+
925
+ # Get an MCP server associated with this agent
926
+ # Retrieve MCP server associated with this agent
927
+ # @param user_id
928
+ # @param mcp_server_uuid
929
+ # @param [Hash] opts the optional parameters
930
+ # @return [Array<(ConversationMcpServerResponse, Fixnum, Hash)>] ConversationMcpServerResponse data, response status code and response headers
931
+ def get_agent_profile_mcp_with_http_info(user_id, mcp_server_uuid, opts = {})
932
+ if @api_client.config.debugging
933
+ @api_client.config.logger.debug 'Calling API: ConversationApi.get_agent_profile_mcp ...'
934
+ end
935
+ # verify the required parameter 'user_id' is set
936
+ if @api_client.config.client_side_validation && user_id.nil?
937
+ fail ArgumentError, "Missing the required parameter 'user_id' when calling ConversationApi.get_agent_profile_mcp"
938
+ end
939
+ # verify the required parameter 'mcp_server_uuid' is set
940
+ if @api_client.config.client_side_validation && mcp_server_uuid.nil?
941
+ fail ArgumentError, "Missing the required parameter 'mcp_server_uuid' when calling ConversationApi.get_agent_profile_mcp"
942
+ end
943
+ # resource path
944
+ local_var_path = '/conversation/agent/profiles/{user_id}/mcps/{mcp_server_uuid}'.sub('{' + 'user_id' + '}', user_id.to_s).sub('{' + 'mcp_server_uuid' + '}', mcp_server_uuid.to_s)
945
+
946
+ # query parameters
947
+ query_params = {}
948
+
949
+ # header parameters
950
+ header_params = {}
951
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
952
+ # HTTP header 'Accept' (if needed)
953
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
954
+ # HTTP header 'Content-Type'
955
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
956
+
957
+ # form parameters
958
+ form_params = {}
959
+
960
+ # http body (model)
961
+ post_body = nil
962
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
963
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
964
+ :header_params => header_params,
965
+ :query_params => query_params,
966
+ :form_params => form_params,
967
+ :body => post_body,
968
+ :auth_names => auth_names,
969
+ :return_type => 'ConversationMcpServerResponse')
970
+ if @api_client.config.debugging
971
+ @api_client.config.logger.debug "API called: ConversationApi#get_agent_profile_mcp\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
972
+ end
973
+ return data, status_code, headers
974
+ end
975
+ # Get the tools available from the MCP server
976
+ # Get the tools available from the MCP server
977
+ # @param user_id
978
+ # @param mcp_server_uuid
979
+ # @param [Hash] opts the optional parameters
980
+ # @return [ConversationMcpServerToolsResponse]
981
+ def get_agent_profile_mcp_tools(user_id, mcp_server_uuid, opts = {})
982
+ data, _status_code, _headers = get_agent_profile_mcp_tools_with_http_info(user_id, mcp_server_uuid, opts)
983
+ data
984
+ end
985
+
986
+ # Get the tools available from the MCP server
987
+ # Get the tools available from the MCP server
988
+ # @param user_id
989
+ # @param mcp_server_uuid
990
+ # @param [Hash] opts the optional parameters
991
+ # @return [Array<(ConversationMcpServerToolsResponse, Fixnum, Hash)>] ConversationMcpServerToolsResponse data, response status code and response headers
992
+ def get_agent_profile_mcp_tools_with_http_info(user_id, mcp_server_uuid, opts = {})
993
+ if @api_client.config.debugging
994
+ @api_client.config.logger.debug 'Calling API: ConversationApi.get_agent_profile_mcp_tools ...'
995
+ end
996
+ # verify the required parameter 'user_id' is set
997
+ if @api_client.config.client_side_validation && user_id.nil?
998
+ fail ArgumentError, "Missing the required parameter 'user_id' when calling ConversationApi.get_agent_profile_mcp_tools"
999
+ end
1000
+ # verify the required parameter 'mcp_server_uuid' is set
1001
+ if @api_client.config.client_side_validation && mcp_server_uuid.nil?
1002
+ fail ArgumentError, "Missing the required parameter 'mcp_server_uuid' when calling ConversationApi.get_agent_profile_mcp_tools"
1003
+ end
1004
+ # resource path
1005
+ local_var_path = '/conversation/agent/profiles/{user_id}/mcps/{mcp_server_uuid}/tools'.sub('{' + 'user_id' + '}', user_id.to_s).sub('{' + 'mcp_server_uuid' + '}', mcp_server_uuid.to_s)
1006
+
1007
+ # query parameters
1008
+ query_params = {}
1009
+
1010
+ # header parameters
1011
+ header_params = {}
1012
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
1013
+ # HTTP header 'Accept' (if needed)
1014
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1015
+ # HTTP header 'Content-Type'
1016
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
1017
+
1018
+ # form parameters
1019
+ form_params = {}
1020
+
1021
+ # http body (model)
1022
+ post_body = nil
1023
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
1024
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
1025
+ :header_params => header_params,
1026
+ :query_params => query_params,
1027
+ :form_params => form_params,
1028
+ :body => post_body,
1029
+ :auth_names => auth_names,
1030
+ :return_type => 'ConversationMcpServerToolsResponse')
1031
+ if @api_client.config.debugging
1032
+ @api_client.config.logger.debug "API called: ConversationApi#get_agent_profile_mcp_tools\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1033
+ end
1034
+ return data, status_code, headers
1035
+ end
1036
+ # Get the list of MCP servers associated with this agent
1037
+ # Retrieve MCP servers associated with this agent
1038
+ # @param user_id
1039
+ # @param [Hash] opts the optional parameters
1040
+ # @return [ConversationMcpServersResponse]
1041
+ def get_agent_profile_mcps(user_id, opts = {})
1042
+ data, _status_code, _headers = get_agent_profile_mcps_with_http_info(user_id, opts)
1043
+ data
1044
+ end
1045
+
1046
+ # Get the list of MCP servers associated with this agent
1047
+ # Retrieve MCP servers associated with this agent
1048
+ # @param user_id
1049
+ # @param [Hash] opts the optional parameters
1050
+ # @return [Array<(ConversationMcpServersResponse, Fixnum, Hash)>] ConversationMcpServersResponse data, response status code and response headers
1051
+ def get_agent_profile_mcps_with_http_info(user_id, opts = {})
1052
+ if @api_client.config.debugging
1053
+ @api_client.config.logger.debug 'Calling API: ConversationApi.get_agent_profile_mcps ...'
1054
+ end
1055
+ # verify the required parameter 'user_id' is set
1056
+ if @api_client.config.client_side_validation && user_id.nil?
1057
+ fail ArgumentError, "Missing the required parameter 'user_id' when calling ConversationApi.get_agent_profile_mcps"
1058
+ end
1059
+ # resource path
1060
+ local_var_path = '/conversation/agent/profiles/{user_id}/mcps'.sub('{' + 'user_id' + '}', user_id.to_s)
1061
+
1062
+ # query parameters
1063
+ query_params = {}
1064
+
1065
+ # header parameters
1066
+ header_params = {}
1067
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
1068
+ # HTTP header 'Accept' (if needed)
1069
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1070
+ # HTTP header 'Content-Type'
1071
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
1072
+
1073
+ # form parameters
1074
+ form_params = {}
1075
+
1076
+ # http body (model)
1077
+ post_body = nil
1078
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
1079
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
1080
+ :header_params => header_params,
1081
+ :query_params => query_params,
1082
+ :form_params => form_params,
1083
+ :body => post_body,
1084
+ :auth_names => auth_names,
1085
+ :return_type => 'ConversationMcpServersResponse')
1086
+ if @api_client.config.debugging
1087
+ @api_client.config.logger.debug "API called: ConversationApi#get_agent_profile_mcps\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1088
+ end
1089
+ return data, status_code, headers
1090
+ end
854
1091
  # Get agent profiles
855
1092
  # Retrieve the agents profile
856
1093
  # @param [Hash] opts the optional parameters
@@ -3187,6 +3424,67 @@ module UltracartClient
3187
3424
  end
3188
3425
  return data, status_code, headers
3189
3426
  end
3427
+ # Insert an agent MCP server
3428
+ # Insert an agent MCP server
3429
+ # @param user_id
3430
+ # @param mcp_server MCP Server
3431
+ # @param [Hash] opts the optional parameters
3432
+ # @return [ConversationMcpServerResponse]
3433
+ def insert_agent_profile_mcp(user_id, mcp_server, opts = {})
3434
+ data, _status_code, _headers = insert_agent_profile_mcp_with_http_info(user_id, mcp_server, opts)
3435
+ data
3436
+ end
3437
+
3438
+ # Insert an agent MCP server
3439
+ # Insert an agent MCP server
3440
+ # @param user_id
3441
+ # @param mcp_server MCP Server
3442
+ # @param [Hash] opts the optional parameters
3443
+ # @return [Array<(ConversationMcpServerResponse, Fixnum, Hash)>] ConversationMcpServerResponse data, response status code and response headers
3444
+ def insert_agent_profile_mcp_with_http_info(user_id, mcp_server, opts = {})
3445
+ if @api_client.config.debugging
3446
+ @api_client.config.logger.debug 'Calling API: ConversationApi.insert_agent_profile_mcp ...'
3447
+ end
3448
+ # verify the required parameter 'user_id' is set
3449
+ if @api_client.config.client_side_validation && user_id.nil?
3450
+ fail ArgumentError, "Missing the required parameter 'user_id' when calling ConversationApi.insert_agent_profile_mcp"
3451
+ end
3452
+ # verify the required parameter 'mcp_server' is set
3453
+ if @api_client.config.client_side_validation && mcp_server.nil?
3454
+ fail ArgumentError, "Missing the required parameter 'mcp_server' when calling ConversationApi.insert_agent_profile_mcp"
3455
+ end
3456
+ # resource path
3457
+ local_var_path = '/conversation/agent/profiles/{user_id}/mcps'.sub('{' + 'user_id' + '}', user_id.to_s)
3458
+
3459
+ # query parameters
3460
+ query_params = {}
3461
+
3462
+ # header parameters
3463
+ header_params = {}
3464
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
3465
+ # HTTP header 'Accept' (if needed)
3466
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
3467
+ # HTTP header 'Content-Type'
3468
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
3469
+
3470
+ # form parameters
3471
+ form_params = {}
3472
+
3473
+ # http body (model)
3474
+ post_body = @api_client.object_to_http_body(mcp_server)
3475
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
3476
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
3477
+ :header_params => header_params,
3478
+ :query_params => query_params,
3479
+ :form_params => form_params,
3480
+ :body => post_body,
3481
+ :auth_names => auth_names,
3482
+ :return_type => 'ConversationMcpServerResponse')
3483
+ if @api_client.config.debugging
3484
+ @api_client.config.logger.debug "API called: ConversationApi#insert_agent_profile_mcp\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
3485
+ end
3486
+ return data, status_code, headers
3487
+ end
3190
3488
  # Insert a canned message
3191
3489
  # Insert a canned message
3192
3490
  # @param canned_message Canned message
@@ -0,0 +1,289 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ OpenAPI spec version: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.15-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module UltracartClient
16
+ class ConversationMcpServer
17
+ # Authorization Method
18
+ attr_accessor :auth_method
19
+
20
+ # Basic password
21
+ attr_accessor :basic_password
22
+
23
+ # Basic user name
24
+ attr_accessor :basic_user_name
25
+
26
+ # Header name
27
+ attr_accessor :header_name
28
+
29
+ # Header value
30
+ attr_accessor :header_value
31
+
32
+ # UUID of the MCP server configuration
33
+ attr_accessor :mcp_server_uuid
34
+
35
+ # Priority on which the MCP server tools are incorporated into the model. Lower number comes first
36
+ attr_accessor :priority
37
+
38
+ # URL to the MCP server (must be https)
39
+ attr_accessor :url
40
+
41
+ class EnumAttributeValidator
42
+ attr_reader :datatype
43
+ attr_reader :allowable_values
44
+
45
+ def initialize(datatype, allowable_values)
46
+ @allowable_values = allowable_values.map do |value|
47
+ case datatype.to_s
48
+ when /Integer/i
49
+ value.to_i
50
+ when /Float/i
51
+ value.to_f
52
+ else
53
+ value
54
+ end
55
+ end
56
+ end
57
+
58
+ def valid?(value)
59
+ !value || allowable_values.include?(value)
60
+ end
61
+ end
62
+
63
+ # Attribute mapping from ruby-style variable name to JSON key.
64
+ def self.attribute_map
65
+ {
66
+ :'auth_method' => :'auth_method',
67
+ :'basic_password' => :'basic_password',
68
+ :'basic_user_name' => :'basic_user_name',
69
+ :'header_name' => :'header_name',
70
+ :'header_value' => :'header_value',
71
+ :'mcp_server_uuid' => :'mcp_server_uuid',
72
+ :'priority' => :'priority',
73
+ :'url' => :'url'
74
+ }
75
+ end
76
+
77
+ # Attribute type mapping.
78
+ def self.swagger_types
79
+ {
80
+ :'auth_method' => :'String',
81
+ :'basic_password' => :'String',
82
+ :'basic_user_name' => :'String',
83
+ :'header_name' => :'String',
84
+ :'header_value' => :'String',
85
+ :'mcp_server_uuid' => :'String',
86
+ :'priority' => :'Integer',
87
+ :'url' => :'String'
88
+ }
89
+ end
90
+
91
+ # Initializes the object
92
+ # @param [Hash] attributes Model attributes in the form of hash
93
+ def initialize(attributes = {})
94
+ return unless attributes.is_a?(Hash)
95
+
96
+ # convert string to symbol for hash key
97
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
98
+
99
+ if attributes.has_key?(:'auth_method')
100
+ self.auth_method = attributes[:'auth_method']
101
+ end
102
+
103
+ if attributes.has_key?(:'basic_password')
104
+ self.basic_password = attributes[:'basic_password']
105
+ end
106
+
107
+ if attributes.has_key?(:'basic_user_name')
108
+ self.basic_user_name = attributes[:'basic_user_name']
109
+ end
110
+
111
+ if attributes.has_key?(:'header_name')
112
+ self.header_name = attributes[:'header_name']
113
+ end
114
+
115
+ if attributes.has_key?(:'header_value')
116
+ self.header_value = attributes[:'header_value']
117
+ end
118
+
119
+ if attributes.has_key?(:'mcp_server_uuid')
120
+ self.mcp_server_uuid = attributes[:'mcp_server_uuid']
121
+ end
122
+
123
+ if attributes.has_key?(:'priority')
124
+ self.priority = attributes[:'priority']
125
+ end
126
+
127
+ if attributes.has_key?(:'url')
128
+ self.url = attributes[:'url']
129
+ end
130
+ end
131
+
132
+ # Show invalid properties with the reasons. Usually used together with valid?
133
+ # @return Array for valid properties with the reasons
134
+ def list_invalid_properties
135
+ invalid_properties = Array.new
136
+ invalid_properties
137
+ end
138
+
139
+ # Check to see if the all the properties in the model are valid
140
+ # @return true if the model is valid
141
+ def valid?
142
+ auth_method_validator = EnumAttributeValidator.new('String', ['none', 'header', 'basic'])
143
+ return false unless auth_method_validator.valid?(@auth_method)
144
+ true
145
+ end
146
+
147
+ # Custom attribute writer method checking allowed values (enum).
148
+ # @param [Object] auth_method Object to be assigned
149
+ def auth_method=(auth_method)
150
+ validator = EnumAttributeValidator.new('String', ['none', 'header', 'basic'])
151
+ unless validator.valid?(auth_method)
152
+ fail ArgumentError, 'invalid value for "auth_method", must be one of #{validator.allowable_values}.'
153
+ end
154
+ @auth_method = auth_method
155
+ end
156
+
157
+ # Checks equality by comparing each attribute.
158
+ # @param [Object] Object to be compared
159
+ def ==(o)
160
+ return true if self.equal?(o)
161
+ self.class == o.class &&
162
+ auth_method == o.auth_method &&
163
+ basic_password == o.basic_password &&
164
+ basic_user_name == o.basic_user_name &&
165
+ header_name == o.header_name &&
166
+ header_value == o.header_value &&
167
+ mcp_server_uuid == o.mcp_server_uuid &&
168
+ priority == o.priority &&
169
+ url == o.url
170
+ end
171
+
172
+ # @see the `==` method
173
+ # @param [Object] Object to be compared
174
+ def eql?(o)
175
+ self == o
176
+ end
177
+
178
+ # Calculates hash code according to all attributes.
179
+ # @return [Fixnum] Hash code
180
+ def hash
181
+ [auth_method, basic_password, basic_user_name, header_name, header_value, mcp_server_uuid, priority, url].hash
182
+ end
183
+
184
+ # Builds the object from hash
185
+ # @param [Hash] attributes Model attributes in the form of hash
186
+ # @return [Object] Returns the model itself
187
+ def build_from_hash(attributes)
188
+ return nil unless attributes.is_a?(Hash)
189
+ self.class.swagger_types.each_pair do |key, type|
190
+ if type =~ /\AArray<(.*)>/i
191
+ # check to ensure the input is an array given that the attribute
192
+ # is documented as an array but the input is not
193
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
194
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
195
+ end
196
+ elsif !attributes[self.class.attribute_map[key]].nil?
197
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
198
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
199
+ end
200
+
201
+ self
202
+ end
203
+
204
+ # Deserializes the data based on type
205
+ # @param string type Data type
206
+ # @param string value Value to be deserialized
207
+ # @return [Object] Deserialized data
208
+ def _deserialize(type, value)
209
+ case type.to_sym
210
+ when :DateTime
211
+ DateTime.parse(value)
212
+ when :Date
213
+ Date.parse(value)
214
+ when :String
215
+ value.to_s
216
+ when :Integer
217
+ value.to_i
218
+ when :Float
219
+ value.to_f
220
+ when :BOOLEAN
221
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
222
+ true
223
+ else
224
+ false
225
+ end
226
+ when :Object
227
+ # generic object (usually a Hash), return directly
228
+ value
229
+ when /\AArray<(?<inner_type>.+)>\z/
230
+ inner_type = Regexp.last_match[:inner_type]
231
+ value.map { |v| _deserialize(inner_type, v) }
232
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
233
+ k_type = Regexp.last_match[:k_type]
234
+ v_type = Regexp.last_match[:v_type]
235
+ {}.tap do |hash|
236
+ value.each do |k, v|
237
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
238
+ end
239
+ end
240
+ else # model
241
+ temp_model = UltracartClient.const_get(type).new
242
+ temp_model.build_from_hash(value)
243
+ end
244
+ end
245
+
246
+ # Returns the string representation of the object
247
+ # @return [String] String presentation of the object
248
+ def to_s
249
+ to_hash.to_s
250
+ end
251
+
252
+ # to_body is an alias to to_hash (backward compatibility)
253
+ # @return [Hash] Returns the object in the form of hash
254
+ def to_body
255
+ to_hash
256
+ end
257
+
258
+ # Returns the object in the form of hash
259
+ # @return [Hash] Returns the object in the form of hash
260
+ def to_hash
261
+ hash = {}
262
+ self.class.attribute_map.each_pair do |attr, param|
263
+ value = self.send(attr)
264
+ next if value.nil?
265
+ hash[param] = _to_hash(value)
266
+ end
267
+ hash
268
+ end
269
+
270
+ # Outputs non-array value in the form of hash
271
+ # For object, use to_hash. Otherwise, just return the value
272
+ # @param [Object] value Any valid value
273
+ # @return [Hash] Returns the value in the form of hash
274
+ def _to_hash(value)
275
+ if value.is_a?(Array)
276
+ value.compact.map { |v| _to_hash(v) }
277
+ elsif value.is_a?(Hash)
278
+ {}.tap do |hash|
279
+ value.each { |k, v| hash[k] = _to_hash(v) }
280
+ end
281
+ elsif value.respond_to? :to_hash
282
+ value.to_hash
283
+ else
284
+ value
285
+ end
286
+ end
287
+
288
+ end
289
+ end