ultracart_api 4.1.73 → 4.1.76

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.
@@ -0,0 +1,330 @@
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 'cgi'
14
+
15
+ module UltracartClient
16
+ class ConversationEmbedApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+
23
+ def self.new_using_api_key(simple_key, verify_ssl = true, debugging = false)
24
+ api_config = Configuration.new
25
+ api_config.api_key_prefix['x-ultracart-simple-key'] = simple_key
26
+ api_config.api_version = '2017-03-01'
27
+ api_config.verify_ssl = verify_ssl
28
+
29
+ api_client = ApiClient.new(api_config)
30
+ api_client.config.debugging = debugging
31
+
32
+ UltracartClient::ConversationEmbedApi.new(api_client)
33
+ end
34
+
35
+ # Initiate a device authorization flow for an embed widget.
36
+ # RFC 8628 device authorization. Only the embed widget's client_id and the crm_embed scope are accepted.
37
+ # @param client_id [String] The embed widget OAuth client_id.
38
+ # @param scope [String] The application-level scope (must be 'crm_embed').
39
+ # @param [Hash] opts the optional parameters
40
+ # @return [nil]
41
+ def embed_oauth_device_authorize(client_id, scope, opts = {})
42
+ embed_oauth_device_authorize_with_http_info(client_id, scope, opts)
43
+ nil
44
+ end
45
+
46
+ # Initiate a device authorization flow for an embed widget.
47
+ # RFC 8628 device authorization. Only the embed widget's client_id and the crm_embed scope are accepted.
48
+ # @param client_id [String] The embed widget OAuth client_id.
49
+ # @param scope [String] The application-level scope (must be 'crm_embed').
50
+ # @param [Hash] opts the optional parameters
51
+ # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
52
+ def embed_oauth_device_authorize_with_http_info(client_id, scope, opts = {})
53
+ if @api_client.config.debugging
54
+ @api_client.config.logger.debug 'Calling API: ConversationEmbedApi.embed_oauth_device_authorize ...'
55
+ end
56
+ # verify the required parameter 'client_id' is set
57
+ if @api_client.config.client_side_validation && client_id.nil?
58
+ fail ArgumentError, "Missing the required parameter 'client_id' when calling ConversationEmbedApi.embed_oauth_device_authorize"
59
+ end
60
+ # verify the required parameter 'scope' is set
61
+ if @api_client.config.client_side_validation && scope.nil?
62
+ fail ArgumentError, "Missing the required parameter 'scope' when calling ConversationEmbedApi.embed_oauth_device_authorize"
63
+ end
64
+ # resource path
65
+ local_var_path = '/conversation_embed/oauth/device/authorize'
66
+
67
+ # query parameters
68
+ query_params = opts[:query_params] || {}
69
+
70
+ # header parameters
71
+ header_params = opts[:header_params] || {}
72
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
73
+ # HTTP header 'Accept' (if needed)
74
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
75
+ # HTTP header 'Content-Type'
76
+ content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
77
+ if !content_type.nil?
78
+ header_params['Content-Type'] = content_type
79
+ end
80
+
81
+ # form parameters
82
+ form_params = opts[:form_params] || {}
83
+ form_params['client_id'] = client_id
84
+ form_params['scope'] = scope
85
+
86
+ # http body (model)
87
+ post_body = opts[:debug_body]
88
+
89
+ # return_type
90
+ return_type = opts[:debug_return_type]
91
+
92
+ # auth_names
93
+ auth_names = opts[:debug_auth_names] || ['ultraCartBrowserApiKey', 'ultraCartOauth', 'ultraCartSimpleApiKey']
94
+
95
+ new_options = opts.merge(
96
+ :operation => :"ConversationEmbedApi.embed_oauth_device_authorize",
97
+ :header_params => header_params,
98
+ :query_params => query_params,
99
+ :form_params => form_params,
100
+ :body => post_body,
101
+ :auth_names => auth_names,
102
+ :return_type => return_type
103
+ )
104
+
105
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
106
+ if @api_client.config.debugging
107
+ @api_client.config.logger.debug "API called: ConversationEmbedApi#embed_oauth_device_authorize\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
108
+ end
109
+ return data, status_code, headers
110
+ end
111
+
112
+ # Revoke an embed widget access or refresh token.
113
+ # RFC 7009 style — the token itself is proof of possession. Accepts either an access token or a refresh token in the 'token' parameter.
114
+ # @param client_id [String] The embed widget OAuth client_id.
115
+ # @param token [String] The token to revoke (access token or refresh token).
116
+ # @param [Hash] opts the optional parameters
117
+ # @return [nil]
118
+ def embed_oauth_revoke(client_id, token, opts = {})
119
+ embed_oauth_revoke_with_http_info(client_id, token, opts)
120
+ nil
121
+ end
122
+
123
+ # Revoke an embed widget access or refresh token.
124
+ # RFC 7009 style — the token itself is proof of possession. Accepts either an access token or a refresh token in the &#39;token&#39; parameter.
125
+ # @param client_id [String] The embed widget OAuth client_id.
126
+ # @param token [String] The token to revoke (access token or refresh token).
127
+ # @param [Hash] opts the optional parameters
128
+ # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
129
+ def embed_oauth_revoke_with_http_info(client_id, token, opts = {})
130
+ if @api_client.config.debugging
131
+ @api_client.config.logger.debug 'Calling API: ConversationEmbedApi.embed_oauth_revoke ...'
132
+ end
133
+ # verify the required parameter 'client_id' is set
134
+ if @api_client.config.client_side_validation && client_id.nil?
135
+ fail ArgumentError, "Missing the required parameter 'client_id' when calling ConversationEmbedApi.embed_oauth_revoke"
136
+ end
137
+ # verify the required parameter 'token' is set
138
+ if @api_client.config.client_side_validation && token.nil?
139
+ fail ArgumentError, "Missing the required parameter 'token' when calling ConversationEmbedApi.embed_oauth_revoke"
140
+ end
141
+ # resource path
142
+ local_var_path = '/conversation_embed/oauth/device/revoke'
143
+
144
+ # query parameters
145
+ query_params = opts[:query_params] || {}
146
+
147
+ # header parameters
148
+ header_params = opts[:header_params] || {}
149
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
150
+ # HTTP header 'Accept' (if needed)
151
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
152
+ # HTTP header 'Content-Type'
153
+ content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
154
+ if !content_type.nil?
155
+ header_params['Content-Type'] = content_type
156
+ end
157
+
158
+ # form parameters
159
+ form_params = opts[:form_params] || {}
160
+ form_params['client_id'] = client_id
161
+ form_params['token'] = token
162
+
163
+ # http body (model)
164
+ post_body = opts[:debug_body]
165
+
166
+ # return_type
167
+ return_type = opts[:debug_return_type]
168
+
169
+ # auth_names
170
+ auth_names = opts[:debug_auth_names] || ['ultraCartBrowserApiKey', 'ultraCartOauth', 'ultraCartSimpleApiKey']
171
+
172
+ new_options = opts.merge(
173
+ :operation => :"ConversationEmbedApi.embed_oauth_revoke",
174
+ :header_params => header_params,
175
+ :query_params => query_params,
176
+ :form_params => form_params,
177
+ :body => post_body,
178
+ :auth_names => auth_names,
179
+ :return_type => return_type
180
+ )
181
+
182
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
183
+ if @api_client.config.debugging
184
+ @api_client.config.logger.debug "API called: ConversationEmbedApi#embed_oauth_revoke\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
185
+ end
186
+ return data, status_code, headers
187
+ end
188
+
189
+ # Exchange a device_code or refresh_token for an access token (embed widget).
190
+ # Accepts grant_type=urn:ietf:params:oauth:grant-type:device_code or grant_type=refresh_token. Other grant types are rejected. Access tokens issued here expire in 60 minutes.
191
+ # @param client_id [String] The embed widget OAuth client_id.
192
+ # @param grant_type [String] Grant type.
193
+ # @param [Hash] opts the optional parameters
194
+ # @option opts [String] :device_code The device code received from /oauth/device/authorize (required for device_code grant).
195
+ # @option opts [String] :refresh_token The refresh token (required for refresh_token grant).
196
+ # @return [nil]
197
+ def embed_oauth_token(client_id, grant_type, opts = {})
198
+ embed_oauth_token_with_http_info(client_id, grant_type, opts)
199
+ nil
200
+ end
201
+
202
+ # Exchange a device_code or refresh_token for an access token (embed widget).
203
+ # Accepts grant_type&#x3D;urn:ietf:params:oauth:grant-type:device_code or grant_type&#x3D;refresh_token. Other grant types are rejected. Access tokens issued here expire in 60 minutes.
204
+ # @param client_id [String] The embed widget OAuth client_id.
205
+ # @param grant_type [String] Grant type.
206
+ # @param [Hash] opts the optional parameters
207
+ # @option opts [String] :device_code The device code received from /oauth/device/authorize (required for device_code grant).
208
+ # @option opts [String] :refresh_token The refresh token (required for refresh_token grant).
209
+ # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
210
+ def embed_oauth_token_with_http_info(client_id, grant_type, opts = {})
211
+ if @api_client.config.debugging
212
+ @api_client.config.logger.debug 'Calling API: ConversationEmbedApi.embed_oauth_token ...'
213
+ end
214
+ # verify the required parameter 'client_id' is set
215
+ if @api_client.config.client_side_validation && client_id.nil?
216
+ fail ArgumentError, "Missing the required parameter 'client_id' when calling ConversationEmbedApi.embed_oauth_token"
217
+ end
218
+ # verify the required parameter 'grant_type' is set
219
+ if @api_client.config.client_side_validation && grant_type.nil?
220
+ fail ArgumentError, "Missing the required parameter 'grant_type' when calling ConversationEmbedApi.embed_oauth_token"
221
+ end
222
+ # resource path
223
+ local_var_path = '/conversation_embed/oauth/device/token'
224
+
225
+ # query parameters
226
+ query_params = opts[:query_params] || {}
227
+
228
+ # header parameters
229
+ header_params = opts[:header_params] || {}
230
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
231
+ # HTTP header 'Accept' (if needed)
232
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
233
+ # HTTP header 'Content-Type'
234
+ content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
235
+ if !content_type.nil?
236
+ header_params['Content-Type'] = content_type
237
+ end
238
+
239
+ # form parameters
240
+ form_params = opts[:form_params] || {}
241
+ form_params['client_id'] = client_id
242
+ form_params['grant_type'] = grant_type
243
+ form_params['device_code'] = opts[:'device_code'] if !opts[:'device_code'].nil?
244
+ form_params['refresh_token'] = opts[:'refresh_token'] if !opts[:'refresh_token'].nil?
245
+
246
+ # http body (model)
247
+ post_body = opts[:debug_body]
248
+
249
+ # return_type
250
+ return_type = opts[:debug_return_type]
251
+
252
+ # auth_names
253
+ auth_names = opts[:debug_auth_names] || ['ultraCartBrowserApiKey', 'ultraCartOauth', 'ultraCartSimpleApiKey']
254
+
255
+ new_options = opts.merge(
256
+ :operation => :"ConversationEmbedApi.embed_oauth_token",
257
+ :header_params => header_params,
258
+ :query_params => query_params,
259
+ :form_params => form_params,
260
+ :body => post_body,
261
+ :auth_names => auth_names,
262
+ :return_type => return_type
263
+ )
264
+
265
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
266
+ if @api_client.config.debugging
267
+ @api_client.config.logger.debug "API called: ConversationEmbedApi#embed_oauth_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
268
+ end
269
+ return data, status_code, headers
270
+ end
271
+
272
+ # Get PBX authorization for the embedded softphone widget.
273
+ # Returns a narrow subset of agent auth fields — only what the softphone widget needs to connect to the PBX relay. Twilio tokens, conversation JWTs, and chat/customer permissions are intentionally excluded.
274
+ # @param [Hash] opts the optional parameters
275
+ # @return [ConversationEmbedPbxAuthResponse]
276
+ def get_embed_pbx_auth(opts = {})
277
+ data, _status_code, _headers = get_embed_pbx_auth_with_http_info(opts)
278
+ data
279
+ end
280
+
281
+ # Get PBX authorization for the embedded softphone widget.
282
+ # Returns a narrow subset of agent auth fields — only what the softphone widget needs to connect to the PBX relay. Twilio tokens, conversation JWTs, and chat/customer permissions are intentionally excluded.
283
+ # @param [Hash] opts the optional parameters
284
+ # @return [Array<(ConversationEmbedPbxAuthResponse, Integer, Hash)>] ConversationEmbedPbxAuthResponse data, response status code and response headers
285
+ def get_embed_pbx_auth_with_http_info(opts = {})
286
+ if @api_client.config.debugging
287
+ @api_client.config.logger.debug 'Calling API: ConversationEmbedApi.get_embed_pbx_auth ...'
288
+ end
289
+ # resource path
290
+ local_var_path = '/conversation_embed/pbx-auth'
291
+
292
+ # query parameters
293
+ query_params = opts[:query_params] || {}
294
+
295
+ # header parameters
296
+ header_params = opts[:header_params] || {}
297
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
298
+ # HTTP header 'Accept' (if needed)
299
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
300
+
301
+ # form parameters
302
+ form_params = opts[:form_params] || {}
303
+
304
+ # http body (model)
305
+ post_body = opts[:debug_body]
306
+
307
+ # return_type
308
+ return_type = opts[:debug_return_type] || 'ConversationEmbedPbxAuthResponse'
309
+
310
+ # auth_names
311
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth']
312
+
313
+ new_options = opts.merge(
314
+ :operation => :"ConversationEmbedApi.get_embed_pbx_auth",
315
+ :header_params => header_params,
316
+ :query_params => query_params,
317
+ :form_params => form_params,
318
+ :body => post_body,
319
+ :auth_names => auth_names,
320
+ :return_type => return_type
321
+ )
322
+
323
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
324
+ if @api_client.config.debugging
325
+ @api_client.config.logger.debug "API called: ConversationEmbedApi#get_embed_pbx_auth\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
326
+ end
327
+ return data, status_code, headers
328
+ end
329
+ end
330
+ end
@@ -0,0 +1,264 @@
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 AutoOrderItemCancelRequest
18
+ # Optional tiebreaker when more than one item on the auto order shares the same original_item_id. When present, the item with this oid is targeted and its original_item_id must match the URL path parameter (safety check). Leave unset for the common case of a unique original_item_id.
19
+ attr_accessor :auto_order_item_oid
20
+
21
+ # Cancellation mode. 'end' soft-cancels the item by setting no_order_after_dts to the current time, preserving the row for reporting. 'remove' hard-deletes the item from the auto order. Defaults to 'end' (the less destructive option) when omitted.
22
+ attr_accessor :mode
23
+
24
+ class EnumAttributeValidator
25
+ attr_reader :datatype
26
+ attr_reader :allowable_values
27
+
28
+ def initialize(datatype, allowable_values)
29
+ @allowable_values = allowable_values.map do |value|
30
+ case datatype.to_s
31
+ when /Integer/i
32
+ value.to_i
33
+ when /Float/i
34
+ value.to_f
35
+ else
36
+ value
37
+ end
38
+ end
39
+ end
40
+
41
+ def valid?(value)
42
+ !value || allowable_values.include?(value)
43
+ end
44
+ end
45
+
46
+ # Attribute mapping from ruby-style variable name to JSON key.
47
+ def self.attribute_map
48
+ {
49
+ :'auto_order_item_oid' => :'auto_order_item_oid',
50
+ :'mode' => :'mode'
51
+ }
52
+ end
53
+
54
+ # Returns all the JSON keys this model knows about
55
+ def self.acceptable_attributes
56
+ attribute_map.values
57
+ end
58
+
59
+ # Attribute type mapping.
60
+ def self.openapi_types
61
+ {
62
+ :'auto_order_item_oid' => :'Integer',
63
+ :'mode' => :'String'
64
+ }
65
+ end
66
+
67
+ # List of attributes with nullable: true
68
+ def self.openapi_nullable
69
+ Set.new([
70
+ ])
71
+ end
72
+
73
+ # Initializes the object
74
+ # @param [Hash] attributes Model attributes in the form of hash
75
+ def initialize(attributes = {})
76
+ if (!attributes.is_a?(Hash))
77
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::AutoOrderItemCancelRequest` initialize method"
78
+ end
79
+
80
+ # check to see if the attribute exists and convert string to symbol for hash key
81
+ attributes = attributes.each_with_object({}) { |(k, v), h|
82
+ if (!self.class.attribute_map.key?(k.to_sym))
83
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::AutoOrderItemCancelRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
84
+ end
85
+ h[k.to_sym] = v
86
+ }
87
+
88
+ if attributes.key?(:'auto_order_item_oid')
89
+ self.auto_order_item_oid = attributes[:'auto_order_item_oid']
90
+ end
91
+
92
+ if attributes.key?(:'mode')
93
+ self.mode = attributes[:'mode']
94
+ end
95
+ end
96
+
97
+ # Show invalid properties with the reasons. Usually used together with valid?
98
+ # @return Array for valid properties with the reasons
99
+ def list_invalid_properties
100
+ invalid_properties = Array.new
101
+ invalid_properties
102
+ end
103
+
104
+ # Check to see if the all the properties in the model are valid
105
+ # @return true if the model is valid
106
+ def valid?
107
+ mode_validator = EnumAttributeValidator.new('String', ["end", "remove"])
108
+ return false unless mode_validator.valid?(@mode)
109
+ true
110
+ end
111
+
112
+ # Custom attribute writer method checking allowed values (enum).
113
+ # @param [Object] mode Object to be assigned
114
+ def mode=(mode)
115
+ validator = EnumAttributeValidator.new('String', ["end", "remove"])
116
+ unless validator.valid?(mode)
117
+ fail ArgumentError, "invalid value for \"mode\", must be one of #{validator.allowable_values}."
118
+ end
119
+ @mode = mode
120
+ end
121
+
122
+ # Checks equality by comparing each attribute.
123
+ # @param [Object] Object to be compared
124
+ def ==(o)
125
+ return true if self.equal?(o)
126
+ self.class == o.class &&
127
+ auto_order_item_oid == o.auto_order_item_oid &&
128
+ mode == o.mode
129
+ end
130
+
131
+ # @see the `==` method
132
+ # @param [Object] Object to be compared
133
+ def eql?(o)
134
+ self == o
135
+ end
136
+
137
+ # Calculates hash code according to all attributes.
138
+ # @return [Integer] Hash code
139
+ def hash
140
+ [auto_order_item_oid, mode].hash
141
+ end
142
+
143
+ # Builds the object from hash
144
+ # @param [Hash] attributes Model attributes in the form of hash
145
+ # @return [Object] Returns the model itself
146
+ def self.build_from_hash(attributes)
147
+ new.build_from_hash(attributes)
148
+ end
149
+
150
+ # Builds the object from hash
151
+ # @param [Hash] attributes Model attributes in the form of hash
152
+ # @return [Object] Returns the model itself
153
+ def build_from_hash(attributes)
154
+ return nil unless attributes.is_a?(Hash)
155
+ attributes = attributes.transform_keys(&:to_sym)
156
+ self.class.openapi_types.each_pair do |key, type|
157
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
158
+ self.send("#{key}=", nil)
159
+ elsif type =~ /\AArray<(.*)>/i
160
+ # check to ensure the input is an array given that the attribute
161
+ # is documented as an array but the input is not
162
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
163
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
164
+ end
165
+ elsif !attributes[self.class.attribute_map[key]].nil?
166
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
167
+ end
168
+ end
169
+
170
+ self
171
+ end
172
+
173
+ # Deserializes the data based on type
174
+ # @param string type Data type
175
+ # @param string value Value to be deserialized
176
+ # @return [Object] Deserialized data
177
+ def _deserialize(type, value)
178
+ case type.to_sym
179
+ when :Time
180
+ Time.parse(value)
181
+ when :Date
182
+ Date.parse(value)
183
+ when :String
184
+ value.to_s
185
+ when :Integer
186
+ value.to_i
187
+ when :Float
188
+ value.to_f
189
+ when :Boolean
190
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
191
+ true
192
+ else
193
+ false
194
+ end
195
+ when :Object
196
+ # generic object (usually a Hash), return directly
197
+ value
198
+ when /\AArray<(?<inner_type>.+)>\z/
199
+ inner_type = Regexp.last_match[:inner_type]
200
+ value.map { |v| _deserialize(inner_type, v) }
201
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
202
+ k_type = Regexp.last_match[:k_type]
203
+ v_type = Regexp.last_match[:v_type]
204
+ {}.tap do |hash|
205
+ value.each do |k, v|
206
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
207
+ end
208
+ end
209
+ else # model
210
+ # models (e.g. Pet) or oneOf
211
+ klass = UltracartClient.const_get(type)
212
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
213
+ end
214
+ end
215
+
216
+ # Returns the string representation of the object
217
+ # @return [String] String presentation of the object
218
+ def to_s
219
+ to_hash.to_s
220
+ end
221
+
222
+ # to_body is an alias to to_hash (backward compatibility)
223
+ # @return [Hash] Returns the object in the form of hash
224
+ def to_body
225
+ to_hash
226
+ end
227
+
228
+ # Returns the object in the form of hash
229
+ # @return [Hash] Returns the object in the form of hash
230
+ def to_hash
231
+ hash = {}
232
+ self.class.attribute_map.each_pair do |attr, param|
233
+ value = self.send(attr)
234
+ if value.nil?
235
+ is_nullable = self.class.openapi_nullable.include?(attr)
236
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
237
+ end
238
+
239
+ hash[param] = _to_hash(value)
240
+ end
241
+ hash
242
+ end
243
+
244
+ # Outputs non-array value in the form of hash
245
+ # For object, use to_hash. Otherwise, just return the value
246
+ # @param [Object] value Any valid value
247
+ # @return [Hash] Returns the value in the form of hash
248
+ def _to_hash(value)
249
+ if value.is_a?(Array)
250
+ value.compact.map { |v| _to_hash(v) }
251
+ elsif value.is_a?(Hash)
252
+ {}.tap do |hash|
253
+ value.each { |k, v| hash[k] = _to_hash(v) }
254
+ end
255
+ elsif value.respond_to? :to_hash
256
+ value.to_hash
257
+ else
258
+ value
259
+ end
260
+ end
261
+
262
+ end
263
+
264
+ end