ultracart_api 4.1.29 → 4.1.30

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.
@@ -992,6 +992,140 @@ module UltracartClient
992
992
  return data, status_code, headers
993
993
  end
994
994
 
995
+ # Get an MCP server associated with this agent
996
+ # Retrieve MCP server associated with this agent
997
+ # @param user_id [Integer]
998
+ # @param mcp_server_uuid [String]
999
+ # @param [Hash] opts the optional parameters
1000
+ # @return [ConversationMcpServerResponse]
1001
+ def get_agent_profile_mcp(user_id, mcp_server_uuid, opts = {})
1002
+ data, _status_code, _headers = get_agent_profile_mcp_with_http_info(user_id, mcp_server_uuid, opts)
1003
+ data
1004
+ end
1005
+
1006
+ # Get an MCP server associated with this agent
1007
+ # Retrieve MCP server associated with this agent
1008
+ # @param user_id [Integer]
1009
+ # @param mcp_server_uuid [String]
1010
+ # @param [Hash] opts the optional parameters
1011
+ # @return [Array<(ConversationMcpServerResponse, Integer, Hash)>] ConversationMcpServerResponse data, response status code and response headers
1012
+ def get_agent_profile_mcp_with_http_info(user_id, mcp_server_uuid, opts = {})
1013
+ if @api_client.config.debugging
1014
+ @api_client.config.logger.debug 'Calling API: ConversationApi.get_agent_profile_mcp ...'
1015
+ end
1016
+ # verify the required parameter 'user_id' is set
1017
+ if @api_client.config.client_side_validation && user_id.nil?
1018
+ fail ArgumentError, "Missing the required parameter 'user_id' when calling ConversationApi.get_agent_profile_mcp"
1019
+ end
1020
+ # verify the required parameter 'mcp_server_uuid' is set
1021
+ if @api_client.config.client_side_validation && mcp_server_uuid.nil?
1022
+ fail ArgumentError, "Missing the required parameter 'mcp_server_uuid' when calling ConversationApi.get_agent_profile_mcp"
1023
+ end
1024
+ # resource path
1025
+ local_var_path = '/conversation/agent/profiles/{user_id}/mcps/{mcp_server_uuid}'.sub('{' + 'user_id' + '}', CGI.escape(user_id.to_s)).sub('{' + 'mcp_server_uuid' + '}', CGI.escape(mcp_server_uuid.to_s))
1026
+
1027
+ # query parameters
1028
+ query_params = opts[:query_params] || {}
1029
+
1030
+ # header parameters
1031
+ header_params = opts[:header_params] || {}
1032
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
1033
+ # HTTP header 'Accept' (if needed)
1034
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1035
+
1036
+ # form parameters
1037
+ form_params = opts[:form_params] || {}
1038
+
1039
+ # http body (model)
1040
+ post_body = opts[:debug_body]
1041
+
1042
+ # return_type
1043
+ return_type = opts[:debug_return_type] || 'ConversationMcpServerResponse'
1044
+
1045
+ # auth_names
1046
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
1047
+
1048
+ new_options = opts.merge(
1049
+ :operation => :"ConversationApi.get_agent_profile_mcp",
1050
+ :header_params => header_params,
1051
+ :query_params => query_params,
1052
+ :form_params => form_params,
1053
+ :body => post_body,
1054
+ :auth_names => auth_names,
1055
+ :return_type => return_type
1056
+ )
1057
+
1058
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
1059
+ if @api_client.config.debugging
1060
+ @api_client.config.logger.debug "API called: ConversationApi#get_agent_profile_mcp\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1061
+ end
1062
+ return data, status_code, headers
1063
+ end
1064
+
1065
+ # Get the list of MCP servers associated with this agent
1066
+ # Retrieve MCP servers associated with this agent
1067
+ # @param user_id [Integer]
1068
+ # @param [Hash] opts the optional parameters
1069
+ # @return [ConversationMcpServersResponse]
1070
+ def get_agent_profile_mcps(user_id, opts = {})
1071
+ data, _status_code, _headers = get_agent_profile_mcps_with_http_info(user_id, opts)
1072
+ data
1073
+ end
1074
+
1075
+ # Get the list of MCP servers associated with this agent
1076
+ # Retrieve MCP servers associated with this agent
1077
+ # @param user_id [Integer]
1078
+ # @param [Hash] opts the optional parameters
1079
+ # @return [Array<(ConversationMcpServersResponse, Integer, Hash)>] ConversationMcpServersResponse data, response status code and response headers
1080
+ def get_agent_profile_mcps_with_http_info(user_id, opts = {})
1081
+ if @api_client.config.debugging
1082
+ @api_client.config.logger.debug 'Calling API: ConversationApi.get_agent_profile_mcps ...'
1083
+ end
1084
+ # verify the required parameter 'user_id' is set
1085
+ if @api_client.config.client_side_validation && user_id.nil?
1086
+ fail ArgumentError, "Missing the required parameter 'user_id' when calling ConversationApi.get_agent_profile_mcps"
1087
+ end
1088
+ # resource path
1089
+ local_var_path = '/conversation/agent/profiles/{user_id}/mcps'.sub('{' + 'user_id' + '}', CGI.escape(user_id.to_s))
1090
+
1091
+ # query parameters
1092
+ query_params = opts[:query_params] || {}
1093
+
1094
+ # header parameters
1095
+ header_params = opts[:header_params] || {}
1096
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
1097
+ # HTTP header 'Accept' (if needed)
1098
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1099
+
1100
+ # form parameters
1101
+ form_params = opts[:form_params] || {}
1102
+
1103
+ # http body (model)
1104
+ post_body = opts[:debug_body]
1105
+
1106
+ # return_type
1107
+ return_type = opts[:debug_return_type] || 'ConversationMcpServersResponse'
1108
+
1109
+ # auth_names
1110
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
1111
+
1112
+ new_options = opts.merge(
1113
+ :operation => :"ConversationApi.get_agent_profile_mcps",
1114
+ :header_params => header_params,
1115
+ :query_params => query_params,
1116
+ :form_params => form_params,
1117
+ :body => post_body,
1118
+ :auth_names => auth_names,
1119
+ :return_type => return_type
1120
+ )
1121
+
1122
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
1123
+ if @api_client.config.debugging
1124
+ @api_client.config.logger.debug "API called: ConversationApi#get_agent_profile_mcps\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1125
+ end
1126
+ return data, status_code, headers
1127
+ end
1128
+
995
1129
  # Get agent profiles
