citypay_api_client 1.0.3 → 1.1.2

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 (265) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +111 -39
  3. data/citypay_api_client.gemspec +5 -5
  4. data/docs/AccountCreate.md +10 -9
  5. data/docs/AccountStatus.md +8 -7
  6. data/docs/Acknowledgement.md +14 -13
  7. data/docs/AclCheckRequest.md +18 -0
  8. data/docs/AclCheckResponseModel.md +24 -0
  9. data/docs/AirlineAdvice.md +38 -37
  10. data/docs/AirlineSegment.md +22 -21
  11. data/docs/AuthReference.md +34 -33
  12. data/docs/AuthReferences.md +8 -7
  13. data/docs/AuthRequest.md +52 -49
  14. data/docs/AuthResponse.md +64 -59
  15. data/docs/AuthenRequired.md +12 -11
  16. data/docs/AuthorisationAndPaymentApi.md +850 -0
  17. data/docs/Batch.md +22 -0
  18. data/docs/BatchProcessingApi.md +218 -0
  19. data/docs/BatchReportRequest.md +20 -0
  20. data/docs/BatchReportResponseModel.md +28 -0
  21. data/docs/BatchTransaction.md +24 -0
  22. data/docs/BatchTransactionResultModel.md +44 -0
  23. data/docs/Bin.md +34 -0
  24. data/docs/BinLookup.md +18 -0
  25. data/docs/CResAuthRequest.md +8 -7
  26. data/docs/CaptureRequest.md +18 -17
  27. data/docs/Card.md +46 -41
  28. data/docs/CardHolderAccount.md +24 -21
  29. data/docs/CardHolderAccountApi.md +387 -111
  30. data/docs/CardStatus.md +10 -9
  31. data/docs/ChargeRequest.md +38 -31
  32. data/docs/CheckBatchStatus.md +20 -0
  33. data/docs/CheckBatchStatusResponse.md +18 -0
  34. data/docs/ContactDetails.md +32 -31
  35. data/docs/Decision.md +12 -11
  36. data/docs/DirectPostApi.md +389 -0
  37. data/docs/DirectPostRequest.md +60 -0
  38. data/docs/DirectTokenAuthRequest.md +24 -0
  39. data/docs/DomainKeyCheckRequest.md +18 -0
  40. data/docs/DomainKeyRequest.md +22 -0
  41. data/docs/DomainKeyResponse.md +26 -0
  42. data/docs/Error.md +16 -13
  43. data/docs/EventDataModel.md +26 -0
  44. data/docs/Exists.md +22 -0
  45. data/docs/ExternalMPI.md +16 -15
  46. data/docs/ListMerchantsResponse.md +12 -11
  47. data/docs/MCC6012.md +14 -13
  48. data/docs/Merchant.md +16 -15
  49. data/docs/OperationalFunctionsApi.md +375 -0
  50. data/docs/PaResAuthRequest.md +10 -9
  51. data/docs/PaylinkAddress.md +30 -0
  52. data/docs/PaylinkAdjustmentRequest.md +22 -0
  53. data/docs/PaylinkApi.md +806 -0
  54. data/docs/PaylinkAttachmentRequest.md +26 -0
  55. data/docs/PaylinkAttachmentResult.md +22 -0
  56. data/docs/PaylinkBillPaymentTokenRequest.md +32 -0
  57. data/docs/PaylinkCardHolder.md +36 -0
  58. data/docs/PaylinkCart.md +30 -0
  59. data/docs/PaylinkCartItemModel.md +32 -0
  60. data/docs/PaylinkConfig.md +60 -0
  61. data/docs/PaylinkCustomParam.md +38 -0
  62. data/docs/PaylinkEmailNotificationPath.md +26 -0
  63. data/docs/PaylinkErrorCode.md +20 -0
  64. data/docs/PaylinkFieldGuardModel.md +30 -0
  65. data/docs/PaylinkPartPayments.md +28 -0
  66. data/docs/PaylinkSMSNotificationPath.md +20 -0
  67. data/docs/PaylinkStateEvent.md +22 -0
  68. data/docs/PaylinkTokenCreated.md +44 -0
  69. data/docs/PaylinkTokenRequestModel.md +42 -0
  70. data/docs/PaylinkTokenStatus.md +72 -0
  71. data/docs/PaylinkTokenStatusChangeRequest.md +26 -0
  72. data/docs/PaylinkTokenStatusChangeResponse.md +20 -0
  73. data/docs/PaylinkUI.md +24 -0
  74. data/docs/Ping.md +8 -7
  75. data/docs/ProcessBatchRequest.md +24 -0
  76. data/docs/ProcessBatchResponse.md +20 -0
  77. data/docs/RefundRequest.md +26 -0
  78. data/docs/RegisterCard.md +16 -13
  79. data/docs/RequestChallenged.md +16 -15
  80. data/docs/RetrieveRequest.md +12 -11
  81. data/docs/ThreeDSecure.md +32 -15
  82. data/docs/TokenisationResponseModel.md +36 -0
  83. data/docs/VoidRequest.md +12 -13
  84. data/docs/images/3dsv1-challenge.png +0 -0
  85. data/docs/images/3dsv2-challenge.png +0 -0
  86. data/docs/images/3dsv2-frictionless.png +0 -0
  87. data/docs/images/3dsv2-method-challenge.png +0 -0
  88. data/docs/images/3dsv2-method-frictionless.png +0 -0
  89. data/docs/images/3dsv2-no3d.png +0 -0
  90. data/docs/images/citypay-logo.svg +1 -0
  91. data/docs/images/direct-post-flow.png +0 -0
  92. data/docs/images/favicon.ico +0 -0
  93. data/docs/images/header.png +0 -0
  94. data/docs/images/logo.ai +1913 -4
  95. data/docs/images/logo.png +0 -0
  96. data/docs/images/logo.svg +1 -0
  97. data/docs/images/merchant-BPS-workflow.png +0 -0
  98. data/docs/images/paylink-field-guards.png +0 -0
  99. data/lib/.DS_Store +0 -0
  100. data/lib/citypay_api_client/api/authorisation_and_payment_api__.rb +565 -0
  101. data/lib/citypay_api_client/api/batch_processing_api__.rb +225 -0
  102. data/lib/citypay_api_client/api/{card_holder_account_api.rb → card_holder_account_api__.rb} +136 -46
  103. data/lib/citypay_api_client/api/direct_post_api__.rb +373 -0
  104. data/lib/citypay_api_client/api/operational_functions_api__.rb +356 -0
  105. data/lib/citypay_api_client/api/paylink_api__.rb +614 -0
  106. data/lib/citypay_api_client/api_client.rb +72 -70
  107. data/lib/citypay_api_client/api_error.rb +3 -2
  108. data/lib/citypay_api_client/configuration.rb +74 -17
  109. data/lib/citypay_api_client/models/account_create.rb +33 -23
  110. data/lib/citypay_api_client/models/account_status.rb +31 -23
  111. data/lib/citypay_api_client/models/acknowledgement.rb +43 -27
  112. data/lib/citypay_api_client/models/acl_check_request.rb +221 -0
  113. data/lib/citypay_api_client/models/acl_check_response_model.rb +244 -0
  114. data/lib/citypay_api_client/models/airline_advice.rb +63 -34
  115. data/lib/citypay_api_client/models/airline_segment.rb +51 -25
  116. data/lib/citypay_api_client/models/auth_reference.rb +80 -31
  117. data/lib/citypay_api_client/models/auth_references.rb +31 -23
  118. data/lib/citypay_api_client/models/auth_request.rb +137 -56
  119. data/lib/citypay_api_client/models/auth_response.rb +83 -123
  120. data/lib/citypay_api_client/models/authen_required.rb +31 -23
  121. data/lib/citypay_api_client/models/batch.rb +267 -0
  122. data/lib/citypay_api_client/models/batch_report_request.rb +278 -0
  123. data/lib/citypay_api_client/models/batch_report_response_model.rb +364 -0
  124. data/lib/citypay_api_client/models/batch_transaction.rb +324 -0
  125. data/lib/citypay_api_client/models/batch_transaction_result_model.rb +452 -0
  126. data/lib/citypay_api_client/models/bin.rb +294 -0
  127. data/lib/citypay_api_client/models/bin_lookup.rb +231 -0
  128. data/lib/citypay_api_client/models/c_res_auth_request.rb +31 -23
  129. data/lib/citypay_api_client/models/capture_request.rb +59 -38
  130. data/lib/citypay_api_client/models/card.rb +93 -29
  131. data/lib/citypay_api_client/models/card_holder_account.rb +49 -27
  132. data/lib/citypay_api_client/models/card_status.rb +31 -23
  133. data/lib/citypay_api_client/models/charge_request.rb +154 -47
  134. data/lib/citypay_api_client/models/check_batch_status.rb +260 -0
  135. data/lib/citypay_api_client/models/check_batch_status_response.rb +215 -0
  136. data/lib/citypay_api_client/models/contact_details.rb +130 -52
  137. data/lib/citypay_api_client/models/decision.rb +31 -23
  138. data/lib/citypay_api_client/models/direct_post_request.rb +707 -0
  139. data/lib/citypay_api_client/models/direct_token_auth_request.rb +244 -0
  140. data/lib/citypay_api_client/models/domain_key_check_request.rb +249 -0
  141. data/lib/citypay_api_client/models/domain_key_request.rb +249 -0
  142. data/lib/citypay_api_client/models/domain_key_response.rb +297 -0
  143. data/lib/citypay_api_client/models/error.rb +57 -31
  144. data/lib/citypay_api_client/models/event_data_model.rb +254 -0
  145. data/lib/citypay_api_client/models/exists.rb +241 -0
  146. data/lib/citypay_api_client/models/external_mpi.rb +61 -27
  147. data/lib/citypay_api_client/models/list_merchants_response.rb +37 -25
  148. data/lib/citypay_api_client/models/mcc6012.rb +31 -23
  149. data/lib/citypay_api_client/models/merchant.rb +31 -23
  150. data/lib/citypay_api_client/models/pa_res_auth_request.rb +36 -24
  151. data/lib/citypay_api_client/models/paylink_address.rb +425 -0
  152. data/lib/citypay_api_client/models/paylink_adjustment_request.rb +272 -0
  153. data/lib/citypay_api_client/models/paylink_attachment_request.rb +268 -0
  154. data/lib/citypay_api_client/models/paylink_attachment_result.rb +248 -0
  155. data/lib/citypay_api_client/models/paylink_bill_payment_token_request.rb +289 -0
  156. data/lib/citypay_api_client/models/paylink_card_holder.rb +360 -0
  157. data/lib/citypay_api_client/models/paylink_cart.rb +275 -0
  158. data/lib/citypay_api_client/models/paylink_cart_item_model.rb +284 -0
  159. data/lib/citypay_api_client/models/paylink_config.rb +428 -0
  160. data/lib/citypay_api_client/models/paylink_custom_param.rb +321 -0
  161. data/lib/citypay_api_client/models/paylink_email_notification_path.rb +265 -0
  162. data/lib/citypay_api_client/models/paylink_error_code.rb +238 -0
  163. data/lib/citypay_api_client/models/paylink_field_guard_model.rb +274 -0
  164. data/lib/citypay_api_client/models/paylink_part_payments.rb +264 -0
  165. data/lib/citypay_api_client/models/paylink_sms_notification_path.rb +231 -0
  166. data/lib/citypay_api_client/models/paylink_state_event.rb +234 -0
  167. data/lib/citypay_api_client/models/paylink_token_created.rb +365 -0
  168. data/lib/citypay_api_client/models/paylink_token_request_model.rb +427 -0
  169. data/lib/citypay_api_client/models/paylink_token_status.rb +485 -0
  170. data/lib/citypay_api_client/models/paylink_token_status_change_request.rb +269 -0
  171. data/lib/citypay_api_client/models/paylink_token_status_change_response.rb +232 -0
  172. data/lib/citypay_api_client/models/paylink_ui.rb +244 -0
  173. data/lib/citypay_api_client/models/ping.rb +37 -25
  174. data/lib/citypay_api_client/models/process_batch_request.rb +313 -0
  175. data/lib/citypay_api_client/models/process_batch_response.rb +231 -0
  176. data/lib/citypay_api_client/models/refund_request.rb +339 -0
  177. data/lib/citypay_api_client/models/register_card.rb +79 -27
  178. data/lib/citypay_api_client/models/request_challenged.rb +39 -31
  179. data/lib/citypay_api_client/models/retrieve_request.rb +39 -25
  180. data/lib/citypay_api_client/models/three_d_secure.rb +116 -28
  181. data/lib/citypay_api_client/models/tokenisation_response_model.rb +332 -0
  182. data/lib/citypay_api_client/models/void_request.rb +39 -37
  183. data/lib/citypay_api_client/utils/digest_utils.rb +18 -0
  184. data/lib/citypay_api_client/utils/direct_post_mac.rb +22 -0
  185. data/lib/citypay_api_client/version.rb +3 -4
  186. data/lib/citypay_api_client.rb +53 -6
  187. data/spec/.DS_Store +0 -0
  188. data/spec/api/authorisation_and_payment_api___spec.rb +130 -0
  189. data/spec/api/batch_processing_api___spec.rb +70 -0
  190. data/spec/api/{card_holder_account_api_spec.rb → card_holder_account_api___spec.rb} +15 -3
  191. data/spec/api/direct_post_api___spec.rb +98 -0
  192. data/spec/api/operational_functions_api___spec.rb +94 -0
  193. data/spec/api/paylink_api___spec.rb +131 -0
  194. data/spec/api_client_spec.rb +4 -4
  195. data/spec/configuration_spec.rb +5 -5
  196. data/spec/it_api_sandbox_spec.rb +117 -55
  197. data/spec/models/account_create_spec.rb +1 -2
  198. data/spec/models/account_status_spec.rb +2 -2
  199. data/spec/models/acknowledgement_spec.rb +7 -22
  200. data/spec/models/acl_check_request_spec.rb +33 -0
  201. data/spec/models/acl_check_response_model_spec.rb +51 -0
  202. data/spec/models/airline_advice_spec.rb +0 -2
  203. data/spec/models/airline_segment_spec.rb +0 -2
  204. data/spec/models/auth_references_spec.rb +7 -8
  205. data/spec/models/auth_request_spec.rb +0 -2
  206. data/spec/models/auth_response_spec.rb +77 -33
  207. data/spec/models/batch_report_request_spec.rb +37 -0
  208. data/spec/models/batch_report_response_model_spec.rb +61 -0
  209. data/spec/models/batch_spec.rb +43 -0
  210. data/spec/models/batch_transaction_result_model_spec.rb +85 -0
  211. data/spec/models/batch_transaction_spec.rb +49 -0
  212. data/spec/models/bin_lookup_spec.rb +31 -0
  213. data/spec/models/bin_spec.rb +81 -0
  214. data/spec/models/capture_request_spec.rb +0 -2
  215. data/spec/models/card_holder_account_spec.rb +8 -7
  216. data/spec/models/charge_request_spec.rb +0 -2
  217. data/spec/models/check_batch_status_response_spec.rb +45 -0
  218. data/spec/models/check_batch_status_spec.rb +39 -0
  219. data/spec/models/decision_spec.rb +1 -1
  220. data/spec/models/direct_post_request_spec.rb +151 -0
  221. data/spec/models/direct_token_auth_request_spec.rb +51 -0
  222. data/spec/models/domain_key_check_request_spec.rb +31 -0
  223. data/spec/models/domain_key_request_spec.rb +45 -0
  224. data/spec/models/domain_key_response_spec.rb +57 -0
  225. data/spec/models/event_data_model_spec.rb +57 -0
  226. data/spec/{api/operational_api_spec.rb → models/exists_spec.rb} +14 -20
  227. data/spec/models/list_merchants_response_spec.rb +2 -2
  228. data/spec/models/paylink_address_spec.rb +69 -0
  229. data/spec/models/paylink_adjustment_request_spec.rb +45 -0
  230. data/spec/models/paylink_attachment_request_spec.rb +45 -0
  231. data/spec/models/paylink_attachment_result_spec.rb +45 -0
  232. data/spec/models/paylink_bill_payment_token_request_spec.rb +63 -0
  233. data/spec/models/paylink_card_holder_spec.rb +87 -0
  234. data/spec/models/paylink_cart_item_model_spec.rb +75 -0
  235. data/spec/models/paylink_cart_spec.rb +69 -0
  236. data/spec/models/paylink_config_spec.rb +159 -0
  237. data/spec/models/paylink_custom_param_spec.rb +87 -0
  238. data/spec/models/paylink_email_notification_path_spec.rb +57 -0
  239. data/spec/models/paylink_error_code_spec.rb +39 -0
  240. data/spec/models/paylink_field_guard_model_spec.rb +45 -0
  241. data/spec/models/paylink_part_payments_spec.rb +63 -0
  242. data/spec/models/paylink_sms_notification_path_spec.rb +39 -0
  243. data/spec/models/paylink_state_event_spec.rb +45 -0
  244. data/spec/models/paylink_token_created_spec.rb +111 -0
  245. data/spec/models/paylink_token_request_model_spec.rb +91 -0
  246. data/spec/models/paylink_token_status_change_request_spec.rb +57 -0
  247. data/spec/models/paylink_token_status_change_response_spec.rb +39 -0
  248. data/spec/models/paylink_token_status_spec.rb +195 -0
  249. data/spec/models/paylink_ui_spec.rb +51 -0
  250. data/spec/models/process_batch_request_spec.rb +49 -0
  251. data/spec/models/process_batch_response_spec.rb +39 -0
  252. data/spec/models/refund_request_spec.rb +62 -0
  253. data/spec/models/register_card_spec.rb +0 -2
  254. data/spec/models/tokenisation_response_model_spec.rb +87 -0
  255. data/spec/spec_helper.rb +2 -2
  256. data/spec/utils/direct_post_mac_spec.rb +13 -0
  257. metadata +230 -44
  258. data/Gemfile.lock +0 -70
  259. data/docs/OperationalApi.md +0 -112
  260. data/docs/PaymentProcessingApi.md +0 -320
  261. data/git_push.sh +0 -58
  262. data/lib/citypay_api_client/api/operational_api.rb +0 -147
  263. data/lib/citypay_api_client/api/payment_processing_api.rb +0 -405
  264. data/lib/citypay_api_client/test.rb +0 -20
  265. data/spec/api/payment_processing_api_spec.rb +0 -106
