ultracart_api 4.1.174 → 4.1.176

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.
@@ -466,18 +466,18 @@ module UltracartClient
466
466
  end
467
467
 
468
468
  # Attempts to connect to Anrok and returns back the response
469
- # Attempts to connect to Anrok and returns back the response.
469
+ # Attempts to connect to Anrok and returns back the response, including the products configured on the merchant's Anrok account.
470
470
  # @param [Hash] opts the optional parameters
471
- # @return [TaxProviderTestResult]
471
+ # @return [TaxProviderAnrokTestResult]
472
472
  def get_tax_provider_anrok_test(opts = {})
473
473
  data, _status_code, _headers = get_tax_provider_anrok_test_with_http_info(opts)
474
474
  data
475
475
  end
476
476
 
477
477
  # Attempts to connect to Anrok and returns back the response
478
- # Attempts to connect to Anrok and returns back the response.
478
+ # Attempts to connect to Anrok and returns back the response, including the products configured on the merchant's Anrok account.
479
479
  # @param [Hash] opts the optional parameters
480
- # @return [Array<(TaxProviderTestResult, Integer, Hash)>] TaxProviderTestResult data, response status code and response headers
480
+ # @return [Array<(TaxProviderAnrokTestResult, Integer, Hash)>] TaxProviderAnrokTestResult data, response status code and response headers
481
481
  def get_tax_provider_anrok_test_with_http_info(opts = {})
482
482
  if @api_client.config.debugging
483
483
  @api_client.config.logger.debug 'Calling API: TaxApi.get_tax_provider_anrok_test ...'
@@ -501,7 +501,7 @@ module UltracartClient
501
501
  post_body = opts[:debug_body]
502
502
 
503
503
  # return_type
504
- return_type = opts[:debug_return_type] || 'TaxProviderTestResult'
504
+ return_type = opts[:debug_return_type] || 'TaxProviderAnrokTestResult'
505
505
 
506
506
  # auth_names
507
507
  auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
@@ -1004,6 +1004,122 @@ module UltracartClient
1004
1004
  return data, status_code, headers
1005
1005
  end
1006
1006
 
1007
+ # Retrieve the TaxCloud tax provider
1008
+ # Retrieves the TaxCloud tax provider.
1009
+ # @param [Hash] opts the optional parameters
1010
+ # @return [TaxProviderTaxCloud]
1011
+ def get_tax_provider_tax_cloud(opts = {})
1012
+ data, _status_code, _headers = get_tax_provider_tax_cloud_with_http_info(opts)
1013
+ data
1014
+ end
1015
+
1016
+ # Retrieve the TaxCloud tax provider
1017
+ # Retrieves the TaxCloud tax provider.
1018
+ # @param [Hash] opts the optional parameters
1019
+ # @return [Array<(TaxProviderTaxCloud, Integer, Hash)>] TaxProviderTaxCloud data, response status code and response headers
1020
+ def get_tax_provider_tax_cloud_with_http_info(opts = {})
1021
+ if @api_client.config.debugging
1022
+ @api_client.config.logger.debug 'Calling API: TaxApi.get_tax_provider_tax_cloud ...'
1023
+ end
1024
+ # resource path
1025
+ local_var_path = '/tax/providers/taxcloud'
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] || 'TaxProviderTaxCloud'
1044
+
1045
+ # auth_names
1046
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
1047
+
1048
+ new_options = opts.merge(
1049
+ :operation => :"TaxApi.get_tax_provider_tax_cloud",
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: TaxApi#get_tax_provider_tax_cloud\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1061
+ end
1062
+ return data, status_code, headers
1063
+ end
1064
+
1065
+ # Attempts to connect to TaxCloud and returns back the response
1066
+ # Attempts to connect to TaxCloud with the saved API key and Connection ID and returns back the response.
1067
+ # @param [Hash] opts the optional parameters
1068
+ # @return [TaxProviderTestResult]
1069
+ def get_tax_provider_tax_cloud_test(opts = {})
1070
+ data, _status_code, _headers = get_tax_provider_tax_cloud_test_with_http_info(opts)
1071
+ data
1072
+ end
1073
+
1074
+ # Attempts to connect to TaxCloud and returns back the response
1075
+ # Attempts to connect to TaxCloud with the saved API key and Connection ID and returns back the response.
1076
+ # @param [Hash] opts the optional parameters
1077
+ # @return [Array<(TaxProviderTestResult, Integer, Hash)>] TaxProviderTestResult data, response status code and response headers
1078
+ def get_tax_provider_tax_cloud_test_with_http_info(opts = {})
1079
+ if @api_client.config.debugging
1080
+ @api_client.config.logger.debug 'Calling API: TaxApi.get_tax_provider_tax_cloud_test ...'
1081
+ end
1082
+ # resource path
1083
+ local_var_path = '/tax/providers/taxcloud/test'
1084
+
1085
+ # query parameters
1086
+ query_params = opts[:query_params] || {}
1087
+
1088
+ # header parameters
1089
+ header_params = opts[:header_params] || {}
1090
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
1091
+ # HTTP header 'Accept' (if needed)
1092
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1093
+
1094
+ # form parameters
1095
+ form_params = opts[:form_params] || {}
1096
+
1097
+ # http body (model)
1098
+ post_body = opts[:debug_body]
1099
+
1100
+ # return_type
1101
+ return_type = opts[:debug_return_type] || 'TaxProviderTestResult'
1102
+
1103
+ # auth_names
1104
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
1105
+
1106
+ new_options = opts.merge(
1107
+ :operation => :"TaxApi.get_tax_provider_tax_cloud_test",
1108
+ :header_params => header_params,
1109
+ :query_params => query_params,
1110
+ :form_params => form_params,
1111
+ :body => post_body,
1112
+ :auth_names => auth_names,
1113
+ :return_type => return_type
1114
+ )
1115
+
1116
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
1117
+ if @api_client.config.debugging
1118
+ @api_client.config.logger.debug "API called: TaxApi#get_tax_provider_tax_cloud_test\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1119
+ end
1120
+ return data, status_code, headers
1121
+ end
1122
+
1007
1123
  # Retrieve the TaxJar tax provider
1008
1124
  # Retrieves the TaxJar tax provider.
1009
1125
  # @param [Hash] opts the optional parameters
@@ -1960,6 +2076,75 @@ module UltracartClient
1960
2076
  return data, status_code, headers
1961
2077
  end
1962
2078
 
2079
+ # Update the TaxCloud tax provider
2080
+ # Update the TaxCloud tax provider.
2081
+ # @param tax_provider_taxcloud [TaxProviderTaxCloud] TaxProviderTaxCloud object
2082
+ # @param [Hash] opts the optional parameters
2083
+ # @return [TaxProviderTaxCloud]
2084
+ def update_tax_provider_tax_cloud(tax_provider_taxcloud, opts = {})
2085
+ data, _status_code, _headers = update_tax_provider_tax_cloud_with_http_info(tax_provider_taxcloud, opts)
2086
+ data
2087
+ end
2088
+
2089
+ # Update the TaxCloud tax provider
2090
+ # Update the TaxCloud tax provider.
2091
+ # @param tax_provider_taxcloud [TaxProviderTaxCloud] TaxProviderTaxCloud object
2092
+ # @param [Hash] opts the optional parameters
2093
+ # @return [Array<(TaxProviderTaxCloud, Integer, Hash)>] TaxProviderTaxCloud data, response status code and response headers
2094
+ def update_tax_provider_tax_cloud_with_http_info(tax_provider_taxcloud, opts = {})
2095
+ if @api_client.config.debugging
2096
+ @api_client.config.logger.debug 'Calling API: TaxApi.update_tax_provider_tax_cloud ...'
2097
+ end
2098
+ # verify the required parameter 'tax_provider_taxcloud' is set
2099
+ if @api_client.config.client_side_validation && tax_provider_taxcloud.nil?
2100
+ fail ArgumentError, "Missing the required parameter 'tax_provider_taxcloud' when calling TaxApi.update_tax_provider_tax_cloud"
2101
+ end
2102
+ # resource path
2103
+ local_var_path = '/tax/providers/taxcloud'
2104
+
2105
+ # query parameters
2106
+ query_params = opts[:query_params] || {}
2107
+
2108
+ # header parameters
2109
+ header_params = opts[:header_params] || {}
2110
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
2111
+ # HTTP header 'Accept' (if needed)
2112
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
2113
+ # HTTP header 'Content-Type'
2114
+ content_type = @api_client.select_header_content_type(['application/json'])
2115
+ if !content_type.nil?
2116
+ header_params['Content-Type'] = content_type
2117
+ end
2118
+
2119
+ # form parameters
2120
+ form_params = opts[:form_params] || {}
2121
+
2122
+ # http body (model)
2123
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(tax_provider_taxcloud)
2124
+
2125
+ # return_type
2126
+ return_type = opts[:debug_return_type] || 'TaxProviderTaxCloud'
2127
+
2128
+ # auth_names
2129
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
2130
+
2131
+ new_options = opts.merge(
2132
+ :operation => :"TaxApi.update_tax_provider_tax_cloud",
2133
+ :header_params => header_params,
2134
+ :query_params => query_params,
2135
+ :form_params => form_params,
2136
+ :body => post_body,
2137
+ :auth_names => auth_names,
2138
+ :return_type => return_type
2139
+ )
2140
+
2141
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
2142
+ if @api_client.config.debugging
2143
+ @api_client.config.logger.debug "API called: TaxApi#update_tax_provider_tax_cloud\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
2144
+ end
2145
+ return data, status_code, headers
2146
+ end
2147
+
1963
2148
  # Update the TaxJar tax provider
1964
2149
  # Update the TaxJar tax provider.
1965
2150
  # @param tax_provider_tax_jar [TaxProviderTaxJar] TaxProviderTaxJar object
@@ -0,0 +1,220 @@
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 SfvbPageRefreshRequest
18
+ # The page to refresh. A path such as /shop/coffee.html, or a full URL on this storefront's host. The query string is ignored, and a path ending in / means its index.html. One page per request.
19
+ attr_accessor :url
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'url' => :'url'
25
+ }
26
+ end
27
+
28
+ # Returns all the JSON keys this model knows about
29
+ def self.acceptable_attributes
30
+ attribute_map.values
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'url' => :'String'
37
+ }
38
+ end
39
+
40
+ # List of attributes with nullable: true
41
+ def self.openapi_nullable
42
+ Set.new([
43
+ ])
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbPageRefreshRequest` initialize method"
51
+ end
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbPageRefreshRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:'url')
62
+ self.url = attributes[:'url']
63
+ end
64
+ end
65
+
66
+ # Show invalid properties with the reasons. Usually used together with valid?
67
+ # @return Array for valid properties with the reasons
68
+ def list_invalid_properties
69
+ invalid_properties = Array.new
70
+ invalid_properties
71
+ end
72
+
73
+ # Check to see if the all the properties in the model are valid
74
+ # @return true if the model is valid
75
+ def valid?
76
+ true
77
+ end
78
+
79
+ # Checks equality by comparing each attribute.
80
+ # @param [Object] Object to be compared
81
+ def ==(o)
82
+ return true if self.equal?(o)
83
+ self.class == o.class &&
84
+ url == o.url
85
+ end
86
+
87
+ # @see the `==` method
88
+ # @param [Object] Object to be compared
89
+ def eql?(o)
90
+ self == o
91
+ end
92
+
93
+ # Calculates hash code according to all attributes.
94
+ # @return [Integer] Hash code
95
+ def hash
96
+ [url].hash
97
+ end
98
+
99
+ # Builds the object from hash
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ # @return [Object] Returns the model itself
102
+ def self.build_from_hash(attributes)
103
+ new.build_from_hash(attributes)
104
+ end
105
+
106
+ # Builds the object from hash
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ # @return [Object] Returns the model itself
109
+ def build_from_hash(attributes)
110
+ return nil unless attributes.is_a?(Hash)
111
+ attributes = attributes.transform_keys(&:to_sym)
112
+ self.class.openapi_types.each_pair do |key, type|
113
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
114
+ self.send("#{key}=", nil)
115
+ elsif type =~ /\AArray<(.*)>/i
116
+ # check to ensure the input is an array given that the attribute
117
+ # is documented as an array but the input is not
118
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
119
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
120
+ end
121
+ elsif !attributes[self.class.attribute_map[key]].nil?
122
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
123
+ end
124
+ end
125
+
126
+ self
127
+ end
128
+
129
+ # Deserializes the data based on type
130
+ # @param string type Data type
131
+ # @param string value Value to be deserialized
132
+ # @return [Object] Deserialized data
133
+ def _deserialize(type, value)
134
+ case type.to_sym
135
+ when :Time
136
+ Time.parse(value)
137
+ when :Date
138
+ Date.parse(value)
139
+ when :String
140
+ value.to_s
141
+ when :Integer
142
+ value.to_i
143
+ when :Float
144
+ value.to_f
145
+ when :Boolean
146
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
147
+ true
148
+ else
149
+ false
150
+ end
151
+ when :Object
152
+ # generic object (usually a Hash), return directly
153
+ value
154
+ when /\AArray<(?<inner_type>.+)>\z/
155
+ inner_type = Regexp.last_match[:inner_type]
156
+ value.map { |v| _deserialize(inner_type, v) }
157
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
158
+ k_type = Regexp.last_match[:k_type]
159
+ v_type = Regexp.last_match[:v_type]
160
+ {}.tap do |hash|
161
+ value.each do |k, v|
162
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
163
+ end
164
+ end
165
+ else # model
166
+ # models (e.g. Pet) or oneOf
167
+ klass = UltracartClient.const_get(type)
168
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
169
+ end
170
+ end
171
+
172
+ # Returns the string representation of the object
173
+ # @return [String] String presentation of the object
174
+ def to_s
175
+ to_hash.to_s
176
+ end
177
+
178
+ # to_body is an alias to to_hash (backward compatibility)
179
+ # @return [Hash] Returns the object in the form of hash
180
+ def to_body
181
+ to_hash
182
+ end
183
+
184
+ # Returns the object in the form of hash
185
+ # @return [Hash] Returns the object in the form of hash
186
+ def to_hash
187
+ hash = {}
188
+ self.class.attribute_map.each_pair do |attr, param|
189
+ value = self.send(attr)
190
+ if value.nil?
191
+ is_nullable = self.class.openapi_nullable.include?(attr)
192
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
193
+ end
194
+
195
+ hash[param] = _to_hash(value)
196
+ end
197
+ hash
198
+ end
199
+
200
+ # Outputs non-array value in the form of hash
201
+ # For object, use to_hash. Otherwise, just return the value
202
+ # @param [Object] value Any valid value
203
+ # @return [Hash] Returns the value in the form of hash
204
+ def _to_hash(value)
205
+ if value.is_a?(Array)
206
+ value.compact.map { |v| _to_hash(v) }
207
+ elsif value.is_a?(Hash)
208
+ {}.tap do |hash|
209
+ value.each { |k, v| hash[k] = _to_hash(v) }
210
+ end
211
+ elsif value.respond_to? :to_hash
212
+ value.to_hash
213
+ else
214
+ value
215
+ end
216
+ end
217
+
218
+ end
219
+
220
+ end
@@ -0,0 +1,260 @@
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 SfvbPageRefreshResponse
18
+ # A plain sentence saying what happened.
19
+ attr_accessor :message
20
+
21
+ # The page path the refresh used, after normalization.
22
+ attr_accessor :path
23
+
24
+ # True when a cached copy was dropped. The next request renders the page fresh.
25
+ attr_accessor :refreshed
26
+
27
+ # True when the page had a cache entry.
28
+ attr_accessor :was_cached
29
+
30
+ # True when that entry was being served from cache.
31
+ attr_accessor :was_valid
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'message' => :'message',
37
+ :'path' => :'path',
38
+ :'refreshed' => :'refreshed',
39
+ :'was_cached' => :'was_cached',
40
+ :'was_valid' => :'was_valid'
41
+ }
42
+ end
43
+
44
+ # Returns all the JSON keys this model knows about
45
+ def self.acceptable_attributes
46
+ attribute_map.values
47
+ end
48
+
49
+ # Attribute type mapping.
50
+ def self.openapi_types
51
+ {
52
+ :'message' => :'String',
53
+ :'path' => :'String',
54
+ :'refreshed' => :'Boolean',
55
+ :'was_cached' => :'Boolean',
56
+ :'was_valid' => :'Boolean'
57
+ }
58
+ end
59
+
60
+ # List of attributes with nullable: true
61
+ def self.openapi_nullable
62
+ Set.new([
63
+ ])
64
+ end
65
+
66
+ # Initializes the object
67
+ # @param [Hash] attributes Model attributes in the form of hash
68
+ def initialize(attributes = {})
69
+ if (!attributes.is_a?(Hash))
70
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbPageRefreshResponse` initialize method"
71
+ end
72
+
73
+ # check to see if the attribute exists and convert string to symbol for hash key
74
+ attributes = attributes.each_with_object({}) { |(k, v), h|
75
+ if (!self.class.attribute_map.key?(k.to_sym))
76
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbPageRefreshResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
77
+ end
78
+ h[k.to_sym] = v
79
+ }
80
+
81
+ if attributes.key?(:'message')
82
+ self.message = attributes[:'message']
83
+ end
84
+
85
+ if attributes.key?(:'path')
86
+ self.path = attributes[:'path']
87
+ end
88
+
89
+ if attributes.key?(:'refreshed')
90
+ self.refreshed = attributes[:'refreshed']
91
+ end
92
+
93
+ if attributes.key?(:'was_cached')
94
+ self.was_cached = attributes[:'was_cached']
95
+ end
96
+
97
+ if attributes.key?(:'was_valid')
98
+ self.was_valid = attributes[:'was_valid']
99
+ end
100
+ end
101
+
102
+ # Show invalid properties with the reasons. Usually used together with valid?
103
+ # @return Array for valid properties with the reasons
104
+ def list_invalid_properties
105
+ invalid_properties = Array.new
106
+ invalid_properties
107
+ end
108
+
109
+ # Check to see if the all the properties in the model are valid
110
+ # @return true if the model is valid
111
+ def valid?
112
+ true
113
+ end
114
+
115
+ # Checks equality by comparing each attribute.
116
+ # @param [Object] Object to be compared
117
+ def ==(o)
118
+ return true if self.equal?(o)
119
+ self.class == o.class &&
120
+ message == o.message &&
121
+ path == o.path &&
122
+ refreshed == o.refreshed &&
123
+ was_cached == o.was_cached &&
124
+ was_valid == o.was_valid
125
+ end
126
+
127
+ # @see the `==` method
128
+ # @param [Object] Object to be compared
129
+ def eql?(o)
130
+ self == o
131
+ end
132
+
133
+ # Calculates hash code according to all attributes.
134
+ # @return [Integer] Hash code
135
+ def hash
136
+ [message, path, refreshed, was_cached, was_valid].hash
137
+ end
138
+
139
+ # Builds the object from hash
140
+ # @param [Hash] attributes Model attributes in the form of hash
141
+ # @return [Object] Returns the model itself
142
+ def self.build_from_hash(attributes)
143
+ new.build_from_hash(attributes)
144
+ end
145
+
146
+ # Builds the object from hash
147
+ # @param [Hash] attributes Model attributes in the form of hash
148
+ # @return [Object] Returns the model itself
149
+ def build_from_hash(attributes)
150
+ return nil unless attributes.is_a?(Hash)
151
+ attributes = attributes.transform_keys(&:to_sym)
152
+ self.class.openapi_types.each_pair do |key, type|
153
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
154
+ self.send("#{key}=", nil)
155
+ elsif type =~ /\AArray<(.*)>/i
156
+ # check to ensure the input is an array given that the attribute
157
+ # is documented as an array but the input is not
158
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
159
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
160
+ end
161
+ elsif !attributes[self.class.attribute_map[key]].nil?
162
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
163
+ end
164
+ end
165
+
166
+ self
167
+ end
168
+
169
+ # Deserializes the data based on type
170
+ # @param string type Data type
171
+ # @param string value Value to be deserialized
172
+ # @return [Object] Deserialized data
173
+ def _deserialize(type, value)
174
+ case type.to_sym
175
+ when :Time
176
+ Time.parse(value)
177
+ when :Date
178
+ Date.parse(value)
179
+ when :String
180
+ value.to_s
181
+ when :Integer
182
+ value.to_i
183
+ when :Float
184
+ value.to_f
185
+ when :Boolean
186
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
187
+ true
188
+ else
189
+ false
190
+ end
191
+ when :Object
192
+ # generic object (usually a Hash), return directly
193
+ value
194
+ when /\AArray<(?<inner_type>.+)>\z/
195
+ inner_type = Regexp.last_match[:inner_type]
196
+ value.map { |v| _deserialize(inner_type, v) }
197
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
198
+ k_type = Regexp.last_match[:k_type]
199
+ v_type = Regexp.last_match[:v_type]
200
+ {}.tap do |hash|
201
+ value.each do |k, v|
202
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
203
+ end
204
+ end
205
+ else # model
206
+ # models (e.g. Pet) or oneOf
207
+ klass = UltracartClient.const_get(type)
208
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
209
+ end
210
+ end
211
+
212
+ # Returns the string representation of the object
213
+ # @return [String] String presentation of the object
214
+ def to_s
215
+ to_hash.to_s
216
+ end
217
+
218
+ # to_body is an alias to to_hash (backward compatibility)
219
+ # @return [Hash] Returns the object in the form of hash
220
+ def to_body
221
+ to_hash
222
+ end
223
+
224
+ # Returns the object in the form of hash
225
+ # @return [Hash] Returns the object in the form of hash
226
+ def to_hash
227
+ hash = {}
228
+ self.class.attribute_map.each_pair do |attr, param|
229
+ value = self.send(attr)
230
+ if value.nil?
231
+ is_nullable = self.class.openapi_nullable.include?(attr)
232
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
233
+ end
234
+
235
+ hash[param] = _to_hash(value)
236
+ end
237
+ hash
238
+ end
239
+
240
+ # Outputs non-array value in the form of hash
241
+ # For object, use to_hash. Otherwise, just return the value
242
+ # @param [Object] value Any valid value
243
+ # @return [Hash] Returns the value in the form of hash
244
+ def _to_hash(value)
245
+ if value.is_a?(Array)
246
+ value.compact.map { |v| _to_hash(v) }
247
+ elsif value.is_a?(Hash)
248
+ {}.tap do |hash|
249
+ value.each { |k, v| hash[k] = _to_hash(v) }
250
+ end
251
+ elsif value.respond_to? :to_hash
252
+ value.to_hash
253
+ else
254
+ value
255
+ end
256
+ end
257
+
258
+ end
259
+
260
+ end