ultracart_api 3.11.13 → 3.11.15

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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +25 -4
  3. data/docs/CartUpsellAfter.md +3 -1
  4. data/docs/ConversationVirtualAgentCapabilities.md +2 -0
  5. data/docs/CustomReport.md +17 -0
  6. data/docs/CustomReportAccountConfig.md +16 -0
  7. data/docs/CustomReportAccountConfigResponse.md +12 -0
  8. data/docs/CustomReportExecutionParameter.md +10 -0
  9. data/docs/CustomReportExecutionRequest.md +8 -0
  10. data/docs/CustomReportParameter.md +13 -0
  11. data/docs/CustomReportParameterOption.md +9 -0
  12. data/docs/CustomReportQuery.md +13 -0
  13. data/docs/CustomReportResponse.md +12 -0
  14. data/docs/CustomReportTooltip.md +9 -0
  15. data/docs/DatawarehouseApi.md +357 -0
  16. data/docs/Item.md +1 -1
  17. data/docs/OrderApi.md +104 -0
  18. data/lib/ultracart_api/api/datawarehouse_api.rb +390 -0
  19. data/lib/ultracart_api/api/order_api.rb +111 -0
  20. data/lib/ultracart_api/models/cart_upsell_after.rb +25 -5
  21. data/lib/ultracart_api/models/conversation_virtual_agent_capabilities.rb +55 -1
  22. data/lib/ultracart_api/models/custom_report.rb +271 -0
  23. data/lib/ultracart_api/models/custom_report_account_config.rb +261 -0
  24. data/lib/ultracart_api/models/custom_report_account_config_response.rb +221 -0
  25. data/lib/ultracart_api/models/custom_report_execution_parameter.rb +202 -0
  26. data/lib/ultracart_api/models/custom_report_execution_request.rb +186 -0
  27. data/lib/ultracart_api/models/custom_report_parameter.rb +231 -0
  28. data/lib/ultracart_api/models/custom_report_parameter_option.rb +193 -0
  29. data/lib/ultracart_api/models/custom_report_query.rb +231 -0
  30. data/lib/ultracart_api/models/custom_report_response.rb +221 -0
  31. data/lib/ultracart_api/models/custom_report_tooltip.rb +193 -0
  32. data/lib/ultracart_api/models/item.rb +1 -1
  33. data/lib/ultracart_api/version.rb +1 -1
  34. data/lib/ultracart_api.rb +10 -0
  35. metadata +22 -2
@@ -93,6 +93,63 @@ module UltracartClient
93
93
  end
94
94
  return data, status_code, headers
95
95
  end
96
+ # Set a refund block on an order
97
+ # Sets a refund block on an order to prevent a user from performing a refund. Commonly used when a chargeback has been received.
98
+ # @param order_id The order id to block a refund on.
99
+ # @param [Hash] opts the optional parameters
100
+ # @option opts [String] :block_reason Block reason code (optional)
101
+ # @return [nil]
102
+ def block_refund_on_order(order_id, opts = {})
103
+ block_refund_on_order_with_http_info(order_id, opts)
104
+ nil
105
+ end
106
+
107
+ # Set a refund block on an order
108
+ # Sets a refund block on an order to prevent a user from performing a refund. Commonly used when a chargeback has been received.
109
+ # @param order_id The order id to block a refund on.
110
+ # @param [Hash] opts the optional parameters
111
+ # @option opts [String] :block_reason Block reason code (optional)
112
+ # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
113
+ def block_refund_on_order_with_http_info(order_id, opts = {})
114
+ if @api_client.config.debugging
115
+ @api_client.config.logger.debug 'Calling API: OrderApi.block_refund_on_order ...'
116
+ end
117
+ # verify the required parameter 'order_id' is set
118
+ if @api_client.config.client_side_validation && order_id.nil?
119
+ fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderApi.block_refund_on_order"
120
+ end
121
+ # resource path
122
+ local_var_path = '/order/orders/{order_id}/refund_block'.sub('{' + 'order_id' + '}', order_id.to_s)
123
+
124
+ # query parameters
125
+ query_params = {}
126
+ query_params[:'block_reason'] = opts[:'block_reason'] if !opts[:'block_reason'].nil?
127
+
128
+ # header parameters
129
+ header_params = {}
130
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
131
+ # HTTP header 'Accept' (if needed)
132
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
133
+ # HTTP header 'Content-Type'
134
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json; charset=UTF-8'])
135
+
136
+ # form parameters
137
+ form_params = {}
138
+
139
+ # http body (model)
140
+ post_body = nil
141
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
142
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
143
+ :header_params => header_params,
144
+ :query_params => query_params,
145
+ :form_params => form_params,
146
+ :body => post_body,
147
+ :auth_names => auth_names)
148
+ if @api_client.config.debugging
149
+ @api_client.config.logger.debug "API called: OrderApi#block_refund_on_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
150
+ end
151
+ return data, status_code, headers
152
+ end
96
153
  # Cancel an order
