ultracart_api 3.10.79 → 3.10.80

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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -4
  3. data/docs/ConversationApi.md +308 -2
  4. data/docs/ConversationCannedMessage.md +1 -1
  5. data/docs/ConversationDepartment.md +12 -0
  6. data/docs/ConversationDepartmentResponse.md +12 -0
  7. data/docs/ConversationDepartmentSettings.md +7 -0
  8. data/docs/ConversationDepartmentsResponse.md +12 -0
  9. data/docs/ConversationEngagement.md +14 -0
  10. data/docs/ConversationEngagementEquation.md +7 -0
  11. data/docs/ConversationEngagementResponse.md +12 -0
  12. data/docs/ConversationEngagementsResponse.md +12 -0
  13. data/docs/ConversationJoinRequest.md +8 -0
  14. data/docs/ConversationParticipant.md +2 -0
  15. data/docs/ConversationWebchatQueueStatusQueueEntry.md +1 -0
  16. data/lib/ultracart_api/api/conversation_api.rb +333 -1
  17. data/lib/ultracart_api/models/conversation_canned_message.rb +1 -1
  18. data/lib/ultracart_api/models/conversation_department.rb +220 -0
  19. data/lib/ultracart_api/models/conversation_department_response.rb +221 -0
  20. data/lib/ultracart_api/models/conversation_department_settings.rb +175 -0
  21. data/lib/ultracart_api/models/conversation_departments_response.rb +223 -0
  22. data/lib/ultracart_api/models/conversation_engagement.rb +240 -0
  23. data/lib/ultracart_api/models/conversation_engagement_equation.rb +175 -0
  24. data/lib/ultracart_api/models/conversation_engagement_response.rb +221 -0
  25. data/lib/ultracart_api/models/conversation_engagements_response.rb +223 -0
  26. data/lib/ultracart_api/models/conversation_join_request.rb +184 -0
  27. data/lib/ultracart_api/models/conversation_participant.rb +19 -1
  28. data/lib/ultracart_api/models/conversation_webchat_queue_status_queue_entry.rb +10 -1
  29. data/lib/ultracart_api/version.rb +1 -1
  30. data/lib/ultracart_api.rb +9 -0
  31. metadata +20 -2
@@ -291,6 +291,104 @@ module UltracartClient
291
291
  end
292
292
  return data, status_code, headers
293
293
  end
