zip_money 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/Gemfile.lock +69 -0
  4. data/README.md +128 -0
  5. data/Rakefile +8 -0
  6. data/docs/Address.md +15 -0
  7. data/docs/Authority.md +9 -0
  8. data/docs/CaptureChargeRequest.md +8 -0
  9. data/docs/Charge.md +17 -0
  10. data/docs/ChargeCollection.md +8 -0
  11. data/docs/ChargeOrder.md +11 -0
  12. data/docs/ChargesApi.md +307 -0
  13. data/docs/Checkout.md +18 -0
  14. data/docs/CheckoutConfiguration.md +8 -0
  15. data/docs/CheckoutFeatures.md +8 -0
  16. data/docs/CheckoutFeaturesTokenisation.md +8 -0
  17. data/docs/CheckoutOrder.md +13 -0
  18. data/docs/CheckoutsApi.md +119 -0
  19. data/docs/CreateChargeRequest.md +14 -0
  20. data/docs/CreateCheckoutRequest.md +13 -0
  21. data/docs/CreateCheckoutRequestFeatures.md +8 -0
  22. data/docs/CreateCheckoutRequestFeaturesTokenisation.md +8 -0
  23. data/docs/CreateRefundRequest.md +11 -0
  24. data/docs/CreateTokenRequest.md +8 -0
  25. data/docs/Customer.md +15 -0
  26. data/docs/CustomersApi.md +96 -0
  27. data/docs/ErrorResponse.md +8 -0
  28. data/docs/ErrorResponseError.md +10 -0
  29. data/docs/ErrorResponseErrorDetails.md +9 -0
  30. data/docs/InlineResponse200.md +8 -0
  31. data/docs/Metadata.md +7 -0
  32. data/docs/OrderItem.md +16 -0
  33. data/docs/OrderShipping.md +10 -0
  34. data/docs/OrderShippingTracking.md +10 -0
  35. data/docs/Refund.md +13 -0
  36. data/docs/RefundsApi.md +181 -0
  37. data/docs/SettlementsApi.md +96 -0
  38. data/docs/Shopper.md +17 -0
  39. data/docs/ShopperStatistics.md +16 -0
  40. data/docs/Token.md +11 -0
  41. data/docs/TokensApi.md +66 -0
  42. data/lib/zip_money.rb +68 -0
  43. data/lib/zip_money/api/charges_api.rb +301 -0
  44. data/lib/zip_money/api/checkouts_api.rb +120 -0
  45. data/lib/zip_money/api/customers_api.rb +116 -0
  46. data/lib/zip_money/api/refunds_api.rb +181 -0
  47. data/lib/zip_money/api/settlements_api.rb +116 -0
  48. data/lib/zip_money/api/tokens_api.rb +70 -0
  49. data/lib/zip_money/api_client.rb +386 -0
  50. data/lib/zip_money/api_error.rb +31 -0
  51. data/lib/zip_money/configuration.rb +238 -0
  52. data/lib/zip_money/models/address.rb +413 -0
  53. data/lib/zip_money/models/authority.rb +235 -0
  54. data/lib/zip_money/models/capture_charge_request.rb +206 -0
  55. data/lib/zip_money/models/charge.rb +369 -0
  56. data/lib/zip_money/models/charge_collection.rb +188 -0
  57. data/lib/zip_money/models/charge_order.rb +250 -0
  58. data/lib/zip_money/models/checkout.rb +344 -0
  59. data/lib/zip_money/models/checkout_configuration.rb +187 -0
  60. data/lib/zip_money/models/checkout_features.rb +181 -0
  61. data/lib/zip_money/models/checkout_features_tokenisation.rb +184 -0
  62. data/lib/zip_money/models/checkout_order.rb +299 -0
  63. data/lib/zip_money/models/create_charge_request.rb +289 -0
  64. data/lib/zip_money/models/create_checkout_request.rb +272 -0
  65. data/lib/zip_money/models/create_checkout_request_features.rb +181 -0
  66. data/lib/zip_money/models/create_checkout_request_features_tokenisation.rb +189 -0
  67. data/lib/zip_money/models/create_refund_request.rb +246 -0
  68. data/lib/zip_money/models/create_token_request.rb +186 -0
  69. data/lib/zip_money/models/customer.rb +310 -0
  70. data/lib/zip_money/models/error_response.rb +181 -0
  71. data/lib/zip_money/models/error_response_error.rb +211 -0
  72. data/lib/zip_money/models/error_response_error_details.rb +190 -0
  73. data/lib/zip_money/models/inline_response_200.rb +188 -0
  74. data/lib/zip_money/models/metadata.rb +172 -0
  75. data/lib/zip_money/models/order_item.rb +333 -0
  76. data/lib/zip_money/models/order_shipping.rb +200 -0
  77. data/lib/zip_money/models/order_shipping_tracking.rb +247 -0
  78. data/lib/zip_money/models/refund.rb +252 -0
  79. data/lib/zip_money/models/shopper.rb +339 -0
  80. data/lib/zip_money/models/shopper_statistics.rb +295 -0
  81. data/lib/zip_money/models/token.rb +228 -0
  82. data/lib/zip_money/version.rb +8 -0
  83. data/spec/api/charges_api_spec.rb +114 -0
  84. data/spec/api/checkouts_api_spec.rb +54 -0
  85. data/spec/api/customers_api_spec.rb +51 -0
  86. data/spec/api/refunds_api_spec.rb +67 -0
  87. data/spec/api/settlements_api_spec.rb +51 -0
  88. data/spec/api/tokens_api_spec.rb +41 -0
  89. data/spec/api_client_spec.rb +219 -0
  90. data/spec/configuration_spec.rb +50 -0
  91. data/spec/models/address_spec.rb +77 -0
  92. data/spec/models/authority_spec.rb +45 -0
  93. data/spec/models/capture_charge_request_spec.rb +35 -0
  94. data/spec/models/charge_collection_spec.rb +35 -0
  95. data/spec/models/charge_order_spec.rb +53 -0
  96. data/spec/models/charge_spec.rb +93 -0
  97. data/spec/models/checkout_configuration_spec.rb +35 -0
  98. data/spec/models/checkout_features_spec.rb +35 -0
  99. data/spec/models/checkout_features_tokenisation_spec.rb +35 -0
  100. data/spec/models/checkout_order_spec.rb +65 -0
  101. data/spec/models/checkout_spec.rb +103 -0
  102. data/spec/models/create_charge_request_spec.rb +75 -0
  103. data/spec/models/create_checkout_request_features_spec.rb +35 -0
  104. data/spec/models/create_checkout_request_features_tokenisation_spec.rb +35 -0
  105. data/spec/models/create_checkout_request_spec.rb +69 -0
  106. data/spec/models/create_refund_request_spec.rb +53 -0
  107. data/spec/models/create_token_request_spec.rb +35 -0
  108. data/spec/models/customer_spec.rb +81 -0
  109. data/spec/models/error_response_error_details_spec.rb +41 -0
  110. data/spec/models/error_response_error_spec.rb +47 -0
  111. data/spec/models/error_response_spec.rb +35 -0
  112. data/spec/models/inline_response_200_spec.rb +35 -0
  113. data/spec/models/metadata_spec.rb +29 -0
  114. data/spec/models/order_item_spec.rb +87 -0
  115. data/spec/models/order_shipping_spec.rb +47 -0
  116. data/spec/models/order_shipping_tracking_spec.rb +47 -0
  117. data/spec/models/refund_spec.rb +65 -0
  118. data/spec/models/shopper_spec.rb +92 -0
  119. data/spec/models/shopper_statistics_spec.rb +86 -0
  120. data/spec/models/token_spec.rb +52 -0
  121. data/spec/payload_helper.rb +96 -0
  122. data/spec/spec_helper.rb +104 -0
  123. data/zip_money.gemspec +38 -0
  124. metadata +380 -0
@@ -0,0 +1,339 @@
1
+ #Merchant API
2
+ #ZipMoney Merchant API Initial build
3
+ #zipMoney Merchant API version: 2017-03-01
4
+
5
+
6
+ require 'date'
7
+
8
+ module ZipMoney
9
+ # The shopper details
10
+ class Shopper
11
+ # The shopper's title
12
+ attr_accessor :title
13
+
14
+ # The shopper's first name
15
+ attr_accessor :first_name
16
+
17
+ # The shopper's last name
18
+ attr_accessor :last_name
19
+
20
+ # The shopper's middle name
21
+ attr_accessor :middle_name
22
+
23
+ # The shopper's contact phone number
24
+ attr_accessor :phone
25
+
26
+ # The shopper's email address
27
+ attr_accessor :email
28
+
29
+ # The shopper's birth date in the form yyyy-mm-dd
30
+ attr_accessor :birth_date
31
+
32
+ # The shopper's gender
33
+ attr_accessor :gender
34
+
35
+ attr_accessor :statistics
36
+
37
+ attr_accessor :billing_address
38
+
39
+ class EnumAttributeValidator
40
+ attr_reader :datatype
41
+ attr_reader :allowable_values
42
+
43
+ def initialize(datatype, allowable_values)
44
+ @allowable_values = allowable_values.map do |value|
45
+ case datatype.to_s
46
+ when /Integer/i
47
+ value.to_i
48
+ when /Float/i
49
+ value.to_f
50
+ else
51
+ value
52
+ end
53
+ end
54
+ end
55
+
56
+ def valid?(value)
57
+ !value || allowable_values.include?(value)
58
+ end
59
+ end
60
+
61
+ # Attribute mapping from ruby-style variable name to JSON key.
62
+ def self.attribute_map
63
+ {
64
+ :'title' => :'title',
65
+ :'first_name' => :'first_name',
66
+ :'last_name' => :'last_name',
67
+ :'middle_name' => :'middle_name',
68
+ :'phone' => :'phone',
69
+ :'email' => :'email',
70
+ :'birth_date' => :'birth_date',
71
+ :'gender' => :'gender',
72
+ :'statistics' => :'statistics',
73
+ :'billing_address' => :'billing_address'
74
+ }
75
+ end
76
+
77
+ # Attribute type mapping.
78
+ def self.zip_types
79
+ {
80
+ :'title' => :'String',
81
+ :'first_name' => :'String',
82
+ :'last_name' => :'String',
83
+ :'middle_name' => :'String',
84
+ :'phone' => :'String',
85
+ :'email' => :'String',
86
+ :'birth_date' => :'Date',
87
+ :'gender' => :'String',
88
+ :'statistics' => :'ShopperStatistics',
89
+ :'billing_address' => :'Address'
90
+ }
91
+ end
92
+
93
+ # Initializes the object
94
+ # @param [Hash] attributes Model attributes in the form of hash
95
+ def initialize(attributes = {})
96
+ return unless attributes.is_a?(Hash)
97
+
98
+ # convert string to symbol for hash key
99
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
100
+
101
+ if attributes.has_key?(:'title')
102
+ self.title = attributes[:'title']
103
+ end
104
+
105
+ if attributes.has_key?(:'first_name')
106
+ self.first_name = attributes[:'first_name']
107
+ end
108
+
109
+ if attributes.has_key?(:'last_name')
110
+ self.last_name = attributes[:'last_name']
111
+ end
112
+
113
+ if attributes.has_key?(:'middle_name')
114
+ self.middle_name = attributes[:'middle_name']
115
+ end
116
+
117
+ if attributes.has_key?(:'phone')
118
+ self.phone = attributes[:'phone']
119
+ end
120
+
121
+ if attributes.has_key?(:'email')
122
+ self.email = attributes[:'email']
123
+ end
124
+
125
+ if attributes.has_key?(:'birth_date')
126
+ self.birth_date = attributes[:'birth_date']
127
+ end
128
+
129
+ if attributes.has_key?(:'gender')
130
+ self.gender = attributes[:'gender']
131
+ end
132
+
133
+ if attributes.has_key?(:'statistics')
134
+ self.statistics = attributes[:'statistics']
135
+ end
136
+
137
+ if attributes.has_key?(:'billing_address')
138
+ self.billing_address = attributes[:'billing_address']
139
+ end
140
+
141
+ end
142
+
143
+ # Show invalid properties with the reasons. Usually used together with valid?
144
+ # @return Array for valid properies with the reasons
145
+ def list_invalid_properties
146
+ invalid_properties = Array.new
147
+ if @first_name.nil?
148
+ invalid_properties.push("invalid value for 'first_name', first_name cannot be nil.")
149
+ end
150
+
151
+ if @last_name.nil?
152
+ invalid_properties.push("invalid value for 'last_name', last_name cannot be nil.")
153
+ end
154
+
155
+ if !@phone.nil? && @phone !~ Regexp.new(/^\\+?[\\d\\s]+$/)
156
+ invalid_properties.push("invalid value for 'phone', must conform to the pattern /^\\+?[\\d\\s]+$/.")
157
+ end
158
+
159
+ if @email.nil?
160
+ invalid_properties.push("invalid value for 'email', email cannot be nil.")
161
+ end
162
+
163
+ if @billing_address.nil?
164
+ invalid_properties.push("invalid value for 'billing_address', billing_address cannot be nil.")
165
+ end
166
+
167
+ return invalid_properties
168
+ end
169
+
170
+ # Check to see if the all the properties in the model are valid
171
+ # @return true if the model is valid
172
+ def valid?
173
+ return false if @first_name.nil?
174
+ return false if @last_name.nil?
175
+ return false if !@phone.nil? && @phone !~ Regexp.new(/^\\+?[\\d\\s]+$/)
176
+ return false if @email.nil?
177
+ gender_validator = EnumAttributeValidator.new('String', ["Male", "Female", "Other"])
178
+ return false unless gender_validator.valid?(@gender)
179
+ return false if @billing_address.nil?
180
+ return true
181
+ end
182
+
183
+ # Custom attribute writer method with validation
184
+ # @param [Object] phone Value to be assigned
185
+ def phone=(phone)
186
+
187
+ if !phone.nil? && phone !~ Regexp.new(/^\\+?[\\d\\s]+$/)
188
+ fail ArgumentError, "invalid value for 'phone', must conform to the pattern /^\\+?[\\d\\s]+$/."
189
+ end
190
+
191
+ @phone = phone
192
+ end
193
+
194
+ # Custom attribute writer method checking allowed values (enum).
195
+ # @param [Object] gender Object to be assigned
196
+ def gender=(gender)
197
+ validator = EnumAttributeValidator.new('String', ["Male", "Female", "Other"])
198
+ unless validator.valid?(gender)
199
+ fail ArgumentError, "invalid value for 'gender', must be one of #{validator.allowable_values}."
200
+ end
201
+ @gender = gender
202
+ end
203
+
204
+ # Checks equality by comparing each attribute.
205
+ # @param [Object] Object to be compared
206
+ def ==(o)
207
+ return true if self.equal?(o)
208
+ self.class == o.class &&
209
+ title == o.title &&
210
+ first_name == o.first_name &&
211
+ last_name == o.last_name &&
212
+ middle_name == o.middle_name &&
213
+ phone == o.phone &&
214
+ email == o.email &&
215
+ birth_date == o.birth_date &&
216
+ gender == o.gender &&
217
+ statistics == o.statistics &&
218
+ billing_address == o.billing_address
219
+ end
220
+
221
+ # @see the `==` method
222
+ # @param [Object] Object to be compared
223
+ def eql?(o)
224
+ self == o
225
+ end
226
+
227
+ # Calculates hash code according to all attributes.
228
+ # @return [Fixnum] Hash code
229
+ def hash
230
+ [title, first_name, last_name, middle_name, phone, email, birth_date, gender, statistics, billing_address].hash
231
+ end
232
+
233
+ # Builds the object from hash
234
+ # @param [Hash] attributes Model attributes in the form of hash
235
+ # @return [Object] Returns the model itself
236
+ def build_from_hash(attributes)
237
+ return nil unless attributes.is_a?(Hash)
238
+ self.class.zip_types.each_pair do |key, type|
239
+ if type =~ /\AArray<(.*)>/i
240
+ # check to ensure the input is an array given that the the attribute
241
+ # is documented as an array but the input is not
242
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
243
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
244
+ end
245
+ elsif !attributes[self.class.attribute_map[key]].nil?
246
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
247
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
248
+ end
249
+
250
+ self
251
+ end
252
+
253
+ # Deserializes the data based on type
254
+ # @param string type Data type
255
+ # @param string value Value to be deserialized
256
+ # @return [Object] Deserialized data
257
+ def _deserialize(type, value)
258
+ case type.to_sym
259
+ when :DateTime
260
+ DateTime.parse(value)
261
+ when :Date
262
+ Date.parse(value)
263
+ when :String
264
+ value.to_s
265
+ when :Integer
266
+ value.to_i
267
+ when :Float
268
+ value.to_f
269
+ when :BOOLEAN
270
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
271
+ true
272
+ else
273
+ false
274
+ end
275
+ when :Object
276
+ # generic object (usually a Hash), return directly
277
+ value
278
+ when /\AArray<(?<inner_type>.+)>\z/
279
+ inner_type = Regexp.last_match[:inner_type]
280
+ value.map { |v| _deserialize(inner_type, v) }
281
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
282
+ k_type = Regexp.last_match[:k_type]
283
+ v_type = Regexp.last_match[:v_type]
284
+ {}.tap do |hash|
285
+ value.each do |k, v|
286
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
287
+ end
288
+ end
289
+ else # model
290
+ temp_model = ZipMoney.const_get(type).new
291
+ temp_model.build_from_hash(value)
292
+ end
293
+ end
294
+
295
+ # Returns the string representation of the object
296
+ # @return [String] String presentation of the object
297
+ def to_s
298
+ to_hash.to_s
299
+ end
300
+
301
+ # to_body is an alias to to_hash (backward compatibility)
302
+ # @return [Hash] Returns the object in the form of hash
303
+ def to_body
304
+ to_hash
305
+ end
306
+
307
+ # Returns the object in the form of hash
308
+ # @return [Hash] Returns the object in the form of hash
309
+ def to_hash
310
+ hash = {}
311
+ self.class.attribute_map.each_pair do |attr, param|
312
+ value = self.send(attr)
313
+ next if value.nil?
314
+ hash[param] = _to_hash(value)
315
+ end
316
+ hash
317
+ end
318
+
319
+ # Outputs non-array value in the form of hash
320
+ # For object, use to_hash. Otherwise, just return the value
321
+ # @param [Object] value Any valid value
322
+ # @return [Hash] Returns the value in the form of hash
323
+ def _to_hash(value)
324
+ if value.is_a?(Array)
325
+ value.compact.map{ |v| _to_hash(v) }
326
+ elsif value.is_a?(Hash)
327
+ {}.tap do |hash|
328
+ value.each { |k, v| hash[k] = _to_hash(v) }
329
+ end
330
+ elsif value.respond_to? :to_hash
331
+ value.to_hash
332
+ else
333
+ value
334
+ end
335
+ end
336
+
337
+ end
338
+
339
+ end
@@ -0,0 +1,295 @@
1
+ #Merchant API
2
+ #ZipMoney Merchant API Initial build
3
+ #zipMoney Merchant API version: 2017-03-01
4
+
5
+
6
+ require 'date'
7
+
8
+ module ZipMoney
9
+ # Statistics relating to the shopper
10
+ class ShopperStatistics
11
+ # The time at which the shopper's account was created
12
+ attr_accessor :account_created
13
+
14
+ # The total number of separate purchases the shopper has made through the store
15
+ attr_accessor :sales_total_count
16
+
17
+ # The total purchase amount of all orders previously captured through the store.
18
+ attr_accessor :sales_total_amount
19
+
20
+ # The average value of sales made by the shopper through the store
21
+ attr_accessor :sales_avg_amount
22
+
23
+ # The maximum purchase amount the shopper has previously purchased from the store.
24
+ attr_accessor :sales_max_amount
25
+
26
+ # The total amount of all refunds linked to this shopper's account
27
+ attr_accessor :refunds_total_amount
28
+
29
+ # Has the shopper had a previous chargeback?
30
+ attr_accessor :previous_chargeback
31
+
32
+ # The currency of all all amount values
33
+ attr_accessor :currency
34
+
35
+ # The date at which the shopper last logged in to your store.
36
+ attr_accessor :last_login
37
+
38
+ class EnumAttributeValidator
39
+ attr_reader :datatype
40
+ attr_reader :allowable_values
41
+
42
+ def initialize(datatype, allowable_values)
43
+ @allowable_values = allowable_values.map do |value|
44
+ case datatype.to_s
45
+ when /Integer/i
46
+ value.to_i
47
+ when /Float/i
48
+ value.to_f
49
+ else
50
+ value
51
+ end
52
+ end
53
+ end
54
+
55
+ def valid?(value)
56
+ !value || allowable_values.include?(value)
57
+ end
58
+ end
59
+
60
+ # Attribute mapping from ruby-style variable name to JSON key.
61
+ def self.attribute_map
62
+ {
63
+ :'account_created' => :'account_created',
64
+ :'sales_total_count' => :'sales_total_count',
65
+ :'sales_total_amount' => :'sales_total_amount',
66
+ :'sales_avg_amount' => :'sales_avg_amount',
67
+ :'sales_max_amount' => :'sales_max_amount',
68
+ :'refunds_total_amount' => :'refunds_total_amount',
69
+ :'previous_chargeback' => :'previous_chargeback',
70
+ :'currency' => :'currency',
71
+ :'last_login' => :'last_login'
72
+ }
73
+ end
74
+
75
+ # Attribute type mapping.
76
+ def self.zip_types
77
+ {
78
+ :'account_created' => :'DateTime',
79
+ :'sales_total_count' => :'Integer',
80
+ :'sales_total_amount' => :'Float',
81
+ :'sales_avg_amount' => :'Float',
82
+ :'sales_max_amount' => :'Float',
83
+ :'refunds_total_amount' => :'Float',
84
+ :'previous_chargeback' => :'BOOLEAN',
85
+ :'currency' => :'String',
86
+ :'last_login' => :'DateTime'
87
+ }
88
+ end
89
+
90
+ # Initializes the object
91
+ # @param [Hash] attributes Model attributes in the form of hash
92
+ def initialize(attributes = {})
93
+ return unless attributes.is_a?(Hash)
94
+
95
+ # convert string to symbol for hash key
96
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
97
+
98
+ if attributes.has_key?(:'account_created')
99
+ self.account_created = attributes[:'account_created']
100
+ end
101
+
102
+ if attributes.has_key?(:'sales_total_count')
103
+ self.sales_total_count = attributes[:'sales_total_count']
104
+ end
105
+
106
+ if attributes.has_key?(:'sales_total_amount')
107
+ self.sales_total_amount = attributes[:'sales_total_amount']
108
+ end
109
+
110
+ if attributes.has_key?(:'sales_avg_amount')
111
+ self.sales_avg_amount = attributes[:'sales_avg_amount']
112
+ end
113
+
114
+ if attributes.has_key?(:'sales_max_amount')
115
+ self.sales_max_amount = attributes[:'sales_max_amount']
116
+ end
117
+
118
+ if attributes.has_key?(:'refunds_total_amount')
119
+ self.refunds_total_amount = attributes[:'refunds_total_amount']
120
+ end
121
+
122
+ if attributes.has_key?(:'previous_chargeback')
123
+ self.previous_chargeback = attributes[:'previous_chargeback']
124
+ end
125
+
126
+ if attributes.has_key?(:'currency')
127
+ self.currency = attributes[:'currency']
128
+ end
129
+
130
+ if attributes.has_key?(:'last_login')
131
+ self.last_login = attributes[:'last_login']
132
+ end
133
+
134
+ end
135
+
136
+ # Show invalid properties with the reasons. Usually used together with valid?
137
+ # @return Array for valid properies with the reasons
138
+ def list_invalid_properties
139
+ invalid_properties = Array.new
140
+ return invalid_properties
141
+ end
142
+
143
+ # Check to see if the all the properties in the model are valid
144
+ # @return true if the model is valid
145
+ def valid?
146
+ currency_validator = EnumAttributeValidator.new('String', ["AUD", "NZD"])
147
+ return false unless currency_validator.valid?(@currency)
148
+ return true
149
+ end
150
+
151
+ # Custom attribute writer method checking allowed values (enum).
152
+ # @param [Object] currency Object to be assigned
153
+ def currency=(currency)
154
+ validator = EnumAttributeValidator.new('String', ["AUD", "NZD"])
155
+ unless validator.valid?(currency)
156
+ fail ArgumentError, "invalid value for 'currency', must be one of #{validator.allowable_values}."
157
+ end
158
+ @currency = currency
159
+ end
160
+
161
+ # Checks equality by comparing each attribute.
162
+ # @param [Object] Object to be compared
163
+ def ==(o)
164
+ return true if self.equal?(o)
165
+ self.class == o.class &&
166
+ account_created == o.account_created &&
167
+ sales_total_count == o.sales_total_count &&
168
+ sales_total_amount == o.sales_total_amount &&
169
+ sales_avg_amount == o.sales_avg_amount &&
170
+ sales_max_amount == o.sales_max_amount &&
171
+ refunds_total_amount == o.refunds_total_amount &&
172
+ previous_chargeback == o.previous_chargeback &&
173
+ currency == o.currency &&
174
+ last_login == o.last_login
175
+ end
176
+
177
+ # @see the `==` method
178
+ # @param [Object] Object to be compared
179
+ def eql?(o)
180
+ self == o
181
+ end
182
+
183
+ # Calculates hash code according to all attributes.
184
+ # @return [Fixnum] Hash code
185
+ def hash
186
+ [account_created, sales_total_count, sales_total_amount, sales_avg_amount, sales_max_amount, refunds_total_amount, previous_chargeback, currency, last_login].hash
187
+ end
188
+
189
+ # Builds the object from hash
190
+ # @param [Hash] attributes Model attributes in the form of hash
191
+ # @return [Object] Returns the model itself
192
+ def build_from_hash(attributes)
193
+ return nil unless attributes.is_a?(Hash)
194
+ self.class.zip_types.each_pair do |key, type|
195
+ if type =~ /\AArray<(.*)>/i
196
+ # check to ensure the input is an array given that the the attribute
197
+ # is documented as an array but the input is not
198
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
199
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
200
+ end
201
+ elsif !attributes[self.class.attribute_map[key]].nil?
202
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
203
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
204
+ end
205
+
206
+ self
207
+ end
208
+
209
+ # Deserializes the data based on type
210
+ # @param string type Data type
211
+ # @param string value Value to be deserialized
212
+ # @return [Object] Deserialized data
213
+ def _deserialize(type, value)
214
+ case type.to_sym
215
+ when :DateTime
216
+ DateTime.parse(value)
217
+ when :Date
218
+ Date.parse(value)
219
+ when :String
220
+ value.to_s
221
+ when :Integer
222
+ value.to_i
223
+ when :Float
224
+ value.to_f
225
+ when :BOOLEAN
226
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
227
+ true
228
+ else
229
+ false
230
+ end
231
+ when :Object
232
+ # generic object (usually a Hash), return directly
233
+ value
234
+ when /\AArray<(?<inner_type>.+)>\z/
235
+ inner_type = Regexp.last_match[:inner_type]
236
+ value.map { |v| _deserialize(inner_type, v) }
237
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
238
+ k_type = Regexp.last_match[:k_type]
239
+ v_type = Regexp.last_match[:v_type]
240
+ {}.tap do |hash|
241
+ value.each do |k, v|
242
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
243
+ end
244
+ end
245
+ else # model
246
+ temp_model = ZipMoney.const_get(type).new
247
+ temp_model.build_from_hash(value)
248
+ end
249
+ end
250
+
251
+ # Returns the string representation of the object
252
+ # @return [String] String presentation of the object
253
+ def to_s
254
+ to_hash.to_s
255
+ end
256
+
257
+ # to_body is an alias to to_hash (backward compatibility)
258
+ # @return [Hash] Returns the object in the form of hash
259
+ def to_body
260
+ to_hash
261
+ end
262
+
263
+ # Returns the object in the form of hash
264
+ # @return [Hash] Returns the object in the form of hash
265
+ def to_hash
266
+ hash = {}
267
+ self.class.attribute_map.each_pair do |attr, param|
268
+ value = self.send(attr)
269
+ next if value.nil?
270
+ hash[param] = _to_hash(value)
271
+ end
272
+ hash
273
+ end
274
+
275
+ # Outputs non-array value in the form of hash
276
+ # For object, use to_hash. Otherwise, just return the value
277
+ # @param [Object] value Any valid value
278
+ # @return [Hash] Returns the value in the form of hash
279
+ def _to_hash(value)
280
+ if value.is_a?(Array)
281
+ value.compact.map{ |v| _to_hash(v) }
282
+ elsif value.is_a?(Hash)
283
+ {}.tap do |hash|
284
+ value.each { |k, v| hash[k] = _to_hash(v) }
285
+ end
286
+ elsif value.respond_to? :to_hash
287
+ value.to_hash
288
+ else
289
+ value
290
+ end
291
+ end
292
+
293
+ end
294
+
295
+ end