97
154
  # Cancel an order on the UltraCart account. If the success flag is false, then consult the error message for why it failed.
98
155
  # @param order_id The order id to cancel.
@@ -1607,6 +1664,60 @@ module UltracartClient
1607
1664
  end
1608
1665
  return data, status_code, headers
1609
1666
  end
1667
+ # Remove a refund block on an order
1668
+ # Removes a refund block on an order to prevent a user from performing a refund.
1669
+ # @param order_id The order id to unblock a refund on.
1670
+ # @param [Hash] opts the optional parameters
1671
+ # @return [nil]
1672
+ def unblock_refund_on_order(order_id, opts = {})
1673
+ unblock_refund_on_order_with_http_info(order_id, opts)
1674
+ nil
1675
+ end
1676
+
1677
+ # Remove a refund block on an order
1678
+ # Removes a refund block on an order to prevent a user from performing a refund.
1679
+ # @param order_id The order id to unblock a refund on.
1680
+ # @param [Hash] opts the optional parameters
1681
+ # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
1682
+ def unblock_refund_on_order_with_http_info(order_id, opts = {})
1683
+ if @api_client.config.debugging
1684
+ @api_client.config.logger.debug 'Calling API: OrderApi.unblock_refund_on_order ...'
1685
+ end
1686
+ # verify the required parameter 'order_id' is set
1687
+ if @api_client.config.client_side_validation && order_id.nil?
1688
+ fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderApi.unblock_refund_on_order"
1689
+ end
1690
+ # resource path
1691
+ local_var_path = '/order/orders/{order_id}/refund_unblock'.sub('{' + 'order_id' + '}', order_id.to_s)
1692
+
1693
+ # query parameters
1694
+ query_params = {}
1695
+
1696
+ # header parameters
1697
+ header_params = {}
1698
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
1699
+ # HTTP header 'Accept' (if needed)
1700
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1701
+ # HTTP header 'Content-Type'
1702
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json; charset=UTF-8'])
1703
+
1704
+ # form parameters
1705
+ form_params = {}
1706
+
1707
+ # http body (model)
1708
+ post_body = nil
1709
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
1710
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
1711
+ :header_params => header_params,
1712
+ :query_params => query_params,
1713
+ :form_params => form_params,
1714
+ :body => post_body,
1715
+ :auth_names => auth_names)
1716
+ if @api_client.config.debugging
1717
+ @api_client.config.logger.debug "API called: OrderApi#unblock_refund_on_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1718
+ end
1719
+ return data, status_code, headers
1720
+ end
1610
1721
  # Update A/R Retry Configuration
1611
1722
  # Update A/R Retry Configuration. This is primarily an internal API call. It is doubtful you would ever need to use it.
1612
1723
  # @param retry_config AccountsReceivableRetryConfig object
@@ -20,15 +20,23 @@ module UltracartClient
20
20
  # The amount of inactivity in minutes after which the cart should be finalized into an order. This will calculate the finalize_after_dts field.
21
21
  attr_accessor :finalize_after_minutes
22
22
 
23
- # Upsell path code
23
+ # Upsell path code (this is for legacy upsells only)
24
24
  attr_accessor :upsell_path_code
25
25
 
26
+ # Upsell path name to start on (StoreFront Upsells). Will only be respected on a handoff API call.
27
+ attr_accessor :upsell_path_name
28
+
29
+ # Upsell path variation to start on (StoreFront Upsells). Will only be respected on a handoff API call.
30
+ attr_accessor :upsell_path_variation
31
+
26
32
  # Attribute mapping from ruby-style variable name to JSON key.