294
+ # Retrieve a list of departments ordered by name
295
+ # Retrieve a list of departments ordered by name
296
+ # @param [Hash] opts the optional parameters
297
+ # @return [ConversationDepartmentsResponse]
298
+ def get_conversation_departments(opts = {})
299
+ data, _status_code, _headers = get_conversation_departments_with_http_info(opts)
300
+ data
301
+ end
302
+
303
+ # Retrieve a list of departments ordered by name
304
+ # Retrieve a list of departments ordered by name
305
+ # @param [Hash] opts the optional parameters
306
+ # @return [Array<(ConversationDepartmentsResponse, Fixnum, Hash)>] ConversationDepartmentsResponse data, response status code and response headers
307
+ def get_conversation_departments_with_http_info(opts = {})
308
+ if @api_client.config.debugging
309
+ @api_client.config.logger.debug 'Calling API: ConversationApi.get_conversation_departments ...'
310
+ end
311
+ # resource path
312
+ local_var_path = '/conversation/departments'
313
+
314
+ # query parameters
315
+ query_params = {}
316
+
317
+ # header parameters
318
+ header_params = {}
319
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
320
+ # HTTP header 'Accept' (if needed)
321
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
322
+ # HTTP header 'Content-Type'
323
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
324
+
325
+ # form parameters
326
+ form_params = {}
327
+
328
+ # http body (model)
329
+ post_body = nil
330
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
331
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
332
+ :header_params => header_params,
333
+ :query_params => query_params,
334
+ :form_params => form_params,
335
+ :body => post_body,
336
+ :auth_names => auth_names,
337
+ :return_type => 'ConversationDepartmentsResponse')
338
+ if @api_client.config.debugging
339
+ @api_client.config.logger.debug "API called: ConversationApi#get_conversation_departments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
340
+ end
341
+ return data, status_code, headers
342
+ end
343
+ # Retrieve a list of engagements ordered by name
344
+ # Retrieve a list of engagements ordered by name
345
+ # @param [Hash] opts the optional parameters
346
+ # @return [ConversationEngagementsResponse]
347
+ def get_conversation_engagements(opts = {})
348
+ data, _status_code, _headers = get_conversation_engagements_with_http_info(opts)
349
+ data
350
+ end
351
+
352
+ # Retrieve a list of engagements ordered by name
353
+ # Retrieve a list of engagements ordered by name
354
+ # @param [Hash] opts the optional parameters
355
+ # @return [Array<(ConversationEngagementsResponse, Fixnum, Hash)>] ConversationEngagementsResponse data, response status code and response headers
356
+ def get_conversation_engagements_with_http_info(opts = {})
357
+ if @api_client.config.debugging
358
+ @api_client.config.logger.debug 'Calling API: ConversationApi.get_conversation_engagements ...'
359
+ end
360
+ # resource path
361
+ local_var_path = '/conversation/engagements'
362
+
363
+ # query parameters
364
+ query_params = {}
365
+
366
+ # header parameters
367
+ header_params = {}
368
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
369
+ # HTTP header 'Accept' (if needed)
370
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
371
+ # HTTP header 'Content-Type'
372
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
373
+
374
+ # form parameters
375
+ form_params = {}
376
+
377
+ # http body (model)
378
+ post_body = nil
379
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
380
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
381
+ :header_params => header_params,
382
+ :query_params => query_params,
383
+ :form_params => form_params,
384
+ :body => post_body,
385
+ :auth_names => auth_names,
386
+ :return_type => 'ConversationEngagementsResponse')
387
+ if @api_client.config.debugging
388
+ @api_client.config.logger.debug "API called: ConversationApi#get_conversation_engagements\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
389
+ end
390
+ return data, status_code, headers
391
+ end
294
392
  # Retrieve conversation messages
295
393
  # Retrieve conversation messages since a particular time
296
394
  # @param conversation_uuid
@@ -575,10 +673,121 @@ module UltracartClient
575
673
  end
576
674
  return data, status_code, headers
577
675
  end