996
1130
  # Retrieve the agents profile
997
1131
  # @param [Hash] opts the optional parameters
@@ -3744,6 +3878,81 @@ module UltracartClient
3744
3878
  return data, status_code, headers
3745
3879
  end
3746
3880
 
3881
+ # Insert an agent MCP server
3882
+ # Insert an agent MCP server
3883
+ # @param user_id [Integer]
3884
+ # @param mcp_server [ConversationMcpServer] MCP Server
3885
+ # @param [Hash] opts the optional parameters
3886
+ # @return [ConversationMcpServerResponse]
3887
+ def insert_agent_profile_mcp(user_id, mcp_server, opts = {})
3888
+ data, _status_code, _headers = insert_agent_profile_mcp_with_http_info(user_id, mcp_server, opts)
3889
+ data
3890
+ end
3891
+
3892
+ # Insert an agent MCP server
3893
+ # Insert an agent MCP server
3894
+ # @param user_id [Integer]
3895
+ # @param mcp_server [ConversationMcpServer] MCP Server
3896
+ # @param [Hash] opts the optional parameters
3897
+ # @return [Array<(ConversationMcpServerResponse, Integer, Hash)>] ConversationMcpServerResponse data, response status code and response headers
3898
+ def insert_agent_profile_mcp_with_http_info(user_id, mcp_server, opts = {})
3899
+ if @api_client.config.debugging
3900
+ @api_client.config.logger.debug 'Calling API: ConversationApi.insert_agent_profile_mcp ...'
3901
+ end
3902
+ # verify the required parameter 'user_id' is set
3903
+ if @api_client.config.client_side_validation && user_id.nil?
3904
+ fail ArgumentError, "Missing the required parameter 'user_id' when calling ConversationApi.insert_agent_profile_mcp"
3905
+ end
3906
+ # verify the required parameter 'mcp_server' is set
3907
+ if @api_client.config.client_side_validation && mcp_server.nil?
3908
+ fail ArgumentError, "Missing the required parameter 'mcp_server' when calling ConversationApi.insert_agent_profile_mcp"
3909
+ end
3910
+ # resource path
3911
+ local_var_path = '/conversation/agent/profiles/{user_id}/mcps'.sub('{' + 'user_id' + '}', CGI.escape(user_id.to_s))
3912
+
3913
+ # query parameters
3914
+ query_params = opts[:query_params] || {}
3915
+
3916
+ # header parameters
3917
+ header_params = opts[:header_params] || {}
3918
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
3919
+ # HTTP header 'Accept' (if needed)
3920
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
3921
+ # HTTP header 'Content-Type'
3922
+ content_type = @api_client.select_header_content_type(['application/json'])
3923
+ if !content_type.nil?
3924
+ header_params['Content-Type'] = content_type
3925
+ end
3926
+
3927
+ # form parameters
3928
+ form_params = opts[:form_params] || {}
3929
+
3930
+ # http body (model)
3931
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(mcp_server)
3932
+
3933
+ # return_type
3934
+ return_type = opts[:debug_return_type] || 'ConversationMcpServerResponse'
3935
+
3936
+ # auth_names
3937
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
3938
+
3939
+ new_options = opts.merge(
3940
+ :operation => :"ConversationApi.insert_agent_profile_mcp",
3941
+ :header_params => header_params,
3942
+ :query_params => query_params,
3943
+ :form_params => form_params,
3944
+ :body => post_body,
3945
+ :auth_names => auth_names,
3946
+ :return_type => return_type
3947
+ )
3948
+
3949
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
3950
+ if @api_client.config.debugging
3951
+ @api_client.config.logger.debug "API called: ConversationApi#insert_agent_profile_mcp\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
3952
+ end
3953
+ return data, status_code, headers
3954
+ end
3955
+
3747
3956
  # Insert a canned message