27
33
  def self.attribute_map
28
34
  {
29
35
  :'finalize_after_dts' => :'finalize_after_dts',
30
36
  :'finalize_after_minutes' => :'finalize_after_minutes',
31
- :'upsell_path_code' => :'upsell_path_code'
37
+ :'upsell_path_code' => :'upsell_path_code',
38
+ :'upsell_path_name' => :'upsell_path_name',
39
+ :'upsell_path_variation' => :'upsell_path_variation'
32
40
  }
33
41
  end
34
42
 
@@ -37,7 +45,9 @@ module UltracartClient
37
45
  {
38
46
  :'finalize_after_dts' => :'String',
39
47
  :'finalize_after_minutes' => :'Integer',
40
- :'upsell_path_code' => :'String'
48
+ :'upsell_path_code' => :'String',
49
+ :'upsell_path_name' => :'String',
50
+ :'upsell_path_variation' => :'String'
41
51
  }
42
52
  end
43
53
 
@@ -60,6 +70,14 @@ module UltracartClient
60
70
  if attributes.has_key?(:'upsell_path_code')
61
71
  self.upsell_path_code = attributes[:'upsell_path_code']
62
72
  end
73
+
74
+ if attributes.has_key?(:'upsell_path_name')
75
+ self.upsell_path_name = attributes[:'upsell_path_name']
76
+ end
77
+
78
+ if attributes.has_key?(:'upsell_path_variation')
79
+ self.upsell_path_variation = attributes[:'upsell_path_variation']
80
+ end
63
81
  end
64
82
 
65
83
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -97,7 +115,9 @@ module UltracartClient
97
115
  self.class == o.class &&
98
116
  finalize_after_dts == o.finalize_after_dts &&
99
117
  finalize_after_minutes == o.finalize_after_minutes &&
100
- upsell_path_code == o.upsell_path_code
118
+ upsell_path_code == o.upsell_path_code &&
119
+ upsell_path_name == o.upsell_path_name &&
120
+ upsell_path_variation == o.upsell_path_variation
101
121
  end
102
122
 
103
123
  # @see the `==` method
@@ -109,7 +129,7 @@ module UltracartClient
109
129
  # Calculates hash code according to all attributes.
110
130
  # @return [Fixnum] Hash code
111
131
  def hash
112
- [finalize_after_dts, finalize_after_minutes, upsell_path_code].hash
132
+ [finalize_after_dts, finalize_after_minutes, upsell_path_code, upsell_path_name, upsell_path_variation].hash
113
133
  end
114
134
 
115
135
  # Builds the object from hash
@@ -24,6 +24,12 @@ module UltracartClient
24
24
 
25
25
  attr_accessor :open_support_ticket
26
26
 
27
+ # Channel to use to open the support ticket
28
+ attr_accessor :open_support_ticket_channel
29
+
30
+ # Email to send support ticket to
31
+ attr_accessor :open_support_ticket_channel_email
32
+
27
33
  attr_accessor :pause_subscription
28
34
 
29
35
  attr_accessor :resume_subscription
@@ -32,6 +38,28 @@ module UltracartClient
32
38
 
33
39
  attr_accessor :update_subscription_credit_card
34
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
+
35
63
  # Attribute mapping from ruby-style variable name to JSON key.
36
64
  def self.attribute_map
37
65
  {
@@ -40,6 +68,8 @@ module UltracartClient
40
68
  :'lookup_order_information' => :'lookup_order_information',
41
69
  :'lookup_subscription_information' => :'lookup_subscription_information',
42
70
  :'open_support_ticket' => :'open_support_ticket',
71
+ :'open_support_ticket_channel' => :'open_support_ticket_channel',
72
+ :'open_support_ticket_channel_email' => :'open_support_ticket_channel_email',
43
73
  :'pause_subscription' => :'pause_subscription',
44
74
  :'resume_subscription' => :'resume_subscription',
45
75
  :'transfer_chat_to_live_agent' => :'transfer_chat_to_live_agent',
@@ -55,6 +85,8 @@ module UltracartClient
55
85
  :'lookup_order_information' => :'BOOLEAN',
56
86
  :'lookup_subscription_information' => :'BOOLEAN',
57
87
  :'open_support_ticket' => :'BOOLEAN',
88
+ :'open_support_ticket_channel' => :'String',
89
+ :'open_support_ticket_channel_email' => :'String',
58
90
  :'pause_subscription' => :'BOOLEAN',
59
91
  :'resume_subscription' => :'BOOLEAN',
60
92
  :'transfer_chat_to_live_agent' => :'BOOLEAN',
@@ -90,6 +122,14 @@ module UltracartClient
90
122
  self.open_support_ticket = attributes[:'open_support_ticket']
91
123
  end
92
124
 
125
+ if attributes.has_key?(:'open_support_ticket_channel')
126
+ self.open_support_ticket_channel = attributes[:'open_support_ticket_channel']
127
+ end
128
+
129
+ if attributes.has_key?(:'open_support_ticket_channel_email')
130
+ self.open_support_ticket_channel_email = attributes[:'open_support_ticket_channel_email']
131
+ end
132
+
93
133
  if attributes.has_key?(:'pause_subscription')
94
134
  self.pause_subscription = attributes[:'pause_subscription']
95
135
  end
@@ -117,9 +157,21 @@ module UltracartClient
117
157
  # Check to see if the all the properties in the model are valid
118
158
  # @return true if the model is valid
119
159
  def valid?
160
+ open_support_ticket_channel_validator = EnumAttributeValidator.new('String', ['none', 'email', 'UltraCart Task', 'Zoho Desk Ticket'])
161
+ return false unless open_support_ticket_channel_validator.valid?(@open_support_ticket_channel)
120
162
  true
121
163
  end
122
164
 
165
+ # Custom attribute writer method checking allowed values (enum).
166
+ # @param [Object] open_support_ticket_channel Object to be assigned
167
+ def open_support_ticket_channel=(open_support_ticket_channel)
168
+ validator = EnumAttributeValidator.new('String', ['none', 'email', 'UltraCart Task', 'Zoho Desk Ticket'])
169
+ unless validator.valid?(open_support_ticket_channel)
170
+ fail ArgumentError, 'invalid value for "open_support_ticket_channel", must be one of #{validator.allowable_values}.'
171
+ end
172
+ @open_support_ticket_channel = open_support_ticket_channel
173
+ end
174
+
123
175
  # Checks equality by comparing each attribute.
124
176
  # @param [Object] Object to be compared
125
177
  def ==(o)
@@ -130,6 +182,8 @@ module UltracartClient
130
182
  lookup_order_information == o.lookup_order_information &&
131
183
  lookup_subscription_information == o.lookup_subscription_information &&
132
184
  open_support_ticket == o.open_support_ticket &&
185
+ open_support_ticket_channel == o.open_support_ticket_channel &&
186
+ open_support_ticket_channel_email == o.open_support_ticket_channel_email &&
133
187
  pause_subscription == o.pause_subscription &&
134
188
  resume_subscription == o.resume_subscription &&
135
189
  transfer_chat_to_live_agent == o.transfer_chat_to_live_agent &&
@@ -145,7 +199,7 @@ module UltracartClient
145
199
  # Calculates hash code according to all attributes.
146
200
  # @return [Fixnum] Hash code
147
201
  def hash
148
- [cancel_subscription, delay_subscription, lookup_order_information, lookup_subscription_information, open_support_ticket, pause_subscription, resume_subscription, transfer_chat_to_live_agent, update_subscription_credit_card].hash
202
+ [cancel_subscription, delay_subscription, lookup_order_information, lookup_subscription_information, open_support_ticket, open_support_ticket_channel, open_support_ticket_channel_email, pause_subscription, resume_subscription, transfer_chat_to_live_agent, update_subscription_credit_card].hash
149
203
  end
150
204
 
151
205
  # Builds the object from hash
@@ -0,0 +1,271 @@
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 CustomReport
17
+ attr_accessor :chart_javascript
18
+
19
+ attr_accessor :chart_javascript_url
20
+
21
+ attr_accessor :data_warehouse_report_config_oid
22
+
23
+ attr_accessor :dataset_security_level
24
+
25
+ attr_accessor :group_name
26
+
27
+ attr_accessor :merchant_id
28
+
29
+ attr_accessor :name
30
+
31
+ attr_accessor :parameters
32
+
33
+ attr_accessor :queries
34
+
35
+ attr_accessor :tooltips
36
+
37
+ # Attribute mapping from ruby-style variable name to JSON key.
38
+ def self.attribute_map
39
+ {
40
+ :'chart_javascript' => :'chart_javascript',
41
+ :'chart_javascript_url' => :'chart_javascript_url',
42
+ :'data_warehouse_report_config_oid' => :'data_warehouse_report_config_oid',
43
+ :'dataset_security_level' => :'dataset_security_level',
44
+ :'group_name' => :'group_name',
45
+ :'merchant_id' => :'merchant_id',
46
+ :'name' => :'name',
47
+ :'parameters' => :'parameters',
48
+ :'queries' => :'queries',
49
+ :'tooltips' => :'tooltips'
50
+ }
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.swagger_types
55
+ {
56
+ :'chart_javascript' => :'String',
57
+ :'chart_javascript_url' => :'String',
58
+ :'data_warehouse_report_config_oid' => :'Integer',
59
+ :'dataset_security_level' => :'String',
60
+ :'group_name' => :'String',
61
+ :'merchant_id' => :'String',
62
+ :'name' => :'String',
63
+ :'parameters' => :'Array<CustomReportParameter>',
64
+ :'queries' => :'Array<CustomReportQuery>',
65
+ :'tooltips' => :'Array<CustomReportTooltip>'
66
+ }
67
+ end
68
+
69
+ # Initializes the object
70
+ # @param [Hash] attributes Model attributes in the form of hash
71
+ def initialize(attributes = {})
72
+ return unless attributes.is_a?(Hash)
73
+
74
+ # convert string to symbol for hash key
75
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
76
+
77
+ if attributes.has_key?(:'chart_javascript')
78
+ self.chart_javascript = attributes[:'chart_javascript']
79
+ end
80
+
81
+ if attributes.has_key?(:'chart_javascript_url')
82
+ self.chart_javascript_url = attributes[:'chart_javascript_url']
83
+ end
84
+
85
+ if attributes.has_key?(:'data_warehouse_report_config_oid')
86
+ self.data_warehouse_report_config_oid = attributes[:'data_warehouse_report_config_oid']
87
+ end
88
+
89
+ if attributes.has_key?(:'dataset_security_level')
90
+ self.dataset_security_level = attributes[:'dataset_security_level']
91
+ end
92
+
93
+ if attributes.has_key?(:'group_name')
94
+ self.group_name = attributes[:'group_name']
95
+ end
96
+
97
+ if attributes.has_key?(:'merchant_id')
98
+ self.merchant_id = attributes[:'merchant_id']
99
+ end
100
+
101
+ if attributes.has_key?(:'name')
102
+ self.name = attributes[:'name']
103
+ end
104
+
105
+ if attributes.has_key?(:'parameters')
106
+ if (value = attributes[:'parameters']).is_a?(Array)
107
+ self.parameters = value
108
+ end
109
+ end
110
+
111
+ if attributes.has_key?(:'queries')
112
+ if (value = attributes[:'queries']).is_a?(Array)
113
+ self.queries = value
114
+ end
115
+ end
116
+
117
+ if attributes.has_key?(:'tooltips')
118
+ if (value = attributes[:'tooltips']).is_a?(Array)
119
+ self.tooltips = value
120
+ end
121
+ end
122
+ end
123
+
124
+ # Show invalid properties with the reasons. Usually used together with valid?
125
+ # @return Array for valid properties with the reasons
126
+ def list_invalid_properties
127
+ invalid_properties = Array.new
128
+ invalid_properties
129
+ end
130
+
131
+ # Check to see if the all the properties in the model are valid
132
+ # @return true if the model is valid
133
+ def valid?
134
+ true
135
+ end
136
+
137
+ # Checks equality by comparing each attribute.
138
+ # @param [Object] Object to be compared
139
+ def ==(o)
140
+ return true if self.equal?(o)
141
+ self.class == o.class &&
142
+ chart_javascript == o.chart_javascript &&
143
+ chart_javascript_url == o.chart_javascript_url &&
144
+ data_warehouse_report_config_oid == o.data_warehouse_report_config_oid &&
145
+ dataset_security_level == o.dataset_security_level &&
146
+ group_name == o.group_name &&
147
+ merchant_id == o.merchant_id &&
148
+ name == o.name &&
149
+ parameters == o.parameters &&
150
+ queries == o.queries &&
151
+ tooltips == o.tooltips
152
+ end
153
+
154
+ # @see the `==` method
155
+ # @param [Object] Object to be compared
156
+ def eql?(o)
157
+ self == o
158
+ end
159
+
160
+ # Calculates hash code according to all attributes.
161
+ # @return [Fixnum] Hash code
162
+ def hash
163
+ [chart_javascript, chart_javascript_url, data_warehouse_report_config_oid, dataset_security_level, group_name, merchant_id, name, parameters, queries, tooltips].hash
164
+ end
165
+
166
+ # Builds the object from hash
167
+ # @param [Hash] attributes Model attributes in the form of hash
168
+ # @return [Object] Returns the model itself
169
+ def build_from_hash(attributes)
170
+ return nil unless attributes.is_a?(Hash)
171
+ self.class.swagger_types.each_pair do |key, type|
172
+ if type =~ /\AArray<(.*)>/i
173
+ # check to ensure the input is an array given that the attribute
174
+ # is documented as an array but the input is not
175
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
176
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
177
+ end
178
+ elsif !attributes[self.class.attribute_map[key]].nil?
179
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
180
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
181
+ end
182
+
183
+ self
184
+ end
185
+
186
+ # Deserializes the data based on type
187
+ # @param string type Data type
188
+ # @param string value Value to be deserialized
189
+ # @return [Object] Deserialized data
190
+ def _deserialize(type, value)
191
+ case type.to_sym
192
+ when :DateTime
193
+ DateTime.parse(value)
194
+ when :Date
195
+ Date.parse(value)
196
+ when :String
197
+ value.to_s
198
+ when :Integer
199
+ value.to_i
200
+ when :Float
201
+ value.to_f
202
+ when :BOOLEAN
203
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
204
+ true
205
+ else
206
+ false
207
+ end
208
+ when :Object
209
+ # generic object (usually a Hash), return directly
210
+ value
211
+ when /\AArray<(?<inner_type>.+)>\z/
212
+ inner_type = Regexp.last_match[:inner_type]
213
+ value.map { |v| _deserialize(inner_type, v) }
214
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
215
+ k_type = Regexp.last_match[:k_type]
216
+ v_type = Regexp.last_match[:v_type]
217
+ {}.tap do |hash|
218
+ value.each do |k, v|
219
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
220
+ end
221
+ end
222
+ else # model
223
+ temp_model = UltracartClient.const_get(type).new
224
+ temp_model.build_from_hash(value)
225
+ end
226
+ end
227
+
228
+ # Returns the string representation of the object
229
+ # @return [String] String presentation of the object
230
+ def to_s
231
+ to_hash.to_s
232
+ end
233
+
234
+ # to_body is an alias to to_hash (backward compatibility)
235
+ # @return [Hash] Returns the object in the form of hash
236
+ def to_body
237
+ to_hash
238
+ end
239
+
240
+ # Returns the object in the form of hash
241
+ # @return [Hash] Returns the object in the form of hash
242
+ def to_hash
243
+ hash = {}
244
+ self.class.attribute_map.each_pair do |attr, param|
245
+ value = self.send(attr)
246
+ next if value.nil?
247
+ hash[param] = _to_hash(value)
248
+ end
249
+ hash
250
+ end
251
+
252
+ # Outputs non-array value in the form of hash
253
+ # For object, use to_hash. Otherwise, just return the value
254
+ # @param [Object] value Any valid value
255
+ # @return [Hash] Returns the value in the form of hash
256
+ def _to_hash(value)
257
+ if value.is_a?(Array)
258
+ value.compact.map { |v| _to_hash(v) }
259
+ elsif value.is_a?(Hash)
260
+ {}.tap do |hash|
261
+ value.each { |k, v| hash[k] = _to_hash(v) }
262
+ end
263
+ elsif value.respond_to? :to_hash
264
+ value.to_hash
265
+ else
266
+ value
267
+ end
268
+ end
269
+
270
+ end
271
+ end