ultracart_api 3.4.6 → 3.4.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -4
- data/docs/EmailList.md +1 -0
- data/docs/EmailListSegmentFolder.md +12 -0
- data/docs/EmailListSegmentFolderResponse.md +12 -0
- data/docs/EmailListSegmentFoldersResponse.md +12 -0
- data/docs/EmailSegment.md +1 -0
- data/docs/PaymentsConfiguration.md +5 -3
- data/docs/PaymentsConfigurationAffirm.md +7 -7
- data/docs/PaymentsConfigurationAmazon.md +7 -7
- data/docs/PaymentsConfigurationCOD.md +5 -5
- data/docs/PaymentsConfigurationCash.md +1 -1
- data/docs/PaymentsConfigurationCheck.md +12 -17
- data/docs/PaymentsConfigurationCreditCard.md +11 -9
- data/docs/PaymentsConfigurationCreditCardType.md +17 -0
- data/docs/PaymentsConfigurationEcheck.md +11 -0
- data/docs/PaymentsConfigurationLoanHero.md +4 -4
- data/docs/PaymentsConfigurationMoneyOrder.md +11 -0
- data/docs/PaymentsConfigurationPayPal.md +28 -28
- data/docs/PaymentsConfigurationPurchaseOrder.md +3 -3
- data/docs/PaymentsConfigurationQuoteRequest.md +2 -2
- data/docs/PaymentsConfigurationRestrictions.md +14 -12
- data/docs/PaymentsConfigurationRestrictionsTheme.md +10 -0
- data/docs/PaymentsConfigurationSezzle.md +8 -7
- data/docs/PaymentsConfigurationTestMethod.md +18 -0
- data/docs/PaymentsConfigurationWePay.md +26 -26
- data/docs/PaymentsConfigurationWireTransfer.md +10 -10
- data/docs/StorefrontApi.md +260 -0
- data/lib/ultracart_api.rb +8 -0
- data/lib/ultracart_api/api/storefront_api.rb +295 -0
- data/lib/ultracart_api/models/email_list.rb +11 -1
- data/lib/ultracart_api/models/email_list_segment_folder.rb +240 -0
- data/lib/ultracart_api/models/email_list_segment_folder_response.rb +221 -0
- data/lib/ultracart_api/models/email_list_segment_folders_response.rb +223 -0
- data/lib/ultracart_api/models/email_segment.rb +11 -1
- data/lib/ultracart_api/models/payments_configuration.rb +50 -31
- data/lib/ultracart_api/models/payments_configuration_affirm.rb +81 -40
- data/lib/ultracart_api/models/payments_configuration_amazon.rb +51 -44
- data/lib/ultracart_api/models/payments_configuration_cash.rb +4 -3
- data/lib/ultracart_api/models/payments_configuration_check.rb +72 -103
- data/lib/ultracart_api/models/payments_configuration_cod.rb +39 -34
- data/lib/ultracart_api/models/payments_configuration_credit_card.rb +74 -39
- data/lib/ultracart_api/models/payments_configuration_credit_card_type.rb +309 -0
- data/lib/ultracart_api/models/payments_configuration_echeck.rb +214 -0
- data/lib/ultracart_api/models/payments_configuration_loan_hero.rb +23 -19
- data/lib/ultracart_api/models/payments_configuration_money_order.rb +214 -0
- data/lib/ultracart_api/models/payments_configuration_pay_pal.rb +270 -172
- data/lib/ultracart_api/models/payments_configuration_purchase_order.rb +19 -16
- data/lib/ultracart_api/models/payments_configuration_quote_request.rb +12 -10
- data/lib/ultracart_api/models/payments_configuration_restrictions.rb +73 -39
- data/lib/ultracart_api/models/payments_configuration_restrictions_theme.rb +202 -0
- data/lib/ultracart_api/models/payments_configuration_sezzle.rb +99 -46
- data/lib/ultracart_api/models/payments_configuration_test_method.rb +319 -0
- data/lib/ultracart_api/models/payments_configuration_we_pay.rb +186 -160
- data/lib/ultracart_api/models/payments_configuration_wire_transfer.rb +71 -61
- data/lib/ultracart_api/version.rb +1 -1
- metadata +18 -2
@@ -0,0 +1,309 @@
|
|
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 PaymentsConfigurationCreditCardType
|
17
|
+
# Optional field used for Quickbooks integrations to match this credit card with the corresponding payment type in Quickbooks
|
18
|
+
attr_accessor :accounting_code
|
19
|
+
|
20
|
+
# Internally used icon information for this card type
|
21
|
+
attr_accessor :card_type_icon
|
22
|
+
|
23
|
+
# Credit card type
|
24
|
+
attr_accessor :credit_card
|
25
|
+
|
26
|
+
# The name of the account to deposit funds
|
27
|
+
attr_accessor :deposit_to_account
|
28
|
+
|
29
|
+
# If true, this card type will be accepted during checkout
|
30
|
+
attr_accessor :enabled
|
31
|
+
|
32
|
+
# Optional additional fee applied to order for this card
|
33
|
+
attr_accessor :processing_fee
|
34
|
+
|
35
|
+
# Optional additional fee applied to order for this card
|
36
|
+
attr_accessor :processing_percentage
|
37
|
+
|
38
|
+
# Optional field. If integrated with Quickbooks, this code will be used when informing Quickbooks about any surcharges applied to orders
|
39
|
+
attr_accessor :surcharge_accounting_code
|
40
|
+
|
41
|
+
# An optional additional fee to charge the customer for using this card.
|
42
|
+
attr_accessor :transaction_fee
|
43
|
+
|
44
|
+
# An optional transaction percentage to charge the customer for using this card
|
45
|
+
attr_accessor :transaction_percentage
|
46
|
+
|
47
|
+
class EnumAttributeValidator
|
48
|
+
attr_reader :datatype
|
49
|
+
attr_reader :allowable_values
|
50
|
+
|
51
|
+
def initialize(datatype, allowable_values)
|
52
|
+
@allowable_values = allowable_values.map do |value|
|
53
|
+
case datatype.to_s
|
54
|
+
when /Integer/i
|
55
|
+
value.to_i
|
56
|
+
when /Float/i
|
57
|
+
value.to_f
|
58
|
+
else
|
59
|
+
value
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def valid?(value)
|
65
|
+
!value || allowable_values.include?(value)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
70
|
+
def self.attribute_map
|
71
|
+
{
|
72
|
+
:'accounting_code' => :'accounting_code',
|
73
|
+
:'card_type_icon' => :'card_type_icon',
|
74
|
+
:'credit_card' => :'credit_card',
|
75
|
+
:'deposit_to_account' => :'deposit_to_account',
|
76
|
+
:'enabled' => :'enabled',
|
77
|
+
:'processing_fee' => :'processing_fee',
|
78
|
+
:'processing_percentage' => :'processing_percentage',
|
79
|
+
:'surcharge_accounting_code' => :'surcharge_accounting_code',
|
80
|
+
:'transaction_fee' => :'transaction_fee',
|
81
|
+
:'transaction_percentage' => :'transaction_percentage'
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
# Attribute type mapping.
|
86
|
+
def self.swagger_types
|
87
|
+
{
|
88
|
+
:'accounting_code' => :'String',
|
89
|
+
:'card_type_icon' => :'String',
|
90
|
+
:'credit_card' => :'String',
|
91
|
+
:'deposit_to_account' => :'String',
|
92
|
+
:'enabled' => :'BOOLEAN',
|
93
|
+
:'processing_fee' => :'String',
|
94
|
+
:'processing_percentage' => :'String',
|
95
|
+
:'surcharge_accounting_code' => :'String',
|
96
|
+
:'transaction_fee' => :'String',
|
97
|
+
:'transaction_percentage' => :'String'
|
98
|
+
}
|
99
|
+
end
|
100
|
+
|
101
|
+
# Initializes the object
|
102
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
103
|
+
def initialize(attributes = {})
|
104
|
+
return unless attributes.is_a?(Hash)
|
105
|
+
|
106
|
+
# convert string to symbol for hash key
|
107
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
108
|
+
|
109
|
+
if attributes.has_key?(:'accounting_code')
|
110
|
+
self.accounting_code = attributes[:'accounting_code']
|
111
|
+
end
|
112
|
+
|
113
|
+
if attributes.has_key?(:'card_type_icon')
|
114
|
+
self.card_type_icon = attributes[:'card_type_icon']
|
115
|
+
end
|
116
|
+
|
117
|
+
if attributes.has_key?(:'credit_card')
|
118
|
+
self.credit_card = attributes[:'credit_card']
|
119
|
+
end
|
120
|
+
|
121
|
+
if attributes.has_key?(:'deposit_to_account')
|
122
|
+
self.deposit_to_account = attributes[:'deposit_to_account']
|
123
|
+
end
|
124
|
+
|
125
|
+
if attributes.has_key?(:'enabled')
|
126
|
+
self.enabled = attributes[:'enabled']
|
127
|
+
end
|
128
|
+
|
129
|
+
if attributes.has_key?(:'processing_fee')
|
130
|
+
self.processing_fee = attributes[:'processing_fee']
|
131
|
+
end
|
132
|
+
|
133
|
+
if attributes.has_key?(:'processing_percentage')
|
134
|
+
self.processing_percentage = attributes[:'processing_percentage']
|
135
|
+
end
|
136
|
+
|
137
|
+
if attributes.has_key?(:'surcharge_accounting_code')
|
138
|
+
self.surcharge_accounting_code = attributes[:'surcharge_accounting_code']
|
139
|
+
end
|
140
|
+
|
141
|
+
if attributes.has_key?(:'transaction_fee')
|
142
|
+
self.transaction_fee = attributes[:'transaction_fee']
|
143
|
+
end
|
144
|
+
|
145
|
+
if attributes.has_key?(:'transaction_percentage')
|
146
|
+
self.transaction_percentage = attributes[:'transaction_percentage']
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
151
|
+
# @return Array for valid properties with the reasons
|
152
|
+
def list_invalid_properties
|
153
|
+
invalid_properties = Array.new
|
154
|
+
invalid_properties
|
155
|
+
end
|
156
|
+
|
157
|
+
# Check to see if the all the properties in the model are valid
|
158
|
+
# @return true if the model is valid
|
159
|
+
def valid?
|
160
|
+
credit_card_validator = EnumAttributeValidator.new('String', ['AMEX', 'Visa', 'Diners Club', 'Discover', 'JCB', 'MasterCard'])
|
161
|
+
return false unless credit_card_validator.valid?(@credit_card)
|
162
|
+
true
|
163
|
+
end
|
164
|
+
|
165
|
+
# Custom attribute writer method checking allowed values (enum).
|
166
|
+
# @param [Object] credit_card Object to be assigned
|
167
|
+
def credit_card=(credit_card)
|
168
|
+
validator = EnumAttributeValidator.new('String', ['AMEX', 'Visa', 'Diners Club', 'Discover', 'JCB', 'MasterCard'])
|
169
|
+
unless validator.valid?(credit_card)
|
170
|
+
fail ArgumentError, 'invalid value for "credit_card", must be one of #{validator.allowable_values}.'
|
171
|
+
end
|
172
|
+
@credit_card = credit_card
|
173
|
+
end
|
174
|
+
|
175
|
+
# Checks equality by comparing each attribute.
|
176
|
+
# @param [Object] Object to be compared
|
177
|
+
def ==(o)
|
178
|
+
return true if self.equal?(o)
|
179
|
+
self.class == o.class &&
|
180
|
+
accounting_code == o.accounting_code &&
|
181
|
+
card_type_icon == o.card_type_icon &&
|
182
|
+
credit_card == o.credit_card &&
|
183
|
+
deposit_to_account == o.deposit_to_account &&
|
184
|
+
enabled == o.enabled &&
|
185
|
+
processing_fee == o.processing_fee &&
|
186
|
+
processing_percentage == o.processing_percentage &&
|
187
|
+
surcharge_accounting_code == o.surcharge_accounting_code &&
|
188
|
+
transaction_fee == o.transaction_fee &&
|
189
|
+
transaction_percentage == o.transaction_percentage
|
190
|
+
end
|
191
|
+
|
192
|
+
# @see the `==` method
|
193
|
+
# @param [Object] Object to be compared
|
194
|
+
def eql?(o)
|
195
|
+
self == o
|
196
|
+
end
|
197
|
+
|
198
|
+
# Calculates hash code according to all attributes.
|
199
|
+
# @return [Fixnum] Hash code
|
200
|
+
def hash
|
201
|
+
[accounting_code, card_type_icon, credit_card, deposit_to_account, enabled, processing_fee, processing_percentage, surcharge_accounting_code, transaction_fee, transaction_percentage].hash
|
202
|
+
end
|
203
|
+
|
204
|
+
# Builds the object from hash
|
205
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
206
|
+
# @return [Object] Returns the model itself
|
207
|
+
def build_from_hash(attributes)
|
208
|
+
return nil unless attributes.is_a?(Hash)
|
209
|
+
self.class.swagger_types.each_pair do |key, type|
|
210
|
+
if type =~ /\AArray<(.*)>/i
|
211
|
+
# check to ensure the input is an array given that the attribute
|
212
|
+
# is documented as an array but the input is not
|
213
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
214
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
215
|
+
end
|
216
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
217
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
218
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
219
|
+
end
|
220
|
+
|
221
|
+
self
|
222
|
+
end
|
223
|
+
|
224
|
+
# Deserializes the data based on type
|
225
|
+
# @param string type Data type
|
226
|
+
# @param string value Value to be deserialized
|
227
|
+
# @return [Object] Deserialized data
|
228
|
+
def _deserialize(type, value)
|
229
|
+
case type.to_sym
|
230
|
+
when :DateTime
|
231
|
+
DateTime.parse(value)
|
232
|
+
when :Date
|
233
|
+
Date.parse(value)
|
234
|
+
when :String
|
235
|
+
value.to_s
|
236
|
+
when :Integer
|
237
|
+
value.to_i
|
238
|
+
when :Float
|
239
|
+
value.to_f
|
240
|
+
when :BOOLEAN
|
241
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
242
|
+
true
|
243
|
+
else
|
244
|
+
false
|
245
|
+
end
|
246
|
+
when :Object
|
247
|
+
# generic object (usually a Hash), return directly
|
248
|
+
value
|
249
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
250
|
+
inner_type = Regexp.last_match[:inner_type]
|
251
|
+
value.map { |v| _deserialize(inner_type, v) }
|
252
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
253
|
+
k_type = Regexp.last_match[:k_type]
|
254
|
+
v_type = Regexp.last_match[:v_type]
|
255
|
+
{}.tap do |hash|
|
256
|
+
value.each do |k, v|
|
257
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
else # model
|
261
|
+
temp_model = UltracartClient.const_get(type).new
|
262
|
+
temp_model.build_from_hash(value)
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
# Returns the string representation of the object
|
267
|
+
# @return [String] String presentation of the object
|
268
|
+
def to_s
|
269
|
+
to_hash.to_s
|
270
|
+
end
|
271
|
+
|
272
|
+
# to_body is an alias to to_hash (backward compatibility)
|
273
|
+
# @return [Hash] Returns the object in the form of hash
|
274
|
+
def to_body
|
275
|
+
to_hash
|
276
|
+
end
|
277
|
+
|
278
|
+
# Returns the object in the form of hash
|
279
|
+
# @return [Hash] Returns the object in the form of hash
|
280
|
+
def to_hash
|
281
|
+
hash = {}
|
282
|
+
self.class.attribute_map.each_pair do |attr, param|
|
283
|
+
value = self.send(attr)
|
284
|
+
next if value.nil?
|
285
|
+
hash[param] = _to_hash(value)
|
286
|
+
end
|
287
|
+
hash
|
288
|
+
end
|
289
|
+
|
290
|
+
# Outputs non-array value in the form of hash
|
291
|
+
# For object, use to_hash. Otherwise, just return the value
|
292
|
+
# @param [Object] value Any valid value
|
293
|
+
# @return [Hash] Returns the value in the form of hash
|
294
|
+
def _to_hash(value)
|
295
|
+
if value.is_a?(Array)
|
296
|
+
value.compact.map { |v| _to_hash(v) }
|
297
|
+
elsif value.is_a?(Hash)
|
298
|
+
{}.tap do |hash|
|
299
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
300
|
+
end
|
301
|
+
elsif value.respond_to? :to_hash
|
302
|
+
value.to_hash
|
303
|
+
else
|
304
|
+
value
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
end
|
309
|
+
end
|
@@ -0,0 +1,214 @@
|
|
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 PaymentsConfigurationEcheck
|
17
|
+
# Master flag indicating this merchant accepts eChecks
|
18
|
+
attr_accessor :accept_echeck
|
19
|
+
|
20
|
+
# Optional Quickbooks accounting code
|
21
|
+
attr_accessor :accounting_code
|
22
|
+
|
23
|
+
# Optional Quickbooks deposit to account
|
24
|
+
attr_accessor :deposit_to_account
|
25
|
+
|
26
|
+
attr_accessor :restrictions
|
27
|
+
|
28
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
29
|
+
def self.attribute_map
|
30
|
+
{
|
31
|
+
:'accept_echeck' => :'accept_echeck',
|
32
|
+
:'accounting_code' => :'accounting_code',
|
33
|
+
:'deposit_to_account' => :'deposit_to_account',
|
34
|
+
:'restrictions' => :'restrictions'
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
# Attribute type mapping.
|
39
|
+
def self.swagger_types
|
40
|
+
{
|
41
|
+
:'accept_echeck' => :'BOOLEAN',
|
42
|
+
:'accounting_code' => :'String',
|
43
|
+
:'deposit_to_account' => :'String',
|
44
|
+
:'restrictions' => :'PaymentsConfigurationRestrictions'
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
# Initializes the object
|
49
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
50
|
+
def initialize(attributes = {})
|
51
|
+
return unless attributes.is_a?(Hash)
|
52
|
+
|
53
|
+
# convert string to symbol for hash key
|
54
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
55
|
+
|
56
|
+
if attributes.has_key?(:'accept_echeck')
|
57
|
+
self.accept_echeck = attributes[:'accept_echeck']
|
58
|
+
end
|
59
|
+
|
60
|
+
if attributes.has_key?(:'accounting_code')
|
61
|
+
self.accounting_code = attributes[:'accounting_code']
|
62
|
+
end
|
63
|
+
|
64
|
+
if attributes.has_key?(:'deposit_to_account')
|
65
|
+
self.deposit_to_account = attributes[:'deposit_to_account']
|
66
|
+
end
|
67
|
+
|
68
|
+
if attributes.has_key?(:'restrictions')
|
69
|
+
self.restrictions = attributes[:'restrictions']
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
74
|
+
# @return Array for valid properties with the reasons
|
75
|
+
def list_invalid_properties
|
76
|
+
invalid_properties = Array.new
|
77
|
+
invalid_properties
|
78
|
+
end
|
79
|
+
|
80
|
+
# Check to see if the all the properties in the model are valid
|
81
|
+
# @return true if the model is valid
|
82
|
+
def valid?
|
83
|
+
true
|
84
|
+
end
|
85
|
+
|
86
|
+
# Checks equality by comparing each attribute.
|
87
|
+
# @param [Object] Object to be compared
|
88
|
+
def ==(o)
|
89
|
+
return true if self.equal?(o)
|
90
|
+
self.class == o.class &&
|
91
|
+
accept_echeck == o.accept_echeck &&
|
92
|
+
accounting_code == o.accounting_code &&
|
93
|
+
deposit_to_account == o.deposit_to_account &&
|
94
|
+
restrictions == o.restrictions
|
95
|
+
end
|
96
|
+
|
97
|
+
# @see the `==` method
|
98
|
+
# @param [Object] Object to be compared
|
99
|
+
def eql?(o)
|
100
|
+
self == o
|
101
|
+
end
|
102
|
+
|
103
|
+
# Calculates hash code according to all attributes.
|
104
|
+
# @return [Fixnum] Hash code
|
105
|
+
def hash
|
106
|
+
[accept_echeck, accounting_code, deposit_to_account, restrictions].hash
|
107
|
+
end
|
108
|
+
|
109
|
+
# Builds the object from hash
|
110
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
111
|
+
# @return [Object] Returns the model itself
|
112
|
+
def build_from_hash(attributes)
|
113
|
+
return nil unless attributes.is_a?(Hash)
|
114
|
+
self.class.swagger_types.each_pair do |key, type|
|
115
|
+
if 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 # or else data not found in attributes(hash), not an issue as the data can be optional
|
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 :DateTime
|
136
|
+
DateTime.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
|
+
temp_model = UltracartClient.const_get(type).new
|
167
|
+
temp_model.build_from_hash(value)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# Returns the string representation of the object
|
172
|
+
# @return [String] String presentation of the object
|
173
|
+
def to_s
|
174
|
+
to_hash.to_s
|
175
|
+
end
|
176
|
+
|
177
|
+
# to_body is an alias to to_hash (backward compatibility)
|
178
|
+
# @return [Hash] Returns the object in the form of hash
|
179
|
+
def to_body
|
180
|
+
to_hash
|
181
|
+
end
|
182
|
+
|
183
|
+
# Returns the object in the form of hash
|
184
|
+
# @return [Hash] Returns the object in the form of hash
|
185
|
+
def to_hash
|
186
|
+
hash = {}
|
187
|
+
self.class.attribute_map.each_pair do |attr, param|
|
188
|
+
value = self.send(attr)
|
189
|
+
next if value.nil?
|
190
|
+
hash[param] = _to_hash(value)
|
191
|
+
end
|
192
|
+
hash
|
193
|
+
end
|
194
|
+
|
195
|
+
# Outputs non-array value in the form of hash
|
196
|
+
# For object, use to_hash. Otherwise, just return the value
|
197
|
+
# @param [Object] value Any valid value
|
198
|
+
# @return [Hash] Returns the value in the form of hash
|
199
|
+
def _to_hash(value)
|
200
|
+
if value.is_a?(Array)
|
201
|
+
value.compact.map { |v| _to_hash(v) }
|
202
|
+
elsif value.is_a?(Hash)
|
203
|
+
{}.tap do |hash|
|
204
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
205
|
+
end
|
206
|
+
elsif value.respond_to? :to_hash
|
207
|
+
value.to_hash
|
208
|
+
else
|
209
|
+
value
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
end
|
214
|
+
end
|