@@ -0,0 +1,707 @@
1
+ =begin
2
+ #CityPay Payment API
3
+
4
+ # This CityPay API is an 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 tokenized payments using cardholder Accounts. ## Compliance and Security 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. These include * Data must be collected using TLS version 1.2 using [strong cryptography](https://citypay.github.io/api-docs/payment-api/#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 cardholder 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
+ Contact: support@citypay.com
7
+ Generated by: https://openapi-generator.tech
8
+ OpenAPI Generator version: 7.2.0
9
+
10
+ =end
11
+
12
+ require 'date'
13
+ require 'time'
14
+
15
+ module CityPayApiClient
16
+ class DirectPostRequest
17
+ # 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.
18
+ attr_accessor :amount
19
+
20
+ # 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.
21
+ attr_accessor :avs_postcode_policy
22
+
23
+ attr_accessor :bill_to
24
+
25
+ # 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.
26
+ attr_accessor :cardnumber
27
+
28
+ # 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.
29
+ attr_accessor :csc
30
+
31
+ # 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.
32
+ attr_accessor :csc_policy
33
+
34
+ # The processing currency for the transaction. Will default to the merchant account currency.
35
+ attr_accessor :currency
36
+
37
+ # 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.
38
+ attr_accessor :duplicate_policy
39
+
40
+ # The month of expiry of the card. The month value should be a numerical value between 1 and 12.
41
+ attr_accessor :expmonth
42
+
43
+ # The year of expiry of the card.
44
+ attr_accessor :expyear
45
+
46
+ # 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 0x32 to 0x127. 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.
47
+ attr_accessor :identifier
48
+
49
+ # A message authentication code ensures the data is authentic and that the intended amount has not been tampered with. The mac value is generated using a hash-based mac value. The following algorithm is used. - A key (k) is derived from your licence key - A value (v) is produced by concatenating the nonce, amount value and identifier, such as a purchase with nonce `0123456789ABCDEF` an amount of £275.95 and an identifier of OD-12345678 would become `0123456789ABCDEF27595OD-12345678` and extracting the UTF-8 byte values - The result from HMAC_SHA256(k, v) is hex-encoded (upper-case) - For instance, a licence key of `LK123456789`, a nonce of `0123456789ABCDEF`, an amount of `27595` and an identifier of `OD-12345678` would generate a MAC of `163DBAB194D743866A9BCC7FC9C8A88FCD99C6BBBF08D619291212D1B91EE12E`.
50
+ attr_accessor :mac
51
+
52
+ # 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.
53
+ attr_accessor :match_avsa
54
+
55
+ # The card holder name as appears on the card such as MR N E BODY. Required for some acquirers.
56
+ attr_accessor :name_on_card
57
+
58
+ # A random value Hex string (uppercase) which is provided to the API to perform a digest. The value will be used in any digest function.
59
+ attr_accessor :nonce
60
+
61
+ # The URL used to redirect back to your site when a transaction has been rejected or declined. Required if a url-encoded request.
62
+ attr_accessor :redirect_failure
63
+
64
+ # The URL used to redirect back to your site when a transaction has been tokenised or authorised. Required if a url-encoded request.
65
+ attr_accessor :redirect_success
66
+
67
+ attr_accessor :ship_to
68
+
69
+ # A \"tag\" is a label that you can attach to a payment authorization. Tags can help you group transactions together based on certain criteria, like a work job or a ticket number. They can also assist in filtering transactions when you're generating reports. Multiple Tags You can add more than one tag to a transaction by separating them with commas. Limitations There is a maximum limit of 3 tags that can be added to a single transaction. Each tag can be no longer than 20 characters and alphanumeric with no spaces. Example: Let's say you're a software company and you have different teams working on various projects. When a team makes a purchase or incurs an expense, they can tag the transaction with the project name, the team name, and the type of expense. Project Name: Project_X Team Name: Team_A Type of Expense: Hardware So, the tag for a transaction might look like: Project_X,Team_A,Hardware This way, when you're looking at your financial reports, you can easily filter transactions based on these tags to see how much each project or team is spending on different types of expenses.
70
+ attr_accessor :tag
71
+
72
+ attr_accessor :threedsecure
73
+
74
+ # Further information that can be added to the transaction will display in reporting. Can be used for flexible values such as operator id.
75
+ attr_accessor :trans_info
76
+
77
+ # The type of transaction being submitted. Normally this value is not required and your account manager may request that you set this field.
78
+ attr_accessor :trans_type
79
+
80
+ # Attribute mapping from ruby-style variable name to JSON key.
81
+ def self.attribute_map
82
+ {
83
+ :'amount' => :'amount',
84
+ :'avs_postcode_policy' => :'avs_postcode_policy',
85
+ :'bill_to' => :'bill_to',
86
+ :'cardnumber' => :'cardnumber',
87
+ :'csc' => :'csc',
88
+ :'csc_policy' => :'csc_policy',
89
+ :'currency' => :'currency',
90
+ :'duplicate_policy' => :'duplicate_policy',
91
+ :'expmonth' => :'expmonth',
92
+ :'expyear' => :'expyear',
93
+ :'identifier' => :'identifier',
94
+ :'mac' => :'mac',
95
+ :'match_avsa' => :'match_avsa',
96
+ :'name_on_card' => :'name_on_card',
97
+ :'nonce' => :'nonce',
98
+ :'redirect_failure' => :'redirect_failure',
99
+ :'redirect_success' => :'redirect_success',
100
+ :'ship_to' => :'ship_to',
101
+ :'tag' => :'tag',
102
+ :'threedsecure' => :'threedsecure',
103
+ :'trans_info' => :'trans_info',
104
+ :'trans_type' => :'trans_type'
105
+ }
106
+ end
107
+
108
+ # Returns all the JSON keys this model knows about
109
+ def self.acceptable_attributes
110
+ attribute_map.values
111
+ end
112
+
113
+ # Attribute type mapping.
114
+ def self.openapi_types
115
+ {
116
+ :'amount' => :'Integer',
117
+ :'avs_postcode_policy' => :'String',
118
+ :'bill_to' => :'ContactDetails',
119
+ :'cardnumber' => :'String',
120
+ :'csc' => :'String',
121
+ :'csc_policy' => :'String',
122
+ :'currency' => :'String',
123
+ :'duplicate_policy' => :'String',
124
+ :'expmonth' => :'Integer',
125
+ :'expyear' => :'Integer',
126
+ :'identifier' => :'String',
127
+ :'mac' => :'String',
128
+ :'match_avsa' => :'String',
129
+ :'name_on_card' => :'String',
130
+ :'nonce' => :'String',
131
+ :'redirect_failure' => :'String',
132
+ :'redirect_success' => :'String',
133
+ :'ship_to' => :'ContactDetails',
134
+ :'tag' => :'String',
135
+ :'threedsecure' => :'ThreeDSecure',
136
+ :'trans_info' => :'String',
137
+ :'trans_type' => :'String'
138
+ }
139
+ end
140
+
141
+ # List of attributes with nullable: true
142
+ def self.openapi_nullable
143
+ Set.new([
144
+ ])
145
+ end
146
+
147
+ # Initializes the object
148
+ # @param [Hash] attributes Model attributes in the form of hash
149
+ def initialize(attributes = {})
150
+ if (!attributes.is_a?(Hash))
151
+ fail ArgumentError, "The input argument (attributes) must be a hash in `CityPayApiClient::DirectPostRequest` initialize method"
152
+ end
153
+
154
+ # check to see if the attribute exists and convert string to symbol for hash key
155
+ attributes = attributes.each_with_object({}) { |(k, v), h|
156
+ if (!self.class.attribute_map.key?(k.to_sym))
157
+ fail ArgumentError, "`#{k}` is not a valid attribute in `CityPayApiClient::DirectPostRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
158
+ end
159
+ h[k.to_sym] = v
160
+ }
161
+
162
+ if attributes.key?(:'amount')
163
+ self.amount = attributes[:'amount']
164
+ else
165
+ self.amount = nil
166
+ end
167
+
168
+ if attributes.key?(:'avs_postcode_policy')
169
+ self.avs_postcode_policy = attributes[:'avs_postcode_policy']
170
+ end
171
+
172
+ if attributes.key?(:'bill_to')
173
+ self.bill_to = attributes[:'bill_to']
174
+ end
175
+
176
+ if attributes.key?(:'cardnumber')
177
+ self.cardnumber = attributes[:'cardnumber']
178
+ else
179
+ self.cardnumber = nil
180
+ end
181
+
182
+ if attributes.key?(:'csc')
183
+ self.csc = attributes[:'csc']
184
+ end
185
+
186
+ if attributes.key?(:'csc_policy')
187
+ self.csc_policy = attributes[:'csc_policy']
188
+ end
189
+
190
+ if attributes.key?(:'currency')
191
+ self.currency = attributes[:'currency']
192
+ end
193
+
194
+ if attributes.key?(:'duplicate_policy')
195
+ self.duplicate_policy = attributes[:'duplicate_policy']
196
+ end
197
+
198
+ if attributes.key?(:'expmonth')
199
+ self.expmonth = attributes[:'expmonth']
200
+ else
201
+ self.expmonth = nil
202
+ end
203
+
204
+ if attributes.key?(:'expyear')
205
+ self.expyear = attributes[:'expyear']
206
+ else
207
+ self.expyear = nil
208
+ end
209
+
210
+ if attributes.key?(:'identifier')
211
+ self.identifier = attributes[:'identifier']
212
+ else
213
+ self.identifier = nil
214
+ end
215
+
216
+ if attributes.key?(:'mac')
217
+ self.mac = attributes[:'mac']
218
+ else
219
+ self.mac = nil
220
+ end
221
+
222
+ if attributes.key?(:'match_avsa')
223
+ self.match_avsa = attributes[:'match_avsa']
224
+ end
225
+
226
+ if attributes.key?(:'name_on_card')
227
+ self.name_on_card = attributes[:'name_on_card']
228
+ end
229
+
230
+ if attributes.key?(:'nonce')
231
+ self.nonce = attributes[:'nonce']
232
+ end
233
+
234
+ if attributes.key?(:'redirect_failure')
235
+ self.redirect_failure = attributes[:'redirect_failure']
236
+ end
237
+
238
+ if attributes.key?(:'redirect_success')
239
+ self.redirect_success = attributes[:'redirect_success']
240
+ end
241
+
242
+ if attributes.key?(:'ship_to')
243
+ self.ship_to = attributes[:'ship_to']
244
+ end
245
+
246
+ if attributes.key?(:'tag')
247
+ self.tag = attributes[:'tag']
248
+ end
249
+
250
+ if attributes.key?(:'threedsecure')
251
+ self.threedsecure = attributes[:'threedsecure']
252
+ end
253
+
254
+ if attributes.key?(:'trans_info')
255
+ self.trans_info = attributes[:'trans_info']
256
+ end
257
+
258
+ if attributes.key?(:'trans_type')
259
+ self.trans_type = attributes[:'trans_type']
260
+ end
261
+ end
262
+
263
+ # Show invalid properties with the reasons. Usually used together with valid?
264
+ # @return Array for valid properties with the reasons
265
+ def list_invalid_properties
266
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
267
+ invalid_properties = Array.new
268
+ if @amount.nil?
269
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.')
270
+ end
271
+
272
+ if @cardnumber.nil?
273
+ invalid_properties.push('invalid value for "cardnumber", cardnumber cannot be nil.')
274
+ end
275
+
276
+ if @cardnumber.to_s.length > 22
277
+ invalid_properties.push('invalid value for "cardnumber", the character length must be smaller than or equal to 22.')
278
+ end
279
+
280
+ if @cardnumber.to_s.length < 12
281
+ invalid_properties.push('invalid value for "cardnumber", the character length must be great than or equal to 12.')
282
+ end
283
+
284
+ if !@csc.nil? && @csc.to_s.length > 4
285
+ invalid_properties.push('invalid value for "csc", the character length must be smaller than or equal to 4.')
286
+ end
287
+
288
+ if !@csc.nil? && @csc.to_s.length < 3
289
+ invalid_properties.push('invalid value for "csc", the character length must be great than or equal to 3.')
290
+ end
291
+
292
+ if !@currency.nil? && @currency.to_s.length > 3
293
+ invalid_properties.push('invalid value for "currency", the character length must be smaller than or equal to 3.')
294
+ end
295
+
296
+ if !@currency.nil? && @currency.to_s.length < 3
297
+ invalid_properties.push('invalid value for "currency", the character length must be great than or equal to 3.')
298
+ end
299
+
300
+ if @expmonth.nil?
301
+ invalid_properties.push('invalid value for "expmonth", expmonth cannot be nil.')
302
+ end
303
+
304
+ if @expmonth > 12
305
+ invalid_properties.push('invalid value for "expmonth", must be smaller than or equal to 12.')
306
+ end
307
+
308
+ if @expmonth < 1
309
+ invalid_properties.push('invalid value for "expmonth", must be greater than or equal to 1.')
310
+ end
311
+
312
+ if @expyear.nil?
313
+ invalid_properties.push('invalid value for "expyear", expyear cannot be nil.')
314
+ end
315
+
316
+ if @expyear > 2100
317
+ invalid_properties.push('invalid value for "expyear", must be smaller than or equal to 2100.')
318
+ end
319
+
320
+ if @expyear < 2000
321
+ invalid_properties.push('invalid value for "expyear", must be greater than or equal to 2000.')
322
+ end
323
+
324
+ if @identifier.nil?
325
+ invalid_properties.push('invalid value for "identifier", identifier cannot be nil.')
326
+ end
327
+
328
+ if @identifier.to_s.length > 50
329
+ invalid_properties.push('invalid value for "identifier", the character length must be smaller than or equal to 50.')
330
+ end
331
+
332
+ if @identifier.to_s.length < 4
333
+ invalid_properties.push('invalid value for "identifier", the character length must be great than or equal to 4.')
334
+ end
335
+
336
+ if @mac.nil?
337
+ invalid_properties.push('invalid value for "mac", mac cannot be nil.')
338
+ end
339
+
340
+ if !@name_on_card.nil? && @name_on_card.to_s.length > 45
341
+ invalid_properties.push('invalid value for "name_on_card", the character length must be smaller than or equal to 45.')
342
+ end
343
+
344
+ if !@name_on_card.nil? && @name_on_card.to_s.length < 2
345
+ invalid_properties.push('invalid value for "name_on_card", the character length must be great than or equal to 2.')
346
+ end
347
+
348
+ if !@trans_info.nil? && @trans_info.to_s.length > 50
349
+ invalid_properties.push('invalid value for "trans_info", the character length must be smaller than or equal to 50.')
350
+ end
351
+
352
+ if !@trans_type.nil? && @trans_type.to_s.length > 1
353
+ invalid_properties.push('invalid value for "trans_type", the character length must be smaller than or equal to 1.')
354
+ end
355
+
356
+ invalid_properties
357
+ end
358
+
359
+ # Check to see if the all the properties in the model are valid
360
+ # @return true if the model is valid
361
+ def valid?
362
+ warn '[DEPRECATED] the `valid?` method is obsolete'
363
+ return false if @amount.nil?
364
+ return false if @cardnumber.nil?
365
+ return false if @cardnumber.to_s.length > 22
366
+ return false if @cardnumber.to_s.length < 12
367
+ return false if !@csc.nil? && @csc.to_s.length > 4
368
+ return false if !@csc.nil? && @csc.to_s.length < 3
369
+ return false if !@currency.nil? && @currency.to_s.length > 3
370
+ return false if !@currency.nil? && @currency.to_s.length < 3
371
+ return false if @expmonth.nil?
372
+ return false if @expmonth > 12
373
+ return false if @expmonth < 1
374
+ return false if @expyear.nil?
375
+ return false if @expyear > 2100
376
+ return false if @expyear < 2000
377
+ return false if @identifier.nil?
378
+ return false if @identifier.to_s.length > 50
379
+ return false if @identifier.to_s.length < 4
380
+ return false if @mac.nil?
381
+ return false if !@name_on_card.nil? && @name_on_card.to_s.length > 45
382
+ return false if !@name_on_card.nil? && @name_on_card.to_s.length < 2
383
+ return false if !@trans_info.nil? && @trans_info.to_s.length > 50
384
+ return false if !@trans_type.nil? && @trans_type.to_s.length > 1
385
+ true
386
+ end
387
+
388
+ # Custom attribute writer method with validation
389
+ # @param [Object] amount Value to be assigned
390
+ def amount=(amount)
391
+ if amount.nil?
392
+ fail ArgumentError, 'amount cannot be nil'
393
+ end
394
+
395
+ @amount = amount
396
+ end
397
+
398
+ # Custom attribute writer method with validation
399
+ # @param [Object] cardnumber Value to be assigned
400
+ def cardnumber=(cardnumber)
401
+ if cardnumber.nil?
402
+ fail ArgumentError, 'cardnumber cannot be nil'
403
+ end
404
+
405
+ if cardnumber.to_s.length > 22
406
+ fail ArgumentError, 'invalid value for "cardnumber", the character length must be smaller than or equal to 22.'
407
+ end
408
+
409
+ if cardnumber.to_s.length < 12
410
+ fail ArgumentError, 'invalid value for "cardnumber", the character length must be great than or equal to 12.'
411
+ end
412
+
413
+ @cardnumber = cardnumber
414
+ end
415
+
416
+ # Custom attribute writer method with validation
417
+ # @param [Object] csc Value to be assigned
418
+ def csc=(csc)
419
+ if csc.nil?
420
+ fail ArgumentError, 'csc cannot be nil'
421
+ end
422
+
423
+ if csc.to_s.length > 4
424
+ fail ArgumentError, 'invalid value for "csc", the character length must be smaller than or equal to 4.'
425
+ end
426
+
427
+ if csc.to_s.length < 3
428
+ fail ArgumentError, 'invalid value for "csc", the character length must be great than or equal to 3.'
429
+ end
430
+
431
+ @csc = csc
432
+ end
433
+
434
+ # Custom attribute writer method with validation
435
+ # @param [Object] currency Value to be assigned
436
+ def currency=(currency)
437
+ if currency.nil?
438
+ fail ArgumentError, 'currency cannot be nil'
439
+ end
440
+
441
+ if currency.to_s.length > 3
442
+ fail ArgumentError, 'invalid value for "currency", the character length must be smaller than or equal to 3.'
443
+ end
444
+
445
+ if currency.to_s.length < 3
446
+ fail ArgumentError, 'invalid value for "currency", the character length must be great than or equal to 3.'
447
+ end
448
+
449
+ @currency = currency
450
+ end
451
+
452
+ # Custom attribute writer method with validation
453
+ # @param [Object] expmonth Value to be assigned
454
+ def expmonth=(expmonth)
455
+ if expmonth.nil?
456
+ fail ArgumentError, 'expmonth cannot be nil'
457
+ end
458
+
459
+ if expmonth > 12
460
+ fail ArgumentError, 'invalid value for "expmonth", must be smaller than or equal to 12.'
461
+ end
462
+
463
+ if expmonth < 1
464
+ fail ArgumentError, 'invalid value for "expmonth", must be greater than or equal to 1.'
465
+ end
466
+
467
+ @expmonth = expmonth
468
+ end
469
+
470
+ # Custom attribute writer method with validation
471
+ # @param [Object] expyear Value to be assigned
472
+ def expyear=(expyear)
473
+ if expyear.nil?
474
+ fail ArgumentError, 'expyear cannot be nil'
475
+ end
476
+
477
+ if expyear > 2100
478
+ fail ArgumentError, 'invalid value for "expyear", must be smaller than or equal to 2100.'
479
+ end
480
+
481
+ if expyear < 2000
482
+ fail ArgumentError, 'invalid value for "expyear", must be greater than or equal to 2000.'
483
+ end
484
+
485
+ @expyear = expyear
486
+ end
487
+
488
+ # Custom attribute writer method with validation
489
+ # @param [Object] identifier Value to be assigned
490
+ def identifier=(identifier)
491
+ if identifier.nil?
492
+ fail ArgumentError, 'identifier cannot be nil'
493
+ end
494
+
495
+ if identifier.to_s.length > 50
496
+ fail ArgumentError, 'invalid value for "identifier", the character length must be smaller than or equal to 50.'
497
+ end
498
+
499
+ if identifier.to_s.length < 4
500
+ fail ArgumentError, 'invalid value for "identifier", the character length must be great than or equal to 4.'
501
+ end
502
+
503
+ @identifier = identifier
504
+ end
505
+
506
+ # Custom attribute writer method with validation
507
+ # @param [Object] name_on_card Value to be assigned
508
+ def name_on_card=(name_on_card)
509
+ if name_on_card.nil?
510
+ fail ArgumentError, 'name_on_card cannot be nil'
511
+ end
512
+
513
+ if name_on_card.to_s.length > 45
514
+ fail ArgumentError, 'invalid value for "name_on_card", the character length must be smaller than or equal to 45.'
515
+ end
516
+
517
+ if name_on_card.to_s.length < 2
518
+ fail ArgumentError, 'invalid value for "name_on_card", the character length must be great than or equal to 2.'
519
+ end
520
+
521
+ @name_on_card = name_on_card
522
+ end
523
+
524
+ # Custom attribute writer method with validation
525
+ # @param [Object] trans_info Value to be assigned
526
+ def trans_info=(trans_info)
527
+ if trans_info.nil?
528
+ fail ArgumentError, 'trans_info cannot be nil'
529
+ end
530
+
531
+ if trans_info.to_s.length > 50
532
+ fail ArgumentError, 'invalid value for "trans_info", the character length must be smaller than or equal to 50.'
533
+ end
534
+
535
+ @trans_info = trans_info
536
+ end
537
+
538
+ # Custom attribute writer method with validation
539
+ # @param [Object] trans_type Value to be assigned
540
+ def trans_type=(trans_type)
541
+ if trans_type.nil?
542
+ fail ArgumentError, 'trans_type cannot be nil'
543
+ end
544
+
545
+ if trans_type.to_s.length > 1
546
+ fail ArgumentError, 'invalid value for "trans_type", the character length must be smaller than or equal to 1.'
547
+ end
548
+
549
+ @trans_type = trans_type
550
+ end
551
+
552
+ # Checks equality by comparing each attribute.
553
+ # @param [Object] Object to be compared
554
+ def ==(o)
555
+ return true if self.equal?(o)
556
+ self.class == o.class &&
557
+ amount == o.amount &&
558
+ avs_postcode_policy == o.avs_postcode_policy &&
559
+ bill_to == o.bill_to &&
560
+ cardnumber == o.cardnumber &&
561
+ csc == o.csc &&
562
+ csc_policy == o.csc_policy &&
563
+ currency == o.currency &&
564
+ duplicate_policy == o.duplicate_policy &&
565
+ expmonth == o.expmonth &&
566
+ expyear == o.expyear &&
567
+ identifier == o.identifier &&
568
+ mac == o.mac &&
569
+ match_avsa == o.match_avsa &&
570
+ name_on_card == o.name_on_card &&
571
+ nonce == o.nonce &&
572
+ redirect_failure == o.redirect_failure &&
573
+ redirect_success == o.redirect_success &&
574
+ ship_to == o.ship_to &&
575
+ tag == o.tag &&
576
+ threedsecure == o.threedsecure &&
577
+ trans_info == o.trans_info &&
578
+ trans_type == o.trans_type
579
+ end
580
+
581
+ # @see the `==` method
582
+ # @param [Object] Object to be compared
583
+ def eql?(o)
584
+ self == o
585
+ end
586
+
587
+ # Calculates hash code according to all attributes.
588
+ # @return [Integer] Hash code
589
+ def hash
590
+ [amount, avs_postcode_policy, bill_to, cardnumber, csc, csc_policy, currency, duplicate_policy, expmonth, expyear, identifier, mac, match_avsa, name_on_card, nonce, redirect_failure, redirect_success, ship_to, tag, threedsecure, trans_info, trans_type].hash
591
+ end
592
+
593
+ # Builds the object from hash
594
+ # @param [Hash] attributes Model attributes in the form of hash
595
+ # @return [Object] Returns the model itself
596
+ def self.build_from_hash(attributes)
597
+ return nil unless attributes.is_a?(Hash)
598
+ attributes = attributes.transform_keys(&:to_sym)
599
+ transformed_hash = {}
600
+ openapi_types.each_pair do |key, type|
601
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
602
+ transformed_hash["#{key}"] = nil
603
+ elsif type =~ /\AArray<(.*)>/i
604
+ # check to ensure the input is an array given that the attribute
605
+ # is documented as an array but the input is not
606
+ if attributes[attribute_map[key]].is_a?(Array)
607
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
608
+ end
609
+ elsif !attributes[attribute_map[key]].nil?
610
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
611
+ end
612
+ end
613
+ new(transformed_hash)
614
+ end
615
+
616
+ # Deserializes the data based on type
617
+ # @param string type Data type
618
+ # @param string value Value to be deserialized
619
+ # @return [Object] Deserialized data
620
+ def self._deserialize(type, value)
621
+ case type.to_sym
622
+ when :Time
623
+ Time.parse(value)
624
+ when :Date
625
+ Date.parse(value)
626
+ when :String
627
+ value.to_s
628
+ when :Integer
629
+ value.to_i
630
+ when :Float
631
+ value.to_f
632
+ when :Boolean
633
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
634
+ true
635
+ else
636
+ false
637
+ end
638
+ when :Object
639
+ # generic object (usually a Hash), return directly
640
+ value
641
+ when /\AArray<(?<inner_type>.+)>\z/
642
+ inner_type = Regexp.last_match[:inner_type]
643
+ value.map { |v| _deserialize(inner_type, v) }
644
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
645
+ k_type = Regexp.last_match[:k_type]
646
+ v_type = Regexp.last_match[:v_type]
647
+ {}.tap do |hash|
648
+ value.each do |k, v|
649
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
650
+ end
651
+ end
652
+ else # model
653
+ # models (e.g. Pet) or oneOf
654
+ klass = CityPayApiClient.const_get(type)
655
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
656
+ end
657
+ end
658
+
659
+ # Returns the string representation of the object
660
+ # @return [String] String presentation of the object
661
+ def to_s
662
+ to_hash.to_s
663
+ end
664
+
665
+ # to_body is an alias to to_hash (backward compatibility)
666
+ # @return [Hash] Returns the object in the form of hash
667
+ def to_body
668
+ to_hash
669
+ end
670
+
671
+ # Returns the object in the form of hash
672
+ # @return [Hash] Returns the object in the form of hash
673
+ def to_hash
674
+ hash = {}
675
+ self.class.attribute_map.each_pair do |attr, param|
676
+ value = self.send(attr)
677
+ if value.nil?
678
+ is_nullable = self.class.openapi_nullable.include?(attr)
679
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
680
+ end
681
+
682
+ hash[param] = _to_hash(value)
683
+ end
684
+ hash
685
+ end
686
+
687
+ # Outputs non-array value in the form of hash
688
+ # For object, use to_hash. Otherwise, just return the value
689
+ # @param [Object] value Any valid value
690
+ # @return [Hash] Returns the value in the form of hash
691
+ def _to_hash(value)
692
+ if value.is_a?(Array)
693
+ value.compact.map { |v| _to_hash(v) }
694
+ elsif value.is_a?(Hash)
695
+ {}.tap do |hash|
696
+ value.each { |k, v| hash[k] = _to_hash(v) }
697
+ end
698
+ elsif value.respond_to? :to_hash
699
+ value.to_hash
700
+ else
701
+ value
702
+ end
703
+ end
704
+
705
+ end
706
+
707
+ end