3748
3957
  # Insert a canned message
3749
3958
  # @param canned_message [ConversationCannedMessage] Canned message
@@ -5033,6 +5242,87 @@ module UltracartClient
5033
5242
  return data, status_code, headers
5034
5243
  end
5035
5244
 
5245
+ # Update an agent MCP server
5246
+ # Update an agent MCP server
5247
+ # @param user_id [Integer]
5248
+ # @param mcp_server_uuid [String]
5249
+ # @param mcp_server [ConversationMcpServer] MCP Server
5250
+ # @param [Hash] opts the optional parameters
5251
+ # @return [ConversationMcpServerResponse]
5252
+ def update_agent_profile_mcp(user_id, mcp_server_uuid, mcp_server, opts = {})
5253
+ data, _status_code, _headers = update_agent_profile_mcp_with_http_info(user_id, mcp_server_uuid, mcp_server, opts)
5254
+ data
5255
+ end
5256
+
5257
+ # Update an agent MCP server
5258
+ # Update an agent MCP server
5259
+ # @param user_id [Integer]
5260
+ # @param mcp_server_uuid [String]
5261
+ # @param mcp_server [ConversationMcpServer] MCP Server
5262
+ # @param [Hash] opts the optional parameters
5263
+ # @return [Array<(ConversationMcpServerResponse, Integer, Hash)>] ConversationMcpServerResponse data, response status code and response headers
5264
+ def update_agent_profile_mcp_with_http_info(user_id, mcp_server_uuid, mcp_server, opts = {})
5265
+ if @api_client.config.debugging
5266
+ @api_client.config.logger.debug 'Calling API: ConversationApi.update_agent_profile_mcp ...'
5267
+ end
5268
+ # verify the required parameter 'user_id' is set
5269
+ if @api_client.config.client_side_validation && user_id.nil?
5270
+ fail ArgumentError, "Missing the required parameter 'user_id' when calling ConversationApi.update_agent_profile_mcp"
5271
+ end
5272
+ # verify the required parameter 'mcp_server_uuid' is set
5273
+ if @api_client.config.client_side_validation && mcp_server_uuid.nil?
5274
+ fail ArgumentError, "Missing the required parameter 'mcp_server_uuid' when calling ConversationApi.update_agent_profile_mcp"
5275
+ end
5276
+ # verify the required parameter 'mcp_server' is set
5277
+ if @api_client.config.client_side_validation && mcp_server.nil?
5278
+ fail ArgumentError, "Missing the required parameter 'mcp_server' when calling ConversationApi.update_agent_profile_mcp"
5279
+ end
5280
+ # resource path
5281
+ local_var_path = '/conversation/agent/profiles/{user_id}/mcps/{mcp_server_uuid}'.sub('{' + 'user_id' + '}', CGI.escape(user_id.to_s)).sub('{' + 'mcp_server_uuid' + '}', CGI.escape(mcp_server_uuid.to_s))
5282
+
5283
+ # query parameters
5284
+ query_params = opts[:query_params] || {}
5285
+
5286
+ # header parameters
5287
+ header_params = opts[:header_params] || {}
5288
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
5289
+ # HTTP header 'Accept' (if needed)
5290
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
5291
+ # HTTP header 'Content-Type'
5292
+ content_type = @api_client.select_header_content_type(['application/json'])
5293
+ if !content_type.nil?
5294
+ header_params['Content-Type'] = content_type
5295
+ end
5296
+
5297
+ # form parameters
5298
+ form_params = opts[:form_params] || {}
5299
+
5300
+ # http body (model)
5301
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(mcp_server)
5302
+
5303
+ # return_type
5304
+ return_type = opts[:debug_return_type] || 'ConversationMcpServerResponse'
5305
+
5306
+ # auth_names
5307
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
5308
+
5309
+ new_options = opts.merge(
5310
+ :operation => :"ConversationApi.update_agent_profile_mcp",
5311
+ :header_params => header_params,
5312
+ :query_params => query_params,
5313
+ :form_params => form_params,
5314
+ :body => post_body,
5315
+ :auth_names => auth_names,
5316
+ :return_type => return_type
5317
+ )
5318
+
5319
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
5320
+ if @api_client.config.debugging
5321
+ @api_client.config.logger.debug "API called: ConversationApi#update_agent_profile_mcp\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
5322
+ end
5323
+ return data, status_code, headers
5324
+ end
5325
+
5036
5326
  # Update a canned message
5037
5327
  # Update a canned message
5038
5328
  # @param conversation_canned_message_oid [Integer]
@@ -0,0 +1,324 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module UltracartClient
17
+ class ConversationMcpServer
18
+ # Authorization Method
19
+ attr_accessor :auth_method
20
+
21
+ # Basic password
22
+ attr_accessor :basic_password
23
+
24
+ # Basic user name
25
+ attr_accessor :basic_user_name
26
+
27
+ # Header name
28
+ attr_accessor :header_name
29
+
30
+ # Header value
31
+ attr_accessor :header_value
32
+
33
+ # UUID of the MCP server configuration
34
+ attr_accessor :mcp_server_uuid
35
+
36
+ # Priority on which the MCP server tools are incorporated into the model. Lower number comes first
37
+ attr_accessor :priority
38
+
39
+ # URL to the MCP server (must be https)
40
+ attr_accessor :url
41
+
42
+ class EnumAttributeValidator
43
+ attr_reader :datatype
44
+ attr_reader :allowable_values
45
+
46
+ def initialize(datatype, allowable_values)
47
+ @allowable_values = allowable_values.map do |value|
48
+ case datatype.to_s
49
+ when /Integer/i
50
+ value.to_i
51
+ when /Float/i
52
+ value.to_f
53
+ else
54
+ value
55
+ end
56
+ end
57
+ end
58
+
59
+ def valid?(value)
60
+ !value || allowable_values.include?(value)
61
+ end
62
+ end
63
+
64
+ # Attribute mapping from ruby-style variable name to JSON key.
65
+ def self.attribute_map
66
+ {
67
+ :'auth_method' => :'auth_method',
68
+ :'basic_password' => :'basic_password',
69
+ :'basic_user_name' => :'basic_user_name',
70
+ :'header_name' => :'header_name',
71
+ :'header_value' => :'header_value',
72
+ :'mcp_server_uuid' => :'mcp_server_uuid',
73
+ :'priority' => :'priority',
74
+ :'url' => :'url'
75
+ }
76
+ end
77
+
78
+ # Returns all the JSON keys this model knows about
79
+ def self.acceptable_attributes
80
+ attribute_map.values
81
+ end
82
+
83
+ # Attribute type mapping.
84
+ def self.openapi_types
85
+ {
86
+ :'auth_method' => :'String',
87
+ :'basic_password' => :'String',
88
+ :'basic_user_name' => :'String',
89
+ :'header_name' => :'String',
90
+ :'header_value' => :'String',
91
+ :'mcp_server_uuid' => :'String',
92
+ :'priority' => :'Integer',
93
+ :'url' => :'String'
94
+ }
95
+ end
96
+
97
+ # List of attributes with nullable: true
98
+ def self.openapi_nullable
99
+ Set.new([
100
+ ])
101
+ end
102
+
103
+ # Initializes the object
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ def initialize(attributes = {})
106
+ if (!attributes.is_a?(Hash))
107
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::ConversationMcpServer` initialize method"
108
+ end
109
+
110
+ # check to see if the attribute exists and convert string to symbol for hash key
111
+ attributes = attributes.each_with_object({}) { |(k, v), h|
112
+ if (!self.class.attribute_map.key?(k.to_sym))
113
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::ConversationMcpServer`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
114
+ end
115
+ h[k.to_sym] = v
116
+ }
117
+
118
+ if attributes.key?(:'auth_method')
119
+ self.auth_method = attributes[:'auth_method']
120
+ end
121
+
122
+ if attributes.key?(:'basic_password')
123
+ self.basic_password = attributes[:'basic_password']
124
+ end
125
+
126
+ if attributes.key?(:'basic_user_name')
127
+ self.basic_user_name = attributes[:'basic_user_name']
128
+ end
129
+
130
+ if attributes.key?(:'header_name')
131
+ self.header_name = attributes[:'header_name']
132
+ end
133
+
134
+ if attributes.key?(:'header_value')
135
+ self.header_value = attributes[:'header_value']
136
+ end
137
+
138
+ if attributes.key?(:'mcp_server_uuid')
139
+ self.mcp_server_uuid = attributes[:'mcp_server_uuid']
140
+ end
141
+
142
+ if attributes.key?(:'priority')
143
+ self.priority = attributes[:'priority']
144
+ end
145
+
146
+ if attributes.key?(:'url')
147
+ self.url = attributes[:'url']
148
+ end
149
+ end
150
+
151
+ # Show invalid properties with the reasons. Usually used together with valid?
152
+ # @return Array for valid properties with the reasons
153
+ def list_invalid_properties
154
+ invalid_properties = Array.new
155
+ invalid_properties
156
+ end
157
+
158
+ # Check to see if the all the properties in the model are valid
159
+ # @return true if the model is valid
160
+ def valid?
161
+ auth_method_validator = EnumAttributeValidator.new('String', ["none", "header", "basic"])
162
+ return false unless auth_method_validator.valid?(@auth_method)
163
+ true
164
+ end
165
+
166
+ # Custom attribute writer method checking allowed values (enum).
167
+ # @param [Object] auth_method Object to be assigned
168
+ def auth_method=(auth_method)
169
+ validator = EnumAttributeValidator.new('String', ["none", "header", "basic"])
170
+ unless validator.valid?(auth_method)
171
+ fail ArgumentError, "invalid value for \"auth_method\", must be one of #{validator.allowable_values}."
172
+ end
173
+ @auth_method = auth_method
174
+ end
175
+
176
+ # Checks equality by comparing each attribute.
177
+ # @param [Object] Object to be compared
178
+ def ==(o)
179
+ return true if self.equal?(o)
180
+ self.class == o.class &&
181
+ auth_method == o.auth_method &&
182
+ basic_password == o.basic_password &&
183
+ basic_user_name == o.basic_user_name &&
184
+ header_name == o.header_name &&
185
+ header_value == o.header_value &&
186
+ mcp_server_uuid == o.mcp_server_uuid &&
187
+ priority == o.priority &&
188
+ url == o.url
189
+ end
190
+
191
+ # @see the `==` method
192
+ # @param [Object] Object to be compared
193
+ def eql?(o)
194
+ self == o
195
+ end
196
+
197
+ # Calculates hash code according to all attributes.
198
+ # @return [Integer] Hash code
199
+ def hash
200
+ [auth_method, basic_password, basic_user_name, header_name, header_value, mcp_server_uuid, priority, url].hash
201
+ end
202
+
203
+ # Builds the object from hash
204
+ # @param [Hash] attributes Model attributes in the form of hash
205
+ # @return [Object] Returns the model itself
206
+ def self.build_from_hash(attributes)
207
+ new.build_from_hash(attributes)
208
+ end
209
+
210
+ # Builds the object from hash
211
+ # @param [Hash] attributes Model attributes in the form of hash
212
+ # @return [Object] Returns the model itself
213
+ def build_from_hash(attributes)
214
+ return nil unless attributes.is_a?(Hash)
215
+ attributes = attributes.transform_keys(&:to_sym)
216
+ self.class.openapi_types.each_pair do |key, type|
217
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
218
+ self.send("#{key}=", nil)
219
+ elsif type =~ /\AArray<(.*)>/i
220
+ # check to ensure the input is an array given that the attribute
221
+ # is documented as an array but the input is not
222
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
223
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
224
+ end
225
+ elsif !attributes[self.class.attribute_map[key]].nil?
226
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
227
+ end
228
+ end
229
+
230
+ self
231
+ end
232
+
233
+ # Deserializes the data based on type
234
+ # @param string type Data type
235
+ # @param string value Value to be deserialized
236
+ # @return [Object] Deserialized data
237
+ def _deserialize(type, value)
238
+ case type.to_sym
239
+ when :Time
240
+ Time.parse(value)
241
+ when :Date
242
+ Date.parse(value)
243
+ when :String
244
+ value.to_s
245
+ when :Integer
246
+ value.to_i
247
+ when :Float
248
+ value.to_f
249
+ when :Boolean
250
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
251
+ true
252
+ else
253
+ false
254
+ end
255
+ when :Object
256
+ # generic object (usually a Hash), return directly
257
+ value
258
+ when /\AArray<(?<inner_type>.+)>\z/
259
+ inner_type = Regexp.last_match[:inner_type]
260
+ value.map { |v| _deserialize(inner_type, v) }
261
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
262
+ k_type = Regexp.last_match[:k_type]
263
+ v_type = Regexp.last_match[:v_type]
264
+ {}.tap do |hash|
265
+ value.each do |k, v|
266
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
267
+ end
268
+ end
269
+ else # model
270
+ # models (e.g. Pet) or oneOf
271
+ klass = UltracartClient.const_get(type)
272
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
273
+ end
274
+ end
275
+
276
+ # Returns the string representation of the object
277
+ # @return [String] String presentation of the object
278
+ def to_s
279
+ to_hash.to_s
280
+ end
281
+
282
+ # to_body is an alias to to_hash (backward compatibility)
283
+ # @return [Hash] Returns the object in the form of hash
284
+ def to_body
285
+ to_hash
286
+ end
287
+
288
+ # Returns the object in the form of hash
289
+ # @return [Hash] Returns the object in the form of hash
290
+ def to_hash
291
+ hash = {}
292
+ self.class.attribute_map.each_pair do |attr, param|
293
+ value = self.send(attr)
294
+ if value.nil?
295
+ is_nullable = self.class.openapi_nullable.include?(attr)
296
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
297
+ end
298
+
299
+ hash[param] = _to_hash(value)
300
+ end
301
+ hash
302
+ end
303
+
304
+ # Outputs non-array value in the form of hash
305
+ # For object, use to_hash. Otherwise, just return the value
306
+ # @param [Object] value Any valid value
307
+ # @return [Hash] Returns the value in the form of hash
308
+ def _to_hash(value)
309
+ if value.is_a?(Array)
310
+ value.compact.map { |v| _to_hash(v) }
311
+ elsif value.is_a?(Hash)
312
+ {}.tap do |hash|
313
+ value.each { |k, v| hash[k] = _to_hash(v) }
314
+ end
315
+ elsif value.respond_to? :to_hash
316
+ value.to_hash
317
+ else
318
+ value
319
+ end
320
+ end
321
+
322
+ end
323
+
324
+ end