citypay_api_client 1.0.0

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 (115) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +176 -0
  4. data/Rakefile +10 -0
  5. data/citypay_api_client.gemspec +39 -0
  6. data/docs/AccountCreate.md +19 -0
  7. data/docs/AccountStatus.md +17 -0
  8. data/docs/Acknowledgement.md +23 -0
  9. data/docs/AirlineAdvice.md +47 -0
  10. data/docs/AirlineSegment.md +31 -0
  11. data/docs/AuthReference.md +43 -0
  12. data/docs/AuthReferences.md +17 -0
  13. data/docs/AuthRequest.md +59 -0
  14. data/docs/AuthResponse.md +69 -0
  15. data/docs/AuthenRequired.md +21 -0
  16. data/docs/CResAuthRequest.md +17 -0
  17. data/docs/CaptureRequest.md +27 -0
  18. data/docs/Card.md +51 -0
  19. data/docs/CardHolderAccount.md +31 -0
  20. data/docs/CardHolderAccountApi.md +515 -0
  21. data/docs/CardStatus.md +19 -0
  22. data/docs/ChargeRequest.md +41 -0
  23. data/docs/ContactDetails.md +41 -0
  24. data/docs/Decision.md +21 -0
  25. data/docs/Error.md +23 -0
  26. data/docs/ExternalMPI.md +25 -0
  27. data/docs/ListMerchantsResponse.md +21 -0
  28. data/docs/MCC6012.md +23 -0
  29. data/docs/Merchant.md +25 -0
  30. data/docs/OperationalApi.md +118 -0
  31. data/docs/PaResAuthRequest.md +19 -0
  32. data/docs/PaymentProcessingApi.md +338 -0
  33. data/docs/Ping.md +17 -0
  34. data/docs/RegisterCard.md +23 -0
  35. data/docs/RequestChallenged.md +25 -0
  36. data/docs/RetrieveRequest.md +21 -0
  37. data/docs/ThreeDSecure.md +25 -0
  38. data/docs/VoidRequest.md +23 -0
  39. data/git_push.sh +58 -0
  40. data/lib/citypay_api_client.rb +72 -0
  41. data/lib/citypay_api_client/api/card_holder_account_api.rb +628 -0
  42. data/lib/citypay_api_client/api/operational_api.rb +148 -0
  43. data/lib/citypay_api_client/api/payment_processing_api.rb +406 -0
  44. data/lib/citypay_api_client/api_client.rb +388 -0
  45. data/lib/citypay_api_client/api_error.rb +57 -0
  46. data/lib/citypay_api_client/configuration.rb +252 -0
  47. data/lib/citypay_api_client/models/account_create.rb +249 -0
  48. data/lib/citypay_api_client/models/account_status.rb +207 -0
  49. data/lib/citypay_api_client/models/acknowledgement.rb +285 -0
  50. data/lib/citypay_api_client/models/airline_advice.rb +551 -0
  51. data/lib/citypay_api_client/models/airline_segment.rb +408 -0
  52. data/lib/citypay_api_client/models/api_key.rb +53 -0
  53. data/lib/citypay_api_client/models/auth_reference.rb +400 -0
  54. data/lib/citypay_api_client/models/auth_references.rb +208 -0
  55. data/lib/citypay_api_client/models/auth_request.rb +631 -0
  56. data/lib/citypay_api_client/models/auth_response.rb +563 -0
  57. data/lib/citypay_api_client/models/authen_required.rb +227 -0
  58. data/lib/citypay_api_client/models/c_res_auth_request.rb +207 -0
  59. data/lib/citypay_api_client/models/capture_request.rb +285 -0
  60. data/lib/citypay_api_client/models/card.rb +425 -0
  61. data/lib/citypay_api_client/models/card_holder_account.rb +315 -0
  62. data/lib/citypay_api_client/models/card_status.rb +217 -0
  63. data/lib/citypay_api_client/models/charge_request.rb +453 -0
  64. data/lib/citypay_api_client/models/contact_details.rb +456 -0
  65. data/lib/citypay_api_client/models/decision.rb +224 -0
  66. data/lib/citypay_api_client/models/error.rb +285 -0
  67. data/lib/citypay_api_client/models/external_mpi.rb +307 -0
  68. data/lib/citypay_api_client/models/list_merchants_response.rb +252 -0
  69. data/lib/citypay_api_client/models/mcc6012.rb +237 -0
  70. data/lib/citypay_api_client/models/merchant.rb +247 -0
  71. data/lib/citypay_api_client/models/pa_res_auth_request.rb +227 -0
  72. data/lib/citypay_api_client/models/ping.rb +231 -0
  73. data/lib/citypay_api_client/models/register_card.rb +336 -0
  74. data/lib/citypay_api_client/models/request_challenged.rb +247 -0
  75. data/lib/citypay_api_client/models/retrieve_request.rb +256 -0
  76. data/lib/citypay_api_client/models/three_d_secure.rb +247 -0
  77. data/lib/citypay_api_client/models/void_request.rb +266 -0
  78. data/lib/citypay_api_client/version.rb +15 -0
  79. data/spec/api/card_holder_account_api_spec.rb +149 -0
  80. data/spec/api/operational_api_spec.rb +59 -0
  81. data/spec/api/payment_processing_api_spec.rb +107 -0
  82. data/spec/api_client_spec.rb +226 -0
  83. data/spec/configuration_spec.rb +42 -0
  84. data/spec/models/account_create_spec.rb +47 -0
  85. data/spec/models/account_status_spec.rb +41 -0
  86. data/spec/models/acknowledgement_spec.rb +59 -0
  87. data/spec/models/airline_advice_spec.rb +131 -0
  88. data/spec/models/airline_segment_spec.rb +83 -0
  89. data/spec/models/auth_reference_spec.rb +119 -0
  90. data/spec/models/auth_references_spec.rb +41 -0
  91. data/spec/models/auth_request_spec.rb +167 -0
  92. data/spec/models/auth_response_spec.rb +197 -0
  93. data/spec/models/authen_required_spec.rb +53 -0
  94. data/spec/models/c_res_auth_request_spec.rb +41 -0
  95. data/spec/models/capture_request_spec.rb +71 -0
  96. data/spec/models/card_holder_account_spec.rb +83 -0
  97. data/spec/models/card_spec.rb +143 -0
  98. data/spec/models/card_status_spec.rb +47 -0
  99. data/spec/models/charge_request_spec.rb +113 -0
  100. data/spec/models/contact_details_spec.rb +113 -0
  101. data/spec/models/decision_spec.rb +53 -0
  102. data/spec/models/error_spec.rb +59 -0
  103. data/spec/models/external_mpi_spec.rb +65 -0
  104. data/spec/models/list_merchants_response_spec.rb +53 -0
  105. data/spec/models/mcc6012_spec.rb +59 -0
  106. data/spec/models/merchant_spec.rb +65 -0
  107. data/spec/models/pa_res_auth_request_spec.rb +47 -0
  108. data/spec/models/ping_spec.rb +41 -0
  109. data/spec/models/register_card_spec.rb +59 -0
  110. data/spec/models/request_challenged_spec.rb +65 -0
  111. data/spec/models/retrieve_request_spec.rb +53 -0
  112. data/spec/models/three_d_secure_spec.rb +65 -0
  113. data/spec/models/void_request_spec.rb +59 -0
  114. data/spec/spec_helper.rb +111 -0
  115. metadata +252 -0