676
+ # Insert a department
677
+ # Insert a department
678
+ # @param department Department
679
+ # @param [Hash] opts the optional parameters
680
+ # @return [ConversationDepartmentResponse]
681
+ def insert_conversation_department(department, opts = {})
682
+ data, _status_code, _headers = insert_conversation_department_with_http_info(department, opts)
683
+ data
684
+ end
685
+
686
+ # Insert a department
687
+ # Insert a department
688
+ # @param department Department
689
+ # @param [Hash] opts the optional parameters
690
+ # @return [Array<(ConversationDepartmentResponse, Fixnum, Hash)>] ConversationDepartmentResponse data, response status code and response headers
691
+ def insert_conversation_department_with_http_info(department, opts = {})
692
+ if @api_client.config.debugging
693
+ @api_client.config.logger.debug 'Calling API: ConversationApi.insert_conversation_department ...'
694
+ end
695
+ # verify the required parameter 'department' is set
696
+ if @api_client.config.client_side_validation && department.nil?
697
+ fail ArgumentError, "Missing the required parameter 'department' when calling ConversationApi.insert_conversation_department"
698
+ end
699
+ # resource path
700
+ local_var_path = '/conversation/departments'
701
+
702
+ # query parameters
703
+ query_params = {}
704
+
705
+ # header parameters
706
+ header_params = {}
707
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
708
+ # HTTP header 'Accept' (if needed)
709
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
710
+ # HTTP header 'Content-Type'
711
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
712
+
713
+ # form parameters
714
+ form_params = {}
715
+
716
+ # http body (model)
717
+ post_body = @api_client.object_to_http_body(department)
718
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
719
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
720
+ :header_params => header_params,
721
+ :query_params => query_params,
722
+ :form_params => form_params,
723
+ :body => post_body,
724
+ :auth_names => auth_names,
725
+ :return_type => 'ConversationDepartmentResponse')
726
+ if @api_client.config.debugging
727
+ @api_client.config.logger.debug "API called: ConversationApi#insert_conversation_department\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
728
+ end
729
+ return data, status_code, headers
730
+ end
731
+ # Insert a engagement
732
+ # Insert a engagement
733
+ # @param engagement Engagement
734
+ # @param [Hash] opts the optional parameters
735
+ # @return [ConversationEngagementResponse]
736
+ def insert_conversation_engagement(engagement, opts = {})
737
+ data, _status_code, _headers = insert_conversation_engagement_with_http_info(engagement, opts)
738
+ data
739
+ end
740
+
741
+ # Insert a engagement
742
+ # Insert a engagement
743
+ # @param engagement Engagement
744
+ # @param [Hash] opts the optional parameters
745
+ # @return [Array<(ConversationEngagementResponse, Fixnum, Hash)>] ConversationEngagementResponse data, response status code and response headers
746
+ def insert_conversation_engagement_with_http_info(engagement, opts = {})
747
+ if @api_client.config.debugging
748
+ @api_client.config.logger.debug 'Calling API: ConversationApi.insert_conversation_engagement ...'
749
+ end
750
+ # verify the required parameter 'engagement' is set
751
+ if @api_client.config.client_side_validation && engagement.nil?
752
+ fail ArgumentError, "Missing the required parameter 'engagement' when calling ConversationApi.insert_conversation_engagement"
753
+ end
754
+ # resource path
755
+ local_var_path = '/conversation/engagements'
756
+
757
+ # query parameters
758
+ query_params = {}
759
+
760
+ # header parameters
761
+ header_params = {}
762
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
763
+ # HTTP header 'Accept' (if needed)
764
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
765
+ # HTTP header 'Content-Type'
766
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
767
+
768
+ # form parameters
769
+ form_params = {}
770
+
771
+ # http body (model)
772
+ post_body = @api_client.object_to_http_body(engagement)
773
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
774
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
775
+ :header_params => header_params,
776
+ :query_params => query_params,
777
+ :form_params => form_params,
778
+ :body => post_body,
779
+ :auth_names => auth_names,
780
+ :return_type => 'ConversationEngagementResponse')
781
+ if @api_client.config.debugging
782
+ @api_client.config.logger.debug "API called: ConversationApi#insert_conversation_engagement\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
783
+ end
784
+ return data, status_code, headers
785
+ end
578
786
  # Join a conversation
579
787
  # Join a conversation
580
788
  # @param conversation_uuid
581
789
  # @param [Hash] opts the optional parameters
790
+ # @option opts [ConversationJoinRequest] :join_request Join request
582
791
  # @return [nil]
583
792
  def join_conversation(conversation_uuid, opts = {})
584
793
  join_conversation_with_http_info(conversation_uuid, opts)
@@ -589,6 +798,7 @@ module UltracartClient
589
798
  # Join a conversation
590
799
  # @param conversation_uuid
591
800
  # @param [Hash] opts the optional parameters
801
+ # @option opts [ConversationJoinRequest] :join_request Join request
592
802
  # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
593
803
  def join_conversation_with_http_info(conversation_uuid, opts = {})
594
804
  if @api_client.config.debugging
@@ -616,7 +826,7 @@ module UltracartClient
616
826
  form_params = {}
617
827
 
618
828
  # http body (model)
619
- post_body = nil
829
+ post_body = @api_client.object_to_http_body(opts[:'join_request'])
620
830
  auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
621
831
  data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
622
832
  :header_params => header_params,
@@ -908,6 +1118,128 @@ module UltracartClient
908
1118
  end
909
1119
  return data, status_code, headers
910
1120
  end
1121
+ # Update a department
1122
+ # Update a department
1123
+ # @param conversation_department_oid
1124
+ # @param department Department
1125
+ # @param [Hash] opts the optional parameters
1126
+ # @return [ConversationDepartmentResponse]
1127
+ def update_conversation_department(conversation_department_oid, department, opts = {})
1128
+ data, _status_code, _headers = update_conversation_department_with_http_info(conversation_department_oid, department, opts)
1129
+ data
1130
+ end
1131
+
1132
+ # Update a department
1133
+ # Update a department
1134
+ # @param conversation_department_oid
1135
+ # @param department Department
1136
+ # @param [Hash] opts the optional parameters
1137
+ # @return [Array<(ConversationDepartmentResponse, Fixnum, Hash)>] ConversationDepartmentResponse data, response status code and response headers
1138
+ def update_conversation_department_with_http_info(conversation_department_oid, department, opts = {})
1139
+ if @api_client.config.debugging
1140
+ @api_client.config.logger.debug 'Calling API: ConversationApi.update_conversation_department ...'
1141
+ end
1142
+ # verify the required parameter 'conversation_department_oid' is set
1143
+ if @api_client.config.client_side_validation && conversation_department_oid.nil?
1144
+ fail ArgumentError, "Missing the required parameter 'conversation_department_oid' when calling ConversationApi.update_conversation_department"
1145
+ end
1146
+ # verify the required parameter 'department' is set
1147
+ if @api_client.config.client_side_validation && department.nil?
1148
+ fail ArgumentError, "Missing the required parameter 'department' when calling ConversationApi.update_conversation_department"
1149
+ end
1150
+ # resource path
1151
+ local_var_path = '/conversation/departments/{conversation_department_oid}'.sub('{' + 'conversation_department_oid' + '}', conversation_department_oid.to_s)
1152
+
1153
+ # query parameters
1154
+ query_params = {}
1155
+
1156
+ # header parameters
1157
+ header_params = {}
1158
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
1159
+ # HTTP header 'Accept' (if needed)
1160
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1161
+ # HTTP header 'Content-Type'
1162
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
1163
+
1164
+ # form parameters
1165
+ form_params = {}
1166
+
1167
+ # http body (model)
1168
+ post_body = @api_client.object_to_http_body(department)
1169
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
1170
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
1171
+ :header_params => header_params,
1172
+ :query_params => query_params,
1173
+ :form_params => form_params,
1174
+ :body => post_body,
1175
+ :auth_names => auth_names,
1176
+ :return_type => 'ConversationDepartmentResponse')
1177
+ if @api_client.config.debugging
1178
+ @api_client.config.logger.debug "API called: ConversationApi#update_conversation_department\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1179
+ end
1180
+ return data, status_code, headers
1181
+ end
1182
+ # Update a engagement
1183
+ # Update a engagement
1184
+ # @param conversation_engagement_oid
1185
+ # @param engagement Engagement
1186
+ # @param [Hash] opts the optional parameters
1187
+ # @return [ConversationEngagementResponse]
1188
+ def update_conversation_engagement(conversation_engagement_oid, engagement, opts = {})
1189
+ data, _status_code, _headers = update_conversation_engagement_with_http_info(conversation_engagement_oid, engagement, opts)
1190
+ data
1191
+ end
1192
+
1193
+ # Update a engagement
1194
+ # Update a engagement
1195
+ # @param conversation_engagement_oid
1196
+ # @param engagement Engagement
1197
+ # @param [Hash] opts the optional parameters
1198
+ # @return [Array<(ConversationEngagementResponse, Fixnum, Hash)>] ConversationEngagementResponse data, response status code and response headers
1199
+ def update_conversation_engagement_with_http_info(conversation_engagement_oid, engagement, opts = {})
1200
+ if @api_client.config.debugging
1201
+ @api_client.config.logger.debug 'Calling API: ConversationApi.update_conversation_engagement ...'
1202
+ end
1203
+ # verify the required parameter 'conversation_engagement_oid' is set
1204
+ if @api_client.config.client_side_validation && conversation_engagement_oid.nil?
1205
+ fail ArgumentError, "Missing the required parameter 'conversation_engagement_oid' when calling ConversationApi.update_conversation_engagement"
1206
+ end
1207
+ # verify the required parameter 'engagement' is set
1208
+ if @api_client.config.client_side_validation && engagement.nil?
1209
+ fail ArgumentError, "Missing the required parameter 'engagement' when calling ConversationApi.update_conversation_engagement"
1210
+ end
1211
+ # resource path
1212
+ local_var_path = '/conversation/engagements/{conversation_engagement_oid}'.sub('{' + 'conversation_engagement_oid' + '}', conversation_engagement_oid.to_s)
1213
+
1214
+ # query parameters
1215
+ query_params = {}
1216
+
1217
+ # header parameters
1218
+ header_params = {}
1219
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
1220
+ # HTTP header 'Accept' (if needed)
1221
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1222
+ # HTTP header 'Content-Type'
1223
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
1224
+
1225
+ # form parameters
1226
+ form_params = {}
1227
+
1228
+ # http body (model)
1229
+ post_body = @api_client.object_to_http_body(engagement)
1230
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
1231
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
1232
+ :header_params => header_params,
1233
+ :query_params => query_params,
1234
+ :form_params => form_params,
1235
+ :body => post_body,
1236
+ :auth_names => auth_names,
1237
+ :return_type => 'ConversationEngagementResponse')
1238
+ if @api_client.config.debugging
1239
+ @api_client.config.logger.debug "API called: ConversationApi#update_conversation_engagement\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1240
+ end
1241
+ return data, status_code, headers
1242
+ end
911
1243
  # Update status within the queue
912
1244
  # Update status within the queue
913
1245
  # @param queue_name
@@ -37,7 +37,7 @@ module UltracartClient
37
37
  {
38
38
  :'canned_message' => :'String',
39
39
  :'conversation_canned_message_oid' => :'Integer',
40
- :'conversation_department_oids' => :'Array<String>',
40
+ :'conversation_department_oids' => :'Array<Integer>',
41
41
  :'short_code' => :'String'
42
42
  }
43
43
  end
@@ -0,0 +1,220 @@
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 ConversationDepartment
17
+ attr_accessor :conversation_department_oid
18
+
19
+ attr_accessor :delete_me
20
+
21
+ attr_accessor :department_name
22
+
23
+ attr_accessor :merchant_id
24
+
25
+ attr_accessor :settings
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'conversation_department_oid' => :'conversation_department_oid',
31
+ :'delete_me' => :'delete_me',
32
+ :'department_name' => :'department_name',
33
+ :'merchant_id' => :'merchant_id',
34
+ :'settings' => :'settings'
35
+ }
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.swagger_types
40
+ {
41
+ :'conversation_department_oid' => :'Integer',
42
+ :'delete_me' => :'BOOLEAN',
43
+ :'department_name' => :'String',
44
+ :'merchant_id' => :'String',
45
+ :'settings' => :'ConversationDepartmentSettings'
46
+ }
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ return unless attributes.is_a?(Hash)
53
+
54
+ # convert string to symbol for hash key
55
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
56
+
57
+ if attributes.has_key?(:'conversation_department_oid')
58
+ self.conversation_department_oid = attributes[:'conversation_department_oid']
59
+ end
60
+
61
+ if attributes.has_key?(:'delete_me')
62
+ self.delete_me = attributes[:'delete_me']
63
+ end
64
+
65
+ if attributes.has_key?(:'department_name')
66
+ self.department_name = attributes[:'department_name']
67
+ end
68
+
69
+ if attributes.has_key?(:'merchant_id')
70
+ self.merchant_id = attributes[:'merchant_id']
71
+ end
72
+
73
+ if attributes.has_key?(:'settings')
74
+ self.settings = attributes[:'settings']
75
+ end
76
+ end
77
+
78
+ # Show invalid properties with the reasons. Usually used together with valid?
79
+ # @return Array for valid properties with the reasons
80
+ def list_invalid_properties
81
+ invalid_properties = Array.new
82
+ invalid_properties
83
+ end
84
+
85
+ # Check to see if the all the properties in the model are valid
86
+ # @return true if the model is valid
87
+ def valid?
88
+ true
89
+ end
90
+
91
+ # Checks equality by comparing each attribute.
92
+ # @param [Object] Object to be compared
93
+ def ==(o)
94
+ return true if self.equal?(o)
95
+ self.class == o.class &&
96
+ conversation_department_oid == o.conversation_department_oid &&
97
+ delete_me == o.delete_me &&
98
+ department_name == o.department_name &&
99
+ merchant_id == o.merchant_id &&
100
+ settings == o.settings
101
+ end
102
+
103
+ # @see the `==` method
104
+ # @param [Object] Object to be compared
105
+ def eql?(o)
106
+ self == o
107
+ end
108
+
109
+ # Calculates hash code according to all attributes.
110
+ # @return [Fixnum] Hash code
111
+ def hash
112
+ [conversation_department_oid, delete_me, department_name, merchant_id, settings].hash
113
+ end
114
+
115
+ # Builds the object from hash
116
+ # @param [Hash] attributes Model attributes in the form of hash
117
+ # @return [Object] Returns the model itself
118
+ def build_from_hash(attributes)
119
+ return nil unless attributes.is_a?(Hash)
120
+ self.class.swagger_types.each_pair do |key, type|
121
+ if type =~ /\AArray<(.*)>/i
122
+ # check to ensure the input is an array given that the attribute
123
+ # is documented as an array but the input is not
124
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
125
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
126
+ end
127
+ elsif !attributes[self.class.attribute_map[key]].nil?
128
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
129
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
130
+ end
131
+
132
+ self
133
+ end
134
+
135
+ # Deserializes the data based on type
136
+ # @param string type Data type
137
+ # @param string value Value to be deserialized
138
+ # @return [Object] Deserialized data
139
+ def _deserialize(type, value)
140
+ case type.to_sym
141
+ when :DateTime
142
+ DateTime.parse(value)
143
+ when :Date
144
+ Date.parse(value)
145
+ when :String
146
+ value.to_s
147
+ when :Integer
148
+ value.to_i
149
+ when :Float
150
+ value.to_f
151
+ when :BOOLEAN
152
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
153
+ true
154
+ else
155
+ false
156
+ end
157
+ when :Object
158
+ # generic object (usually a Hash), return directly
159
+ value
160
+ when /\AArray<(?<inner_type>.+)>\z/
161
+ inner_type = Regexp.last_match[:inner_type]
162
+ value.map { |v| _deserialize(inner_type, v) }
163
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
164
+ k_type = Regexp.last_match[:k_type]
165
+ v_type = Regexp.last_match[:v_type]
166
+ {}.tap do |hash|
167
+ value.each do |k, v|
168
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
169
+ end
170
+ end
171
+ else # model
172
+ temp_model = UltracartClient.const_get(type).new
173
+ temp_model.build_from_hash(value)
174
+ end
175
+ end
176
+
177
+ # Returns the string representation of the object
178
+ # @return [String] String presentation of the object
179
+ def to_s
180
+ to_hash.to_s
181
+ end
182
+
183
+ # to_body is an alias to to_hash (backward compatibility)
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_body
186
+ to_hash
187
+ end
188
+
189
+ # Returns the object in the form of hash
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_hash
192
+ hash = {}
193
+ self.class.attribute_map.each_pair do |attr, param|
194
+ value = self.send(attr)
195
+ next if value.nil?
196
+ hash[param] = _to_hash(value)
197
+ end
198
+ hash
199
+ end
200
+
201
+ # Outputs non-array value in the form of hash
202
+ # For object, use to_hash. Otherwise, just return the value
203
+ # @param [Object] value Any valid value
204
+ # @return [Hash] Returns the value in the form of hash
205
+ def _to_hash(value)
206
+ if value.is_a?(Array)
207
+ value.compact.map { |v| _to_hash(v) }
208
+ elsif value.is_a?(Hash)
209
+ {}.tap do |hash|
210
+ value.each { |k, v| hash[k] = _to_hash(v) }
211
+ end
212
+ elsif value.respond_to? :to_hash
213
+ value.to_hash
214
+ else
215
+ value
216
+ end
217
+ end
218
+
219
+ end
220
+ end