@@ -0,0 +1,631 @@
1
+ =begin
2
+ #CityPay Payment API
3
+
4
+ # This CityPay API is a HTTP RESTful payment API used for direct server to server transactional processing. It provides a number of payment mechanisms including: Internet, MOTO, Continuous Authority transaction processing, 3-D Secure decision handling using RFA Secure, Authorisation, Refunding, Pre-Authorisation, Cancellation/Voids and Completion processing. The API is also capable of tokinsed payments using Card Holder Accounts. ## Compliance and Security <aside class=\"notice\"> Before we begin a reminder that your application will need to adhere to PCI-DSS standards to operate safely and to meet requirements set out by Visa and MasterCard and the PCI Security Standards Council including: </aside> * Data must be collected using TLS version 1.2 using [strong cryptography](#enabled-tls-ciphers). We will not accept calls to our API at lower grade encryption levels. We regularly scan our TLS endpoints for vulnerabilities and perform TLS assessments as part of our compliance program. * The application must not store sensitive card holder data (CHD) such as the card security code (CSC) or primary access number (PAN) * The application must not display the full card number on receipts, it is recommended to mask the PAN and show the last 4 digits. The API will return this for you for ease of receipt creation * If you are developing a website, you will be required to perform regular scans on the network where you host the application to meet your compliance obligations * You will be required to be PCI Compliant and the application must adhere to the security standard. Further information is available from [https://www.pcisecuritystandards.org/](https://www.pcisecuritystandards.org/) * The API verifies that the request is for a valid account and originates from a trusted source using the remote IP address. Our application firewalls analyse data that may be an attempt to break a large number of security common security vulnerabilities.
5
+
6
+ The version of the OpenAPI document: 6.0.0
7
+ Contact: support@citypay.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module CityPayApiClient
16
+ class AuthRequest
17
+ attr_accessor :airline_data
18
+
19
+ # The amount to authorise in the lowest unit of currency with a variable length to a maximum of 12 digits. No decimal points are to be included and no divisional characters such as 1,024. The amount should be the total amount required for the transaction. For example with GBP £1,021.95 the amount value is 102195.
20
+ attr_accessor :amount
21
+
22
+ # A policy value which determines whether an AVS postcode policy is enforced or bypassed. Values are `0` for the default policy (default value if not supplied). Your default values are determined by your account manager on setup of the account. `1` for an enforced policy. Transactions that are enforced will be rejected if the AVS postcode numeric value does not match. `2` to bypass. Transactions that are bypassed will be allowed through even if the postcode did not match. `3` to ignore. Transactions that are ignored will bypass the result and not send postcode details for authorisation.
23
+ attr_accessor :avs_postcode_policy
24
+
25
+ attr_accessor :bill_to
26
+
27
+ # The card holder name as appears on the card such as MR N E BODY. Required for some acquirers.
28
+ attr_accessor :card_holder_name
29
+
30
+ # The card number (PAN) with a variable length to a maximum of 21 digits in numerical form. Any non numeric characters will be stripped out of the card number, this includes whitespace or separators internal of the provided value. The card number must be treated as sensitive data. We only provide an obfuscated value in logging and reporting. The plaintext value is encrypted in our database using AES 256 GMC bit encryption for settlement or refund purposes. When providing the card number to our gateway through the authorisation API you will be handling the card data on your application. This will require further PCI controls to be in place and this value must never be stored.
31
+ attr_accessor :cardnumber
32
+
33
+ # The Card Security Code (CSC) (also known as CV2/CVV2) is normally found on the back of the card (American Express has it on the front). The value helps to identify posession of the card as it is not available within the chip or magnetic swipe. When forwarding the CSC, please ensure the value is a string as some values start with 0 and this will be stripped out by any integer parsing. The CSC number aids fraud prevention in Mail Order and Internet payments. Business rules are available on your account to identify whether to accept or decline transactions based on mismatched results of the CSC. The Payment Card Industry (PCI) requires that at no stage of a transaction should the CSC be stored. This applies to all entities handling card data. It should also not be used in any hashing process. CityPay do not store the value and have no method of retrieving the value once the transaction has been processed. For this reason, duplicate checking is unable to determine the CSC in its duplication check algorithm.
34
+ attr_accessor :csc
35
+
36
+ # A policy value which determines whether a CSC policy is enforced or bypassed. Values are `0` for the default policy (default value if not supplied). Your default values are determined by your account manager on setup of the account. `1` for an enforced policy. Transactions that are enforced will be rejected if the CSC value does not match. `2` to bypass. Transactions that are bypassed will be allowed through even if the CSC did not match. `3` to ignore. Transactions that are ignored will bypass the result and not send the CSC details for authorisation.
37
+ attr_accessor :csc_policy
38
+
39
+ # The processing currency for the transaction. Will default to the merchant account currency.
40
+ attr_accessor :currency
41
+
42
+ # A policy value which determines whether a duplication policy is enforced or bypassed. A duplication check has a window of time set against your account within which it can action. If a previous transaction with matching values occurred within the window, any subsequent transaction will result in a T001 result. Values are `0` for the default policy (default value if not supplied). Your default values are determined by your account manager on setup of the account. `1` for an enforced policy. Transactions that are enforced will be checked for duplication within the duplication window. `2` to bypass. Transactions that are bypassed will not be checked for duplication within the duplication window. `3` to ignore. Transactions that are ignored will have the same affect as bypass.
43
+ attr_accessor :duplicate_policy
44
+
45
+ # The month of expiry of the card. The month value should be a numerical value between 1 and 12.
46
+ attr_accessor :expmonth
47
+
48
+ # The year of expiry of the card.
49
+ attr_accessor :expyear
50
+
51
+ attr_accessor :external_mpi
52
+
53
+ # The identifier of the transaction to process. The value should be a valid reference and may be used to perform post processing actions and to aid in reconciliation of transactions. The value should be a valid printable string with ASCII character ranges from 32 to 127. The identifier is recommended to be distinct for each transaction such as a [random unique identifier](https://en.wikipedia.org/wiki/Universally_unique_identifier) this will aid in ensuring each transaction is identifiable. When transactions are processed they are also checked for duplicate requests. Changing the identifier on a subsequent request will ensure that a transaction is considered as different.
54
+ attr_accessor :identifier
55
+
56
+ # A policy value which determines whether an AVS address policy is enforced, bypassed or ignored. Values are `0` for the default policy (default value if not supplied). Your default values are determined by your account manager on setup of the account. `1` for an enforced policy. Transactions that are enforced will be rejected if the AVS address numeric value does not match. `2` to bypass. Transactions that are bypassed will be allowed through even if the address did not match. `3` to ignore. Transactions that are ignored will bypass the result and not send address numeric details for authorisation.
57
+ attr_accessor :match_avsa
58
+
59
+ attr_accessor :mcc6012
60
+
61
+ # Identifies the merchant account to perform processing for.
62
+ attr_accessor :merchantid
63
+
64
+ # An optional reference value for the calling client such as a version number i.e.
65
+ attr_accessor :sdk
66
+
67
+ attr_accessor :ship_to
68
+
69
+ attr_accessor :threedsecure
70
+
71
+ # Further information that can be added to the transaction will display in reporting. Can be used for flexible values such as operator id.
72
+ attr_accessor :trans_info
73
+
74
+ # The type of transaction being submitted. Normally this value is not required and your account manager may request that you set this field.
75
+ attr_accessor :trans_type
76
+
77
+ # Attribute mapping from ruby-style variable name to JSON key.
78
+ def self.attribute_map
79
+ {
80
+ :'airline_data' => :'airline_data',
81
+ :'amount' => :'amount',
82
+ :'avs_postcode_policy' => :'avs_postcode_policy',
83
+ :'bill_to' => :'bill_to',
84
+ :'card_holder_name' => :'card_holder_name',
85
+ :'cardnumber' => :'cardnumber',
86
+ :'csc' => :'csc',
87
+ :'csc_policy' => :'csc_policy',
88
+ :'currency' => :'currency',
89
+ :'duplicate_policy' => :'duplicate_policy',
90
+ :'expmonth' => :'expmonth',
91
+ :'expyear' => :'expyear',
92
+ :'external_mpi' => :'external_mpi',
93
+ :'identifier' => :'identifier',
94
+ :'match_avsa' => :'match_avsa',
95
+ :'mcc6012' => :'mcc6012',
96
+ :'merchantid' => :'merchantid',
97
+ :'sdk' => :'sdk',
98
+ :'ship_to' => :'ship_to',
99
+ :'threedsecure' => :'threedsecure',
100
+ :'trans_info' => :'trans_info',
101
+ :'trans_type' => :'trans_type'
102
+ }
103
+ end
104
+
105
+ # Attribute type mapping.
106
+ def self.openapi_types
107
+ {
108
+ :'airline_data' => :'AirlineAdvice',
109
+ :'amount' => :'Integer',
110
+ :'avs_postcode_policy' => :'String',
111
+ :'bill_to' => :'ContactDetails',
112
+ :'card_holder_name' => :'String',
113
+ :'cardnumber' => :'String',
114
+ :'csc' => :'String',
115
+ :'csc_policy' => :'String',
116
+ :'currency' => :'String',
117
+ :'duplicate_policy' => :'String',
118
+ :'expmonth' => :'Integer',
119
+ :'expyear' => :'Integer',
120
+ :'external_mpi' => :'ExternalMPI',
121
+ :'identifier' => :'String',
122
+ :'match_avsa' => :'String',
123
+ :'mcc6012' => :'MCC6012',
124
+ :'merchantid' => :'Integer',
125
+ :'sdk' => :'String',
126
+ :'ship_to' => :'ContactDetails',
127
+ :'threedsecure' => :'ThreeDSecure',
128
+ :'trans_info' => :'String',
129
+ :'trans_type' => :'String'
130
+ }
131
+ end
132
+
133
+ # List of attributes with nullable: true
134
+ def self.openapi_nullable
135
+ Set.new([
136
+ ])
137
+ end
138
+
139
+ # Initializes the object
140
+ # @param [Hash] attributes Model attributes in the form of hash
141
+ def initialize(attributes = {})
142
+ if (!attributes.is_a?(Hash))
143
+ fail ArgumentError, "The input argument (attributes) must be a hash in `CityPayApiClient::AuthRequest` initialize method"
144
+ end
145
+
146
+ # check to see if the attribute exists and convert string to symbol for hash key
147
+ attributes = attributes.each_with_object({}) { |(k, v), h|
148
+ if (!self.class.attribute_map.key?(k.to_sym))
149
+ fail ArgumentError, "`#{k}` is not a valid attribute in `CityPayApiClient::AuthRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
150
+ end
151
+ h[k.to_sym] = v
152
+ }
153
+
154
+ if attributes.key?(:'airline_data')
155
+ self.airline_data = attributes[:'airline_data']
156
+ end
157
+
158
+ if attributes.key?(:'amount')
159
+ self.amount = attributes[:'amount']
160
+ end
161
+
162
+ if attributes.key?(:'avs_postcode_policy')
163
+ self.avs_postcode_policy = attributes[:'avs_postcode_policy']
164
+ end
165
+
166
+ if attributes.key?(:'bill_to')
167
+ self.bill_to = attributes[:'bill_to']
168
+ end
169
+
170
+ if attributes.key?(:'card_holder_name')
171
+ self.card_holder_name = attributes[:'card_holder_name']
172
+ end
173
+
174
+ if attributes.key?(:'cardnumber')
175
+ self.cardnumber = attributes[:'cardnumber']
176
+ end
177
+
178
+ if attributes.key?(:'csc')
179
+ self.csc = attributes[:'csc']
180
+ end
181
+
182
+ if attributes.key?(:'csc_policy')
183
+ self.csc_policy = attributes[:'csc_policy']
184
+ end
185
+
186
+ if attributes.key?(:'currency')
187
+ self.currency = attributes[:'currency']
188
+ end
189
+
190
+ if attributes.key?(:'duplicate_policy')
191
+ self.duplicate_policy = attributes[:'duplicate_policy']
192
+ end
193
+
194
+ if attributes.key?(:'expmonth')
195
+ self.expmonth = attributes[:'expmonth']
196
+ end
197
+
198
+ if attributes.key?(:'expyear')
199
+ self.expyear = attributes[:'expyear']
200
+ end
201
+
202
+ if attributes.key?(:'external_mpi')
203
+ self.external_mpi = attributes[:'external_mpi']
204
+ end
205
+
206
+ if attributes.key?(:'identifier')
207
+ self.identifier = attributes[:'identifier']
208
+ end
209
+
210
+ if attributes.key?(:'match_avsa')
211
+ self.match_avsa = attributes[:'match_avsa']
212
+ end
213
+
214
+ if attributes.key?(:'mcc6012')
215
+ self.mcc6012 = attributes[:'mcc6012']
216
+ end
217
+
218
+ if attributes.key?(:'merchantid')
219
+ self.merchantid = attributes[:'merchantid']
220
+ end
221
+
222
+ if attributes.key?(:'sdk')
223
+ self.sdk = attributes[:'sdk']
224
+ end
225
+
226
+ if attributes.key?(:'ship_to')
227
+ self.ship_to = attributes[:'ship_to']
228
+ end
229
+
230
+ if attributes.key?(:'threedsecure')
231
+ self.threedsecure = attributes[:'threedsecure']
232
+ end
233
+
234
+ if attributes.key?(:'trans_info')
235
+ self.trans_info = attributes[:'trans_info']
236
+ end
237
+
238
+ if attributes.key?(:'trans_type')
239
+ self.trans_type = attributes[:'trans_type']
240
+ end
241
+ end
242
+
243
+ # Show invalid properties with the reasons. Usually used together with valid?
244
+ # @return Array for valid properties with the reasons
245
+ def list_invalid_properties
246
+ invalid_properties = Array.new
247
+ if @amount.nil?
248
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.')
249
+ end
250
+
251
+ if @cardnumber.nil?
252
+ invalid_properties.push('invalid value for "cardnumber", cardnumber cannot be nil.')
253
+ end
254
+
255
+ if @cardnumber.to_s.length > 22
256
+ invalid_properties.push('invalid value for "cardnumber", the character length must be smaller than or equal to 22.')
257
+ end
258
+
259
+ if @cardnumber.to_s.length < 12
260
+ invalid_properties.push('invalid value for "cardnumber", the character length must be great than or equal to 12.')
261
+ end
262
+
263
+ if !@csc.nil? && @csc.to_s.length > 4
264
+ invalid_properties.push('invalid value for "csc", the character length must be smaller than or equal to 4.')
265
+ end
266
+
267
+ if !@csc.nil? && @csc.to_s.length < 3
268
+ invalid_properties.push('invalid value for "csc", the character length must be great than or equal to 3.')
269
+ end
270
+
271
+ if !@currency.nil? && @currency.to_s.length > 3
272
+ invalid_properties.push('invalid value for "currency", the character length must be smaller than or equal to 3.')
273
+ end
274
+
275
+ if !@currency.nil? && @currency.to_s.length < 3
276
+ invalid_properties.push('invalid value for "currency", the character length must be great than or equal to 3.')
277
+ end
278
+
279
+ if @expmonth.nil?
280
+ invalid_properties.push('invalid value for "expmonth", expmonth cannot be nil.')
281
+ end
282
+
283
+ if @expmonth > 12
284
+ invalid_properties.push('invalid value for "expmonth", must be smaller than or equal to 12.')
285
+ end
286
+
287
+ if @expmonth < 1
288
+ invalid_properties.push('invalid value for "expmonth", must be greater than or equal to 1.')
289
+ end
290
+
291
+ if @expyear.nil?
292
+ invalid_properties.push('invalid value for "expyear", expyear cannot be nil.')
293
+ end
294
+
295
+ if @expyear > 2100
296
+ invalid_properties.push('invalid value for "expyear", must be smaller than or equal to 2100.')
297
+ end
298
+
299
+ if @expyear < 2000
300
+ invalid_properties.push('invalid value for "expyear", must be greater than or equal to 2000.')
301
+ end
302
+
303
+ if @identifier.nil?
304
+ invalid_properties.push('invalid value for "identifier", identifier cannot be nil.')
305
+ end
306
+
307
+ if @identifier.to_s.length > 50
308
+ invalid_properties.push('invalid value for "identifier", the character length must be smaller than or equal to 50.')
309
+ end
310
+
311
+ if @identifier.to_s.length < 4
312
+ invalid_properties.push('invalid value for "identifier", the character length must be great than or equal to 4.')
313
+ end
314
+
315
+ if @merchantid.nil?
316
+ invalid_properties.push('invalid value for "merchantid", merchantid cannot be nil.')
317
+ end
318
+
319
+ if !@trans_info.nil? && @trans_info.to_s.length > 50
320
+ invalid_properties.push('invalid value for "trans_info", the character length must be smaller than or equal to 50.')
321
+ end
322
+
323
+ if !@trans_type.nil? && @trans_type.to_s.length > 1
324
+ invalid_properties.push('invalid value for "trans_type", the character length must be smaller than or equal to 1.')
325
+ end
326
+
327
+ invalid_properties
328
+ end
329
+
330
+ # Check to see if the all the properties in the model are valid
331
+ # @return true if the model is valid
332
+ def valid?
333
+ return false if @amount.nil?
334
+ return false if @cardnumber.nil?
335
+ return false if @cardnumber.to_s.length > 22
336
+ return false if @cardnumber.to_s.length < 12
337
+ return false if !@csc.nil? && @csc.to_s.length > 4
338
+ return false if !@csc.nil? && @csc.to_s.length < 3
339
+ return false if !@currency.nil? && @currency.to_s.length > 3
340
+ return false if !@currency.nil? && @currency.to_s.length < 3
341
+ return false if @expmonth.nil?
342
+ return false if @expmonth > 12
343
+ return false if @expmonth < 1
344
+ return false if @expyear.nil?
345
+ return false if @expyear > 2100
346
+ return false if @expyear < 2000
347
+ return false if @identifier.nil?
348
+ return false if @identifier.to_s.length > 50
349
+ return false if @identifier.to_s.length < 4
350
+ return false if @merchantid.nil?
351
+ return false if !@trans_info.nil? && @trans_info.to_s.length > 50
352
+ return false if !@trans_type.nil? && @trans_type.to_s.length > 1
353
+ true
354
+ end
355
+
356
+ # Custom attribute writer method with validation
357
+ # @param [Object] cardnumber Value to be assigned
358
+ def cardnumber=(cardnumber)
359
+ if cardnumber.nil?
360
+ fail ArgumentError, 'cardnumber cannot be nil'
361
+ end
362
+
363
+ if cardnumber.to_s.length > 22
364
+ fail ArgumentError, 'invalid value for "cardnumber", the character length must be smaller than or equal to 22.'
365
+ end
366
+
367
+ if cardnumber.to_s.length < 12
368
+ fail ArgumentError, 'invalid value for "cardnumber", the character length must be great than or equal to 12.'
369
+ end
370
+
371
+ @cardnumber = cardnumber
372
+ end
373
+
374
+ # Custom attribute writer method with validation
375
+ # @param [Object] csc Value to be assigned
376
+ def csc=(csc)
377
+ if !csc.nil? && csc.to_s.length > 4
378
+ fail ArgumentError, 'invalid value for "csc", the character length must be smaller than or equal to 4.'
379
+ end
380
+
381
+ if !csc.nil? && csc.to_s.length < 3
382
+ fail ArgumentError, 'invalid value for "csc", the character length must be great than or equal to 3.'
383
+ end
384
+
385
+ @csc = csc
386
+ end
387
+
388
+ # Custom attribute writer method with validation
389
+ # @param [Object] currency Value to be assigned
390
+ def currency=(currency)
391
+ if !currency.nil? && currency.to_s.length > 3
392
+ fail ArgumentError, 'invalid value for "currency", the character length must be smaller than or equal to 3.'
393
+ end
394
+
395
+ if !currency.nil? && currency.to_s.length < 3
396
+ fail ArgumentError, 'invalid value for "currency", the character length must be great than or equal to 3.'
397
+ end
398
+
399
+ @currency = currency
400
+ end
401
+
402
+ # Custom attribute writer method with validation
403
+ # @param [Object] expmonth Value to be assigned
404
+ def expmonth=(expmonth)
405
+ if expmonth.nil?
406
+ fail ArgumentError, 'expmonth cannot be nil'
407
+ end
408
+
409
+ if expmonth > 12
410
+ fail ArgumentError, 'invalid value for "expmonth", must be smaller than or equal to 12.'
411
+ end
412
+
413
+ if expmonth < 1
414
+ fail ArgumentError, 'invalid value for "expmonth", must be greater than or equal to 1.'
415
+ end
416
+
417
+ @expmonth = expmonth
418
+ end
419
+
420
+ # Custom attribute writer method with validation
421
+ # @param [Object] expyear Value to be assigned
422
+ def expyear=(expyear)
423
+ if expyear.nil?
424
+ fail ArgumentError, 'expyear cannot be nil'
425
+ end
426
+
427
+ if expyear > 2100
428
+ fail ArgumentError, 'invalid value for "expyear", must be smaller than or equal to 2100.'
429
+ end
430
+
431
+ if expyear < 2000
432
+ fail ArgumentError, 'invalid value for "expyear", must be greater than or equal to 2000.'
433
+ end
434
+
435
+ @expyear = expyear
436
+ end
437
+
438
+ # Custom attribute writer method with validation
439
+ # @param [Object] identifier Value to be assigned
440
+ def identifier=(identifier)
441
+ if identifier.nil?
442
+ fail ArgumentError, 'identifier cannot be nil'
443
+ end
444
+
445
+ if identifier.to_s.length > 50
446
+ fail ArgumentError, 'invalid value for "identifier", the character length must be smaller than or equal to 50.'
447
+ end
448
+
449
+ if identifier.to_s.length < 4
450
+ fail ArgumentError, 'invalid value for "identifier", the character length must be great than or equal to 4.'
451
+ end
452
+
453
+ @identifier = identifier
454
+ end
455
+
456
+ # Custom attribute writer method with validation
457
+ # @param [Object] trans_info Value to be assigned
458
+ def trans_info=(trans_info)
459
+ if !trans_info.nil? && trans_info.to_s.length > 50
460
+ fail ArgumentError, 'invalid value for "trans_info", the character length must be smaller than or equal to 50.'
461
+ end
462
+
463
+ @trans_info = trans_info
464
+ end
465
+
466
+ # Custom attribute writer method with validation
467
+ # @param [Object] trans_type Value to be assigned
468
+ def trans_type=(trans_type)
469
+ if !trans_type.nil? && trans_type.to_s.length > 1
470
+ fail ArgumentError, 'invalid value for "trans_type", the character length must be smaller than or equal to 1.'
471
+ end
472
+
473
+ @trans_type = trans_type
474
+ end
475
+
476
+ # Checks equality by comparing each attribute.
477
+ # @param [Object] Object to be compared
478
+ def ==(o)
479
+ return true if self.equal?(o)
480
+ self.class == o.class &&
481
+ airline_data == o.airline_data &&
482
+ amount == o.amount &&
483
+ avs_postcode_policy == o.avs_postcode_policy &&
484
+ bill_to == o.bill_to &&
485
+ card_holder_name == o.card_holder_name &&
486
+ cardnumber == o.cardnumber &&
487
+ csc == o.csc &&
488
+ csc_policy == o.csc_policy &&
489
+ currency == o.currency &&
490
+ duplicate_policy == o.duplicate_policy &&
491
+ expmonth == o.expmonth &&
492
+ expyear == o.expyear &&
493
+ external_mpi == o.external_mpi &&
494
+ identifier == o.identifier &&
495
+ match_avsa == o.match_avsa &&
496
+ mcc6012 == o.mcc6012 &&
497
+ merchantid == o.merchantid &&
498
+ sdk == o.sdk &&
499
+ ship_to == o.ship_to &&
500
+ threedsecure == o.threedsecure &&
501
+ trans_info == o.trans_info &&
502
+ trans_type == o.trans_type
503
+ end
504
+
505
+ # @see the `==` method
506
+ # @param [Object] Object to be compared
507
+ def eql?(o)
508
+ self == o
509
+ end
510
+
511
+ # Calculates hash code according to all attributes.
512
+ # @return [Integer] Hash code
513
+ def hash
514
+ [airline_data, amount, avs_postcode_policy, bill_to, card_holder_name, cardnumber, csc, csc_policy, currency, duplicate_policy, expmonth, expyear, external_mpi, identifier, match_avsa, mcc6012, merchantid, sdk, ship_to, threedsecure, trans_info, trans_type].hash
515
+ end
516
+
517
+ # Builds the object from hash
518
+ # @param [Hash] attributes Model attributes in the form of hash
519
+ # @return [Object] Returns the model itself
520
+ def self.build_from_hash(attributes)
521
+ new.build_from_hash(attributes)
522
+ end
523
+
524
+ # Builds the object from hash
525
+ # @param [Hash] attributes Model attributes in the form of hash
526
+ # @return [Object] Returns the model itself
527
+ def build_from_hash(attributes)
528
+ return nil unless attributes.is_a?(Hash)
529
+ self.class.openapi_types.each_pair do |key, type|
530
+ if type =~ /\AArray<(.*)>/i
531
+ # check to ensure the input is an array given that the attribute
532
+ # is documented as an array but the input is not
533
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
534
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
535
+ end
536
+ elsif !attributes[self.class.attribute_map[key]].nil?
537
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
538
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
539
+ end
540
+
541
+ self
542
+ end
543
+
544
+ # Deserializes the data based on type
545
+ # @param string type Data type
546
+ # @param string value Value to be deserialized
547
+ # @return [Object] Deserialized data
548
+ def _deserialize(type, value)
549
+ case type.to_sym
550
+ when :DateTime
551
+ DateTime.parse(value)
552
+ when :Date
553
+ Date.parse(value)
554
+ when :String
555
+ value.to_s
556
+ when :Integer
557
+ value.to_i
558
+ when :Float
559
+ value.to_f
560
+ when :Boolean
561
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
562
+ true
563
+ else
564
+ false
565
+ end
566
+ when :Object
567
+ # generic object (usually a Hash), return directly
568
+ value
569
+ when /\AArray<(?<inner_type>.+)>\z/
570
+ inner_type = Regexp.last_match[:inner_type]
571
+ value.map { |v| _deserialize(inner_type, v) }
572
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
573
+ k_type = Regexp.last_match[:k_type]
574
+ v_type = Regexp.last_match[:v_type]
575
+ {}.tap do |hash|
576
+ value.each do |k, v|
577
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
578
+ end
579
+ end
580
+ else # model
581
+ CityPayApiClient.const_get(type).build_from_hash(value)
582
+ end
583
+ end
584
+
585
+ # Returns the string representation of the object
586
+ # @return [String] String presentation of the object
587
+ def to_s
588
+ to_hash.to_s
589
+ end
590
+
591
+ # to_body is an alias to to_hash (backward compatibility)
592
+ # @return [Hash] Returns the object in the form of hash
593
+ def to_body
594
+ to_hash
595
+ end
596
+
597
+ # Returns the object in the form of hash
598
+ # @return [Hash] Returns the object in the form of hash
599
+ def to_hash
600
+ hash = {}
601
+ self.class.attribute_map.each_pair do |attr, param|
602
+ value = self.send(attr)
603
+ if value.nil?
604
+ is_nullable = self.class.openapi_nullable.include?(attr)
605
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
606
+ end
607
+
608
+ hash[param] = _to_hash(value)
609
+ end
610
+ hash
611
+ end
612
+
613
+ # Outputs non-array value in the form of hash
614
+ # For object, use to_hash. Otherwise, just return the value
615
+ # @param [Object] value Any valid value
616
+ # @return [Hash] Returns the value in the form of hash
617
+ def _to_hash(value)
618
+ if value.is_a?(Array)
619
+ value.compact.map { |v| _to_hash(v) }
620
+ elsif value.is_a?(Hash)
621
+ {}.tap do |hash|
622
+ value.each { |k, v| hash[k] = _to_hash(v) }
623
+ end
624
+ elsif value.respond_to? :to_hash
625
+ value.to_hash
626
+ else
627
+ value
628
+ end
629
+ end
630
+ end
631
+ end