onlinepayments-sdk-ruby 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (269) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +2 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +140 -0
  5. data/Rakefile +34 -0
  6. data/lib/onlinepayments/sdk/api_exception.rb +42 -0
  7. data/lib/onlinepayments/sdk/api_resource.rb +115 -0
  8. data/lib/onlinepayments/sdk/authenticator.rb +16 -0
  9. data/lib/onlinepayments/sdk/authorization_exception.rb +13 -0
  10. data/lib/onlinepayments/sdk/call_context.rb +26 -0
  11. data/lib/onlinepayments/sdk/client.rb +82 -0
  12. data/lib/onlinepayments/sdk/communication_exception.rb +16 -0
  13. data/lib/onlinepayments/sdk/communicator.rb +300 -0
  14. data/lib/onlinepayments/sdk/communicator_configuration.rb +59 -0
  15. data/lib/onlinepayments/sdk/connection.rb +41 -0
  16. data/lib/onlinepayments/sdk/data_object.rb +31 -0
  17. data/lib/onlinepayments/sdk/declined_payment_exception.rb +30 -0
  18. data/lib/onlinepayments/sdk/declined_payout_exception.rb +32 -0
  19. data/lib/onlinepayments/sdk/declined_refund_exception.rb +32 -0
  20. data/lib/onlinepayments/sdk/declined_transaction_exception.rb +16 -0
  21. data/lib/onlinepayments/sdk/defaultimpl/authorization_type.rb +24 -0
  22. data/lib/onlinepayments/sdk/defaultimpl/default_authenticator.rb +108 -0
  23. data/lib/onlinepayments/sdk/defaultimpl/default_connection.rb +295 -0
  24. data/lib/onlinepayments/sdk/defaultimpl/default_marshaller.rb +32 -0
  25. data/lib/onlinepayments/sdk/defaultimpl.rb +6 -0
  26. data/lib/onlinepayments/sdk/domain/account_on_file.rb +49 -0
  27. data/lib/onlinepayments/sdk/domain/account_on_file_attribute.rb +38 -0
  28. data/lib/onlinepayments/sdk/domain/account_on_file_display_hints.rb +37 -0
  29. data/lib/onlinepayments/sdk/domain/additional_order_input.rb +54 -0
  30. data/lib/onlinepayments/sdk/domain/address.rb +50 -0
  31. data/lib/onlinepayments/sdk/domain/address_personal.rb +58 -0
  32. data/lib/onlinepayments/sdk/domain/airline_data.rb +128 -0
  33. data/lib/onlinepayments/sdk/domain/airline_flight_leg.rb +102 -0
  34. data/lib/onlinepayments/sdk/domain/airline_passenger.rb +38 -0
  35. data/lib/onlinepayments/sdk/domain/amount_breakdown.rb +30 -0
  36. data/lib/onlinepayments/sdk/domain/amount_of_money.rb +30 -0
  37. data/lib/onlinepayments/sdk/domain/api_error.rb +46 -0
  38. data/lib/onlinepayments/sdk/domain/bank_account_iban.rb +26 -0
  39. data/lib/onlinepayments/sdk/domain/browser_data.rb +42 -0
  40. data/lib/onlinepayments/sdk/domain/cancel_payment_response.rb +30 -0
  41. data/lib/onlinepayments/sdk/domain/capture.rb +46 -0
  42. data/lib/onlinepayments/sdk/domain/capture_output.rb +82 -0
  43. data/lib/onlinepayments/sdk/domain/capture_payment_request.rb +38 -0
  44. data/lib/onlinepayments/sdk/domain/capture_response.rb +46 -0
  45. data/lib/onlinepayments/sdk/domain/capture_status_output.rb +26 -0
  46. data/lib/onlinepayments/sdk/domain/captures_response.rb +33 -0
  47. data/lib/onlinepayments/sdk/domain/card.rb +38 -0
  48. data/lib/onlinepayments/sdk/domain/card_essentials.rb +34 -0
  49. data/lib/onlinepayments/sdk/domain/card_fraud_results.rb +34 -0
  50. data/lib/onlinepayments/sdk/domain/card_payment_method_specific_input.rb +98 -0
  51. data/lib/onlinepayments/sdk/domain/card_payment_method_specific_input_base.rb +86 -0
  52. data/lib/onlinepayments/sdk/domain/card_payment_method_specific_input_for_hosted_checkout.rb +26 -0
  53. data/lib/onlinepayments/sdk/domain/card_payment_method_specific_output.rb +78 -0
  54. data/lib/onlinepayments/sdk/domain/card_payout_method_specific_input.rb +38 -0
  55. data/lib/onlinepayments/sdk/domain/card_recurrence_details.rb +26 -0
  56. data/lib/onlinepayments/sdk/domain/card_without_cvv.rb +34 -0
  57. data/lib/onlinepayments/sdk/domain/company_information.rb +26 -0
  58. data/lib/onlinepayments/sdk/domain/complete_payment_card_payment_method_specific_input.rb +30 -0
  59. data/lib/onlinepayments/sdk/domain/complete_payment_request.rb +38 -0
  60. data/lib/onlinepayments/sdk/domain/complete_payment_response.rb +46 -0
  61. data/lib/onlinepayments/sdk/domain/contact_details.rb +42 -0
  62. data/lib/onlinepayments/sdk/domain/create_hosted_checkout_request.rb +78 -0
  63. data/lib/onlinepayments/sdk/domain/create_hosted_checkout_response.rb +48 -0
  64. data/lib/onlinepayments/sdk/domain/create_hosted_tokenization_request.rb +38 -0
  65. data/lib/onlinepayments/sdk/domain/create_hosted_tokenization_response.rb +50 -0
  66. data/lib/onlinepayments/sdk/domain/create_mandate_request.rb +58 -0
  67. data/lib/onlinepayments/sdk/domain/create_mandate_response.rb +38 -0
  68. data/lib/onlinepayments/sdk/domain/create_mandate_with_return_url.rb +58 -0
  69. data/lib/onlinepayments/sdk/domain/create_payment_request.rb +74 -0
  70. data/lib/onlinepayments/sdk/domain/create_payment_response.rb +46 -0
  71. data/lib/onlinepayments/sdk/domain/create_payout_request.rb +46 -0
  72. data/lib/onlinepayments/sdk/domain/create_token_request.rb +34 -0
  73. data/lib/onlinepayments/sdk/domain/created_payment_output.rb +34 -0
  74. data/lib/onlinepayments/sdk/domain/created_token_response.rb +50 -0
  75. data/lib/onlinepayments/sdk/domain/customer.rb +86 -0
  76. data/lib/onlinepayments/sdk/domain/customer_account.rb +70 -0
  77. data/lib/onlinepayments/sdk/domain/customer_account_authentication.rb +30 -0
  78. data/lib/onlinepayments/sdk/domain/customer_device.rb +50 -0
  79. data/lib/onlinepayments/sdk/domain/customer_payment_activity.rb +34 -0
  80. data/lib/onlinepayments/sdk/domain/customer_token.rb +46 -0
  81. data/lib/onlinepayments/sdk/domain/decrypted_payment_data.rb +42 -0
  82. data/lib/onlinepayments/sdk/domain/directory_entry.rb +34 -0
  83. data/lib/onlinepayments/sdk/domain/empty_validator.rb +12 -0
  84. data/lib/onlinepayments/sdk/domain/error_response.rb +37 -0
  85. data/lib/onlinepayments/sdk/domain/external_cardholder_authentication_data.rb +58 -0
  86. data/lib/onlinepayments/sdk/domain/external_token_linked.rb +34 -0
  87. data/lib/onlinepayments/sdk/domain/fixed_list_validator.rb +32 -0
  88. data/lib/onlinepayments/sdk/domain/fraud_fields.rb +30 -0
  89. data/lib/onlinepayments/sdk/domain/fraud_results.rb +26 -0
  90. data/lib/onlinepayments/sdk/domain/g_pay_three_d_secure.rb +46 -0
  91. data/lib/onlinepayments/sdk/domain/get_hosted_checkout_response.rb +34 -0
  92. data/lib/onlinepayments/sdk/domain/get_hosted_tokenization_response.rb +34 -0
  93. data/lib/onlinepayments/sdk/domain/get_iin_details_request.rb +34 -0
  94. data/lib/onlinepayments/sdk/domain/get_iin_details_response.rb +45 -0
  95. data/lib/onlinepayments/sdk/domain/get_mandate_response.rb +30 -0
  96. data/lib/onlinepayments/sdk/domain/get_payment_product_groups_response.rb +33 -0
  97. data/lib/onlinepayments/sdk/domain/get_payment_products_response.rb +33 -0
  98. data/lib/onlinepayments/sdk/domain/gift_card_purchase.rb +34 -0
  99. data/lib/onlinepayments/sdk/domain/hosted_checkout_specific_input.rb +66 -0
  100. data/lib/onlinepayments/sdk/domain/hosted_checkout_specific_output.rb +30 -0
  101. data/lib/onlinepayments/sdk/domain/iin_detail.rb +30 -0
  102. data/lib/onlinepayments/sdk/domain/label_template_element.rb +30 -0
  103. data/lib/onlinepayments/sdk/domain/length_validator.rb +30 -0
  104. data/lib/onlinepayments/sdk/domain/line_item.rb +46 -0
  105. data/lib/onlinepayments/sdk/domain/line_item_invoice_data.rb +26 -0
  106. data/lib/onlinepayments/sdk/domain/loan_recipient.rb +42 -0
  107. data/lib/onlinepayments/sdk/domain/lodging_data.rb +26 -0
  108. data/lib/onlinepayments/sdk/domain/mandate_address.rb +42 -0
  109. data/lib/onlinepayments/sdk/domain/mandate_contact_details.rb +26 -0
  110. data/lib/onlinepayments/sdk/domain/mandate_customer.rb +58 -0
  111. data/lib/onlinepayments/sdk/domain/mandate_merchant_action.rb +34 -0
  112. data/lib/onlinepayments/sdk/domain/mandate_personal_information.rb +34 -0
  113. data/lib/onlinepayments/sdk/domain/mandate_personal_name.rb +30 -0
  114. data/lib/onlinepayments/sdk/domain/mandate_redirect_data.rb +30 -0
  115. data/lib/onlinepayments/sdk/domain/mandate_response.rb +50 -0
  116. data/lib/onlinepayments/sdk/domain/merchant_action.rb +34 -0
  117. data/lib/onlinepayments/sdk/domain/mobile_payment_data.rb +30 -0
  118. data/lib/onlinepayments/sdk/domain/mobile_payment_method_hosted_checkout_specific_input.rb +30 -0
  119. data/lib/onlinepayments/sdk/domain/mobile_payment_method_specific_input.rb +62 -0
  120. data/lib/onlinepayments/sdk/domain/mobile_payment_method_specific_output.rb +58 -0
  121. data/lib/onlinepayments/sdk/domain/mobile_payment_product320_specific_input.rb +30 -0
  122. data/lib/onlinepayments/sdk/domain/operation_output.rb +58 -0
  123. data/lib/onlinepayments/sdk/domain/order.rb +70 -0
  124. data/lib/onlinepayments/sdk/domain/order_line_details.rb +54 -0
  125. data/lib/onlinepayments/sdk/domain/order_references.rb +34 -0
  126. data/lib/onlinepayments/sdk/domain/order_status_output.rb +49 -0
  127. data/lib/onlinepayments/sdk/domain/order_type_information.rb +30 -0
  128. data/lib/onlinepayments/sdk/domain/payment_account_on_file.rb +30 -0
  129. data/lib/onlinepayments/sdk/domain/payment_context.rb +38 -0
  130. data/lib/onlinepayments/sdk/domain/payment_creation_output.rb +38 -0
  131. data/lib/onlinepayments/sdk/domain/payment_details_response.rb +65 -0
  132. data/lib/onlinepayments/sdk/domain/payment_error_response.rb +45 -0
  133. data/lib/onlinepayments/sdk/domain/payment_output.rb +82 -0
  134. data/lib/onlinepayments/sdk/domain/payment_product.rb +102 -0
  135. data/lib/onlinepayments/sdk/domain/payment_product130_specific_input.rb +30 -0
  136. data/lib/onlinepayments/sdk/domain/payment_product130_specific_three_d_secure.rb +38 -0
  137. data/lib/onlinepayments/sdk/domain/payment_product302_specific_data.rb +32 -0
  138. data/lib/onlinepayments/sdk/domain/payment_product320_specific_data.rb +36 -0
  139. data/lib/onlinepayments/sdk/domain/payment_product5100_specific_input.rb +26 -0
  140. data/lib/onlinepayments/sdk/domain/payment_product5402_specific_output.rb +26 -0
  141. data/lib/onlinepayments/sdk/domain/payment_product5500_specific_output.rb +34 -0
  142. data/lib/onlinepayments/sdk/domain/payment_product771_specific_output.rb +26 -0
  143. data/lib/onlinepayments/sdk/domain/payment_product840_customer_account.rb +54 -0
  144. data/lib/onlinepayments/sdk/domain/payment_product840_specific_output.rb +53 -0
  145. data/lib/onlinepayments/sdk/domain/payment_product_display_hints.rb +34 -0
  146. data/lib/onlinepayments/sdk/domain/payment_product_field.rb +46 -0
  147. data/lib/onlinepayments/sdk/domain/payment_product_field_data_restrictions.rb +34 -0
  148. data/lib/onlinepayments/sdk/domain/payment_product_field_display_element.rb +38 -0
  149. data/lib/onlinepayments/sdk/domain/payment_product_field_display_hints.rb +70 -0
  150. data/lib/onlinepayments/sdk/domain/payment_product_field_form_element.rb +37 -0
  151. data/lib/onlinepayments/sdk/domain/payment_product_field_tooltip.rb +30 -0
  152. data/lib/onlinepayments/sdk/domain/payment_product_field_validators.rb +90 -0
  153. data/lib/onlinepayments/sdk/domain/payment_product_filter.rb +42 -0
  154. data/lib/onlinepayments/sdk/domain/payment_product_filters_hosted_checkout.rb +37 -0
  155. data/lib/onlinepayments/sdk/domain/payment_product_group.rb +52 -0
  156. data/lib/onlinepayments/sdk/domain/payment_product_networks_response.rb +32 -0
  157. data/lib/onlinepayments/sdk/domain/payment_references.rb +30 -0
  158. data/lib/onlinepayments/sdk/domain/payment_response.rb +54 -0
  159. data/lib/onlinepayments/sdk/domain/payment_status_output.rb +57 -0
  160. data/lib/onlinepayments/sdk/domain/payout_error_response.rb +45 -0
  161. data/lib/onlinepayments/sdk/domain/payout_output.rb +30 -0
  162. data/lib/onlinepayments/sdk/domain/payout_response.rb +46 -0
  163. data/lib/onlinepayments/sdk/domain/payout_result.rb +46 -0
  164. data/lib/onlinepayments/sdk/domain/payout_status_output.rb +34 -0
  165. data/lib/onlinepayments/sdk/domain/personal_information.rb +38 -0
  166. data/lib/onlinepayments/sdk/domain/personal_information_token.rb +30 -0
  167. data/lib/onlinepayments/sdk/domain/personal_name.rb +34 -0
  168. data/lib/onlinepayments/sdk/domain/personal_name_token.rb +30 -0
  169. data/lib/onlinepayments/sdk/domain/product_directory.rb +33 -0
  170. data/lib/onlinepayments/sdk/domain/protection_eligibility.rb +30 -0
  171. data/lib/onlinepayments/sdk/domain/range_validator.rb +30 -0
  172. data/lib/onlinepayments/sdk/domain/redirect_data.rb +30 -0
  173. data/lib/onlinepayments/sdk/domain/redirect_payment_method_specific_input.rb +66 -0
  174. data/lib/onlinepayments/sdk/domain/redirect_payment_method_specific_output.rb +66 -0
  175. data/lib/onlinepayments/sdk/domain/redirect_payment_product809_specific_input.rb +26 -0
  176. data/lib/onlinepayments/sdk/domain/redirect_payment_product840_specific_input.rb +26 -0
  177. data/lib/onlinepayments/sdk/domain/redirection_data.rb +26 -0
  178. data/lib/onlinepayments/sdk/domain/refund_card_method_specific_output.rb +30 -0
  179. data/lib/onlinepayments/sdk/domain/refund_e_wallet_method_specific_output.rb +38 -0
  180. data/lib/onlinepayments/sdk/domain/refund_error_response.rb +45 -0
  181. data/lib/onlinepayments/sdk/domain/refund_mobile_method_specific_output.rb +34 -0
  182. data/lib/onlinepayments/sdk/domain/refund_output.rb +82 -0
  183. data/lib/onlinepayments/sdk/domain/refund_payment_product840_customer_account.rb +34 -0
  184. data/lib/onlinepayments/sdk/domain/refund_payment_product840_specific_output.rb +30 -0
  185. data/lib/onlinepayments/sdk/domain/refund_redirect_method_specific_output.rb +30 -0
  186. data/lib/onlinepayments/sdk/domain/refund_request.rb +38 -0
  187. data/lib/onlinepayments/sdk/domain/refund_response.rb +46 -0
  188. data/lib/onlinepayments/sdk/domain/refunds_response.rb +33 -0
  189. data/lib/onlinepayments/sdk/domain/regular_expression_validator.rb +26 -0
  190. data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_method_specific_input.rb +34 -0
  191. data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_method_specific_input_base.rb +34 -0
  192. data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_method_specific_output.rb +42 -0
  193. data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_product771_specific_input.rb +34 -0
  194. data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_product771_specific_input_base.rb +34 -0
  195. data/lib/onlinepayments/sdk/domain/session_request.rb +32 -0
  196. data/lib/onlinepayments/sdk/domain/session_response.rb +48 -0
  197. data/lib/onlinepayments/sdk/domain/shipping.rb +58 -0
  198. data/lib/onlinepayments/sdk/domain/shopping_cart.rb +64 -0
  199. data/lib/onlinepayments/sdk/domain/shopping_cart_extension.rb +52 -0
  200. data/lib/onlinepayments/sdk/domain/test_connection.rb +26 -0
  201. data/lib/onlinepayments/sdk/domain/three_d_secure.rb +78 -0
  202. data/lib/onlinepayments/sdk/domain/three_d_secure_base.rb +58 -0
  203. data/lib/onlinepayments/sdk/domain/three_d_secure_data.rb +34 -0
  204. data/lib/onlinepayments/sdk/domain/three_d_secure_results.rb +30 -0
  205. data/lib/onlinepayments/sdk/domain/token_card.rb +34 -0
  206. data/lib/onlinepayments/sdk/domain/token_card_data.rb +30 -0
  207. data/lib/onlinepayments/sdk/domain/token_card_specific_input.rb +30 -0
  208. data/lib/onlinepayments/sdk/domain/token_data.rb +30 -0
  209. data/lib/onlinepayments/sdk/domain/token_e_wallet.rb +34 -0
  210. data/lib/onlinepayments/sdk/domain/token_response.rb +58 -0
  211. data/lib/onlinepayments/sdk/domain/value_mapping_element.rb +37 -0
  212. data/lib/onlinepayments/sdk/endpoint_configuration.rb +127 -0
  213. data/lib/onlinepayments/sdk/exceptions.rb +8 -0
  214. data/lib/onlinepayments/sdk/factory.rb +136 -0
  215. data/lib/onlinepayments/sdk/idempotence_exception.rb +24 -0
  216. data/lib/onlinepayments/sdk/logging/communicator_logger.rb +22 -0
  217. data/lib/onlinepayments/sdk/logging/log_message_builder.rb +56 -0
  218. data/lib/onlinepayments/sdk/logging/logging_capable.rb +17 -0
  219. data/lib/onlinepayments/sdk/logging/logging_util.rb +286 -0
  220. data/lib/onlinepayments/sdk/logging/request_log_message_builder.rb +39 -0
  221. data/lib/onlinepayments/sdk/logging/response_log_message_builder.rb +34 -0
  222. data/lib/onlinepayments/sdk/logging/ruby_communicator_logger.rb +57 -0
  223. data/lib/onlinepayments/sdk/logging/stdout_communicator_logger.rb +34 -0
  224. data/lib/onlinepayments/sdk/logging.rb +10 -0
  225. data/lib/onlinepayments/sdk/marshaller.rb +24 -0
  226. data/lib/onlinepayments/sdk/marshaller_syntax_exception.rb +6 -0
  227. data/lib/onlinepayments/sdk/merchant/hostedcheckout/hosted_checkout_client.rb +86 -0
  228. data/lib/onlinepayments/sdk/merchant/hostedtokenization/hosted_tokenization_client.rb +86 -0
  229. data/lib/onlinepayments/sdk/merchant/mandates/mandates_client.rb +182 -0
  230. data/lib/onlinepayments/sdk/merchant/merchant_client.rb +89 -0
  231. data/lib/onlinepayments/sdk/merchant/payments/payments_client.rb +322 -0
  232. data/lib/onlinepayments/sdk/merchant/payouts/payouts_client.rb +86 -0
  233. data/lib/onlinepayments/sdk/merchant/productgroups/get_product_group_params.rb +57 -0
  234. data/lib/onlinepayments/sdk/merchant/productgroups/get_product_groups_params.rb +57 -0
  235. data/lib/onlinepayments/sdk/merchant/productgroups/product_groups_client.rb +87 -0
  236. data/lib/onlinepayments/sdk/merchant/products/get_payment_product_networks_params.rb +38 -0
  237. data/lib/onlinepayments/sdk/merchant/products/get_payment_product_params.rb +57 -0
  238. data/lib/onlinepayments/sdk/merchant/products/get_payment_products_params.rb +57 -0
  239. data/lib/onlinepayments/sdk/merchant/products/get_product_directory_params.rb +30 -0
  240. data/lib/onlinepayments/sdk/merchant/products/products_client.rb +155 -0
  241. data/lib/onlinepayments/sdk/merchant/services/services_client.rb +82 -0
  242. data/lib/onlinepayments/sdk/merchant/sessions/sessions_client.rb +54 -0
  243. data/lib/onlinepayments/sdk/merchant/tokens/tokens_client.rb +116 -0
  244. data/lib/onlinepayments/sdk/meta_data_provider.rb +150 -0
  245. data/lib/onlinepayments/sdk/modules.rb +62 -0
  246. data/lib/onlinepayments/sdk/not_found_exception.rb +16 -0
  247. data/lib/onlinepayments/sdk/param_request.rb +11 -0
  248. data/lib/onlinepayments/sdk/payment_platform_exception.rb +15 -0
  249. data/lib/onlinepayments/sdk/pooled_connection.rb +21 -0
  250. data/lib/onlinepayments/sdk/proxy_configuration.rb +74 -0
  251. data/lib/onlinepayments/sdk/reference_exception.rb +14 -0
  252. data/lib/onlinepayments/sdk/request_header.rb +50 -0
  253. data/lib/onlinepayments/sdk/request_param.rb +23 -0
  254. data/lib/onlinepayments/sdk/response_exception.rb +47 -0
  255. data/lib/onlinepayments/sdk/response_header.rb +42 -0
  256. data/lib/onlinepayments/sdk/validation_exception.rb +14 -0
  257. data/lib/onlinepayments/sdk/webhooks/api_version_mismatch_exception.rb +20 -0
  258. data/lib/onlinepayments/sdk/webhooks/in_memory_secret_key_store.rb +56 -0
  259. data/lib/onlinepayments/sdk/webhooks/secret_key_not_available_exception.rb +17 -0
  260. data/lib/onlinepayments/sdk/webhooks/secret_key_store.rb +16 -0
  261. data/lib/onlinepayments/sdk/webhooks/signature_validation_exception.rb +19 -0
  262. data/lib/onlinepayments/sdk/webhooks/webhooks.rb +22 -0
  263. data/lib/onlinepayments/sdk/webhooks/webhooks_event.rb +58 -0
  264. data/lib/onlinepayments/sdk/webhooks/webhooks_helper.rb +100 -0
  265. data/lib/onlinepayments/sdk/webhooks/webhooks_helper_builder.rb +25 -0
  266. data/lib/onlinepayments/sdk/webhooks.rb +11 -0
  267. data/lib/onlinepayments/sdk.rb +26 -0
  268. data/onlinepayments-sdk-ruby.gemspec +28 -0
  269. metadata +416 -0
@@ -0,0 +1,108 @@
1
+ require 'openssl' # for HMAC-SHA256
2
+ require 'base64'
3
+
4
+ module OnlinePayments::SDK
5
+ module DefaultImpl
6
+
7
+ # Authenticates requests made to the Online Payments platform using the HMAC algorithm.
8
+ class DefaultAuthenticator < Authenticator
9
+
10
+ # HMAC algorithm used to generate the signature
11
+ HMAC_ALGOR = 'SHA256'.freeze
12
+ CONTENT_TYPE = 'Content-Type'.freeze
13
+ DATE = 'Date'.freeze
14
+ XGCS = 'x-gcs'.freeze
15
+
16
+ # Construct a new DefaultAuthenticator instance that can sign requests
17
+ # with the provided _api_key_id_ and _secret_api_key_.
18
+ #
19
+ # @param api_key_id [String] identifier for the secret key used in authentication.
20
+ # @param secret_api_key [String] the secret key that is used to generate the authentication signature.
21
+ # @param authorization_type [String] the authorization protocol to use for authentication.
22
+ def initialize(api_key_id, secret_api_key, authorization_type = AuthorizationType::V1HMAC)
23
+ raise ArgumentError unless api_key_id && !api_key_id.strip.empty?
24
+ raise ArgumentError unless secret_api_key && !secret_api_key.strip.empty?
25
+ raise ArgumentError unless authorization_type && !authorization_type.strip.empty?
26
+
27
+ @api_key_id = api_key_id
28
+ @secret_api_key = secret_api_key
29
+ @authorization_type = authorization_type
30
+ end
31
+
32
+ # Creates a signature to authenticate a request.
33
+ #
34
+ # @param http_method [String] 'GET', 'PUT', 'POST' or 'DELETE' indicating which HTTP method will be used with the request
35
+ # @param resource_uri [URI::HTTP] URI object that includes #path and #query of the URL that will be used, #query may be *nil*
36
+ # @param http_headers [Array<OnlinePayments::SDK::RequestHeader>] list that contains all headers used by the request
37
+ # @return [String] the created signature
38
+ def create_simple_authentication_signature(http_method, resource_uri, http_headers)
39
+ raise ArgumentError unless http_method && !http_method.strip.empty?
40
+ raise ArgumentError unless resource_uri
41
+
42
+ data_to_sign = to_data_to_sign(http_method, resource_uri, http_headers)
43
+ "GCS #{@authorization_type}:#{@api_key_id}:#{create_auth_signature(data_to_sign)}"
44
+ end
45
+
46
+ protected
47
+
48
+ # Canonizes the _http_method_, _resource_uri_ and _http_headers_ so a unique signature can be generated.
49
+ # Canonical form is as follows:
50
+ # * _http_method_ in upper case
51
+ # * Content-Type
52
+ # * Date header
53
+ # * X-GCS headers sorted alphabetically. Names are in lowercase and values are stripped of excess whitespace
54
+ # * path and query portion of the uri, separated by a question mark
55
+ def to_data_to_sign(http_method, resource_uri, http_headers)
56
+ content_type = ''
57
+ date = ''
58
+ canonical_resource = to_canonical_resource(resource_uri)
59
+ xgc_http_headers = []
60
+
61
+ http_headers&.each do |header|
62
+ name = header.name
63
+ value = header.value
64
+ case
65
+ when name.casecmp(CONTENT_TYPE).zero?
66
+ content_type = value
67
+ when name.casecmp(DATE).zero?
68
+ date = value
69
+ when to_canonical_header_name(name).start_with?("x-gcs")
70
+ xgc_http_headers << [to_canonical_header_name(name), to_canonical_header_value(value)]
71
+ end
72
+ end
73
+
74
+ xgc_http_headers.sort! { |(h1, v1), (h2, v2)| h1 <=> h2 } unless xgc_http_headers.empty?
75
+
76
+ data = "#{http_method.upcase}\n#{content_type}\n#{date}\n"
77
+ data << xgc_http_headers.inject('') { |s, (k, v)| "#{s}#{k}:#{v}\n" } unless xgc_http_headers.empty?
78
+ data << "#{canonical_resource}\n" if canonical_resource
79
+ end
80
+
81
+ # Applies the HMAC algorithm to the canonicalized data to obtain an HMAC digest.
82
+ # Afterwards the HMAC digest is encoded using base64 encoding.
83
+ def create_auth_signature(data_to_sign)
84
+ digest = OpenSSL::Digest.new(HMAC_ALGOR)
85
+ hmac = OpenSSL::HMAC.digest(digest, @secret_api_key, data_to_sign)
86
+ Base64.strict_encode64(hmac).strip
87
+ end
88
+
89
+ private
90
+
91
+ # Returns the encoded URI path without the HTTP method and including all decoded query parameters.
92
+ def to_canonical_resource(resource_uri)
93
+ return "#{resource_uri.path}?#{resource_uri.query}" if resource_uri.query
94
+ resource_uri.path
95
+ end
96
+
97
+ def to_canonical_header_name(original_name)
98
+ original_name ? original_name.downcase : original_name
99
+ end
100
+
101
+ # Strips a header value of excess whitespace to produce a canonical value
102
+ def to_canonical_header_value(original_value)
103
+ return '' unless original_value
104
+ original_value.gsub(/\r?\n[\s&&[^\r\n]]*/, ' ').strip
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,295 @@
1
+ require 'securerandom'
2
+ require 'uri'
3
+ require 'httpclient'
4
+
5
+ # @private :nodoc: this is not our class
6
+ module RefineHTTPClient
7
+ refine HTTPClient do
8
+ # (monkey) patch to gain access to the session pool size in HTTPClient
9
+ def session_count
10
+ sess_pool = @session_manager.instance_variable_get(:@sess_pool)
11
+ sess_pool.size
12
+ end
13
+ end
14
+ end
15
+
16
+ module OnlinePayments::SDK
17
+ module DefaultImpl
18
+ class DefaultConnection < PooledConnection
19
+ using RefineHTTPClient
20
+
21
+ CONTENT_TYPE = 'Content-Type'.freeze
22
+ JSON_CONTENT_TYPE = 'application/json'.freeze
23
+
24
+ # @param args [Hash] the parameters to initialize the connection with
25
+ # @option args [Integer] :connect_timeout connection timeout in seconds.
26
+ # Uses {CommunicatorConfiguration.default_connect_timeout} if not given.
27
+ # @option args [Integer] :socket_timeout socket timeout in seconds.
28
+ # Uses {CommunicatorConfiguration.default_socket_timeout} if not given.
29
+ # @option args [Integer] :max_connections number of connections kept alive in the thread pool.
30
+ # Uses {CommunicatorConfiguration.default_max_connections} if not given.
31
+ # @option args [Hash] :proxy_configuration object that stores the proxy to use.
32
+ # If not given the system default proxy is used;
33
+ # if there is no system default proxy set either, no proxy is used.
34
+ def initialize(args)
35
+ raise ArgumentError unless args.is_a? Hash
36
+
37
+ super()
38
+
39
+ # Set timeouts to nil if they are negative
40
+ @connect_timeout = args[:connect_timeout] || CommunicatorConfiguration.default_connect_timeout
41
+ @connect_timeout = nil unless @connect_timeout&.positive?
42
+ @socket_timeout = args[:socket_timeout] || CommunicatorConfiguration.default_socket_timeout
43
+ @socket_timeout = nil unless @socket_timeout&.positive?
44
+ @max_connections = args[:max_connections] || CommunicatorConfiguration.default_max_connections
45
+ @proxy_configuration = args[:proxy_configuration]
46
+
47
+ # HTTPClient provides the following features:
48
+ # 1) thread safe, an instance can be used by multiple threads without
49
+ # explicit synchronization
50
+ # 2) use persistent connection if HTTP 1.1 is supported. The connection
51
+ # will be left open until explicitly closed or keep_alive_timeout
52
+ # 3) a built-in connection pool with no limit for max connections
53
+ @http_client = create_http_client
54
+ @http_client.connect_timeout = @connect_timeout
55
+ @http_client.send_timeout = @socket_timeout
56
+ @http_client.receive_timeout = @socket_timeout
57
+ end
58
+
59
+ private
60
+
61
+ # Create a HTTPClient instance that uses @proxy_configuration or the system proxy if @proxy_configuration is not set
62
+ def create_http_client
63
+ if @proxy_configuration
64
+ httpclient = HTTPClient.new(@proxy_configuration.proxy_uri)
65
+ httpclient.set_proxy_auth(@proxy_configuration.username, @proxy_configuration.password)
66
+ httpclient.force_basic_auth = true if @proxy_configuration.username && @proxy_configuration.password
67
+ else
68
+ # use system settings
69
+ proxy_string = ENV['https_proxy'] || ENV['http_proxy']
70
+ # proxy string format = 'http://username:password@hostname:port'
71
+ proxy_string =~ %r{https?//(?<username>[^:]):(?<password>[^@])@.*}
72
+ username = Regexp.last_match(1)
73
+ password = Regexp.last_match(2)
74
+ httpclient = HTTPClient.new(proxy_string)
75
+ httpclient.set_proxy_auth(username, password) if username && password
76
+ httpclient.force_basic_auth = true if username && password
77
+ end
78
+ httpclient
79
+ end
80
+
81
+ public
82
+
83
+ # Closes all connections idle for longer than _idle_time_ seconds.
84
+ # In addition, the keep_alive_timeout is set to _idle_time_
85
+ # so any future connections idle for longer than _idle_time_ seconds will also be closed.
86
+ def close_idle_connections(idle_time)
87
+ # in sec
88
+ @http_client.keep_alive_timeout = idle_time # set timeout value
89
+ close_expired_connections
90
+ end
91
+
92
+ # HTTPClient automatically closes expired connections so _close_expired_connections_ is a no-operation.
93
+ def close_expired_connections
94
+ # By default the keep alive timeout is 15 sec, which is the HTTP 1.1
95
+ # standard. To change the value, use keep_alive_timeout= method
96
+ # do nothing, handled by HTTPClient
97
+ end
98
+
99
+ # Frees all networking resources used.
100
+ def close
101
+ @http_client.reset_all
102
+ end
103
+
104
+ # Returns the number of open connections
105
+ def session_count
106
+ @http_client.session_count
107
+ end
108
+
109
+ # Performs a GET request to the Online Payments platform
110
+ # @see request
111
+ def get(uri, request_headers)
112
+ request('get', uri, request_headers) do |response_status_code, response_headers, response_body|
113
+ yield response_status_code, response_headers, response_body
114
+ end
115
+ end
116
+
117
+ # Performs a DELETE request to the Online Payments platform
118
+ # @see request
119
+ def delete(uri, request_headers)
120
+ request('delete', uri, request_headers) do |response_status_code, response_headers, response_body|
121
+ yield response_status_code, response_headers, response_body
122
+ end
123
+ end
124
+
125
+ # Performs a POST request to the Online Payments platform
126
+ # @see request
127
+ def post(uri, request_headers, body)
128
+ request('post', uri, request_headers, body) do |response_status_code, response_headers, response_body|
129
+ yield response_status_code, response_headers, response_body
130
+ end
131
+ end
132
+
133
+ # Performs a PUT request to the Online Payments platform
134
+ # @see request
135
+ def put(uri, request_headers, body)
136
+ request('put', uri, request_headers, body) do |response_status_code, response_headers, response_body|
137
+ yield response_status_code, response_headers, response_body
138
+ end
139
+ end
140
+
141
+ # Performs a HTTP request and yields the response as the status code, headers and body.
142
+ # Also ensures the request is logged when sent and its response is logged when received.
143
+ #
144
+ # @param method [String] 'GET', 'DELETE', 'POST' or 'PUT' depending on the HTTP method being used.
145
+ # @param uri [URI::HTTP] full URI of the location the request is targeted at, including query parameters.
146
+ # @param request_headers [Array<OnlinePayments::SDK::RequestHeader>] list of headers that should be used as HTTP headers in the request.
147
+ # @param body [String] request body.
148
+ # @yield (Integer, Array<OnlinePayments::SDK::ResponseHeader>, IO) The status code, headers and body of the response.
149
+ # @raise [OnlinePayments::SDK::CommunicationException] when communication with the Online Payments platform was not successful.
150
+ def request(method, uri, request_headers, body = nil)
151
+ request_headers = convert_from_headers(request_headers)
152
+ request_id = SecureRandom.uuid
153
+ content_type = request_headers[CONTENT_TYPE]
154
+
155
+ info = { headers: request_headers, content_type: content_type }
156
+ info[:body] = body if body
157
+
158
+ log_request(request_id, method.upcase, uri, info)
159
+
160
+ start_time = Time.now
161
+ begin
162
+ response_headers = nil
163
+ response_status_code = nil
164
+ response_content_type = nil
165
+ response_body = ''
166
+ raw_request(method, uri, request_headers, body) do |status_code, headers, r_content_type, r_body|
167
+ response_headers = headers
168
+ response_status_code = status_code
169
+ response_content_type = r_content_type
170
+ response_body = r_body.read.force_encoding('UTF-8')
171
+ r_body = StringIO.new(response_body)
172
+
173
+ yield status_code, headers, r_body
174
+ end
175
+
176
+ log_response(request_id, response_status_code, start_time,
177
+ headers: response_headers, body: response_body,
178
+ content_type: response_content_type)
179
+ rescue HTTPClient::TimeoutError => e
180
+ log_error(request_id, start_time, e)
181
+ raise OnlinePayments::SDK::CommunicationException, e
182
+ rescue HTTPClient::KeepAliveDisconnected, HTTPClient::RetryableResponse => e # retry these?
183
+ log_error(request_id, start_time, e)
184
+ raise OnlinePayments::SDK::CommunicationException, e
185
+ rescue StandardError => e
186
+ log_error(request_id, start_time, e)
187
+ raise OnlinePayments::SDK::CommunicationException, e
188
+ end
189
+ end
190
+
191
+ # logging code
192
+
193
+ # Enables logging outgoing requests and incoming responses by registering the _communicator_logger_.
194
+ # Note that only one logger can be registered at a time and calling _enable_logging_
195
+ # a second time will override the old logger instance with the new one.
196
+ #
197
+ # @param communicator_logger [OnlinePayments::SDK::Logging::CommunicatorLogger] the communicator logger the requests and responses are logged to
198
+ def enable_logging(communicator_logger)
199
+ raise ArgumentError, 'communicatorLogger is required' unless communicator_logger
200
+
201
+ @communicator_logger = communicator_logger
202
+ end
203
+
204
+ # Disables logging by unregistering any previous logger that might be registered.
205
+ def disable_logging
206
+ @communicator_logger = nil
207
+ end
208
+
209
+ private
210
+
211
+ # Converts a {OnlinePayments::SDK::RequestHeader} list headers to a hash
212
+ def convert_from_headers(headers)
213
+ headers.each_with_object({}) { |h, hash| hash[h.name] = h.value }
214
+ end
215
+
216
+ # Converts a hash to a {OnlinePayments::SDK::ResponseHeader} list
217
+ def convert_to_response_headers(headers)
218
+ arr ||= []
219
+ headers.each { |k, v| arr << OnlinePayments::SDK::ResponseHeader.new(k, v) }
220
+ arr
221
+ end
222
+
223
+ def log_request(request_id, method, uri, args = {})
224
+ return unless @communicator_logger
225
+
226
+ headers = args[:headers]
227
+ body = args[:body]
228
+ content_type = args[:content_type]
229
+ log_msg_builder = OnlinePayments::SDK::Logging::RequestLogMessageBuilder.new(request_id, method, uri)
230
+ headers.each { |k, v| log_msg_builder.add_headers(k, v) } if headers
231
+
232
+ log_msg_builder.set_body(body, content_type)
233
+
234
+ begin
235
+ @communicator_logger.log(log_msg_builder.get_message)
236
+ rescue StandardError => e
237
+ @communicator_logger.log("An error occurred trying to log request #{request_id}", e)
238
+ end
239
+ end
240
+
241
+ # Creates the log_response stream
242
+ def log_response(request_id, status_code, start_time, args = {})
243
+ return unless @communicator_logger
244
+
245
+ duration = (Time.now - start_time) * 1000 # in milliseconds
246
+ headers = args[:headers]
247
+ body = args[:body] if args[:body]
248
+ content_type = args[:content_type]
249
+
250
+ log_msg_builder = OnlinePayments::SDK::Logging::ResponseLogMessageBuilder.new(request_id, status_code, duration)
251
+ if headers
252
+ convert_from_headers(headers)
253
+ .each do |key, value|
254
+ log_msg_builder.add_headers(key, value)
255
+ end
256
+ end
257
+
258
+ log_msg_builder.set_body(body, content_type)
259
+
260
+ begin
261
+ @communicator_logger.log(log_msg_builder.get_message)
262
+ rescue StandardError => e
263
+ @communicator_logger.log("An error occurred trying to log response #{request_id}", e)
264
+ end
265
+ end
266
+
267
+ def log_error(request_id, start_time, thrown)
268
+ return unless @communicator_logger
269
+
270
+ duration = (Time.now - start_time) * 1000 # in millisecs
271
+ @communicator_logger.log("Error occurred for outgoing request (requestId='#{request_id}', #{duration} ms)", thrown)
272
+ end
273
+
274
+ # Makes a request using the specified method
275
+ #
276
+ # Yields a status code, an array of {OnlinePayments::SDK::ResponseHeader},
277
+ # the content_type and body
278
+ def raw_request(method, uri, headers, body = nil)
279
+ connection = body ?
280
+ @http_client.send("#{method}_async", uri, body: body, header: headers) :
281
+ @http_client.send("#{method}_async", uri, header: headers)
282
+
283
+ response = connection.pop
284
+ pipe = response.content
285
+ response_headers = convert_to_response_headers(response.headers)
286
+
287
+ begin
288
+ yield response.status_code, response_headers, response.content_type, pipe
289
+ ensure
290
+ pipe.close
291
+ end
292
+ end
293
+ end
294
+ end
295
+ end
@@ -0,0 +1,32 @@
1
+ require 'json'
2
+ require 'singleton'
3
+
4
+ module OnlinePayments::SDK
5
+ module DefaultImpl
6
+ # marshals objects to and from JSON format.
7
+ # Currently supports marshalling and unmarshalling of classes that support class.new_from_hash and class#to_h
8
+ class DefaultMarshaller < OnlinePayments::SDK::Marshaller
9
+ include Singleton
10
+
11
+ # NOTE: this alias is needed to not break existing method calls depending on old interface
12
+ class << self
13
+ alias_method :INSTANCE, :instance
14
+ end
15
+
16
+ # Marshals the _request_object_ to a JSON string using request_object#to_h
17
+ def marshal(request_object)
18
+ JSON.pretty_generate(request_object.to_h)
19
+ end
20
+
21
+ # Unmarshals a JSON string into an object of type _klass_ using klass.new_from_hash
22
+ # @param [String] json_string
23
+ def unmarshal(json_string, klass)
24
+ return nil unless json_string
25
+ return '' if json_string.empty?
26
+ return klass.new_from_hash(JSON.parse(json_string)) if klass.respond_to?(:new_from_hash)
27
+
28
+ raise NotImplementedError
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,6 @@
1
+ prefix = 'onlinepayments/sdk/defaultimpl'
2
+
3
+ require "#{prefix}/authorization_type"
4
+ require "#{prefix}/default_marshaller"
5
+ require "#{prefix}/default_connection"
6
+ require "#{prefix}/default_authenticator"
@@ -0,0 +1,49 @@
1
+ #
2
+ # This class was auto-generated.
3
+ #
4
+ require 'onlinepayments/sdk/data_object'
5
+ require 'onlinepayments/sdk/domain/account_on_file_attribute'
6
+ require 'onlinepayments/sdk/domain/account_on_file_display_hints'
7
+
8
+ module OnlinePayments::SDK
9
+ module Domain
10
+
11
+ # @attr [Array<OnlinePayments::SDK::Domain::AccountOnFileAttribute>] attributes
12
+ # @attr [OnlinePayments::SDK::Domain::AccountOnFileDisplayHints] display_hints
13
+ # @attr [Integer] id
14
+ # @attr [Integer] payment_product_id
15
+ class AccountOnFile < OnlinePayments::SDK::DataObject
16
+ attr_accessor :attributes
17
+ attr_accessor :display_hints
18
+ attr_accessor :id
19
+ attr_accessor :payment_product_id
20
+
21
+ # @return (Hash)
22
+ def to_h
23
+ hash = super
24
+ hash['attributes'] = @attributes.collect(&:to_h) if @attributes
25
+ hash['displayHints'] = @display_hints.to_h if @display_hints
26
+ hash['id'] = @id unless @id.nil?
27
+ hash['paymentProductId'] = @payment_product_id unless @payment_product_id.nil?
28
+ hash
29
+ end
30
+
31
+ def from_hash(hash)
32
+ super
33
+ if hash.key? 'attributes'
34
+ raise TypeError, "value '%s' is not an Array" % [hash['attributes']] unless hash['attributes'].is_a? Array
35
+ @attributes = []
36
+ hash['attributes'].each do |e|
37
+ @attributes << OnlinePayments::SDK::Domain::AccountOnFileAttribute.new_from_hash(e)
38
+ end
39
+ end
40
+ if hash.key? 'displayHints'
41
+ raise TypeError, "value '%s' is not a Hash" % [hash['displayHints']] unless hash['displayHints'].is_a? Hash
42
+ @display_hints = OnlinePayments::SDK::Domain::AccountOnFileDisplayHints.new_from_hash(hash['displayHints'])
43
+ end
44
+ @id = hash['id'] if hash.key? 'id'
45
+ @payment_product_id = hash['paymentProductId'] if hash.key? 'paymentProductId'
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,38 @@
1
+ #
2
+ # This class was auto-generated.
3
+ #
4
+ require 'onlinepayments/sdk/data_object'
5
+
6
+ module OnlinePayments::SDK
7
+ module Domain
8
+
9
+ # @attr [String] key
10
+ # @attr [String] must_write_reason
11
+ # @attr [String] status
12
+ # @attr [String] value
13
+ class AccountOnFileAttribute < OnlinePayments::SDK::DataObject
14
+ attr_accessor :key
15
+ attr_accessor :must_write_reason
16
+ attr_accessor :status
17
+ attr_accessor :value
18
+
19
+ # @return (Hash)
20
+ def to_h
21
+ hash = super
22
+ hash['key'] = @key unless @key.nil?
23
+ hash['mustWriteReason'] = @must_write_reason unless @must_write_reason.nil?
24
+ hash['status'] = @status unless @status.nil?
25
+ hash['value'] = @value unless @value.nil?
26
+ hash
27
+ end
28
+
29
+ def from_hash(hash)
30
+ super
31
+ @key = hash['key'] if hash.key? 'key'
32
+ @must_write_reason = hash['mustWriteReason'] if hash.key? 'mustWriteReason'
33
+ @status = hash['status'] if hash.key? 'status'
34
+ @value = hash['value'] if hash.key? 'value'
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,37 @@
1
+ #
2
+ # This class was auto-generated.
3
+ #
4
+ require 'onlinepayments/sdk/data_object'
5
+ require 'onlinepayments/sdk/domain/label_template_element'
6
+
7
+ module OnlinePayments::SDK
8
+ module Domain
9
+
10
+ # @attr [Array<OnlinePayments::SDK::Domain::LabelTemplateElement>] label_template
11
+ # @attr [String] logo
12
+ class AccountOnFileDisplayHints < OnlinePayments::SDK::DataObject
13
+ attr_accessor :label_template
14
+ attr_accessor :logo
15
+
16
+ # @return (Hash)
17
+ def to_h
18
+ hash = super
19
+ hash['labelTemplate'] = @label_template.collect(&:to_h) if @label_template
20
+ hash['logo'] = @logo unless @logo.nil?
21
+ hash
22
+ end
23
+
24
+ def from_hash(hash)
25
+ super
26
+ if hash.key? 'labelTemplate'
27
+ raise TypeError, "value '%s' is not an Array" % [hash['labelTemplate']] unless hash['labelTemplate'].is_a? Array
28
+ @label_template = []
29
+ hash['labelTemplate'].each do |e|
30
+ @label_template << OnlinePayments::SDK::Domain::LabelTemplateElement.new_from_hash(e)
31
+ end
32
+ end
33
+ @logo = hash['logo'] if hash.key? 'logo'
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,54 @@
1
+ #
2
+ # This class was auto-generated.
3
+ #
4
+ require 'onlinepayments/sdk/data_object'
5
+ require 'onlinepayments/sdk/domain/airline_data'
6
+ require 'onlinepayments/sdk/domain/loan_recipient'
7
+ require 'onlinepayments/sdk/domain/lodging_data'
8
+ require 'onlinepayments/sdk/domain/order_type_information'
9
+
10
+ module OnlinePayments::SDK
11
+ module Domain
12
+
13
+ # @attr [OnlinePayments::SDK::Domain::AirlineData] airline_data
14
+ # @attr [OnlinePayments::SDK::Domain::LoanRecipient] loan_recipient
15
+ # @attr [OnlinePayments::SDK::Domain::LodgingData] lodging_data
16
+ # @attr [OnlinePayments::SDK::Domain::OrderTypeInformation] type_information
17
+ class AdditionalOrderInput < OnlinePayments::SDK::DataObject
18
+ attr_accessor :airline_data
19
+ attr_accessor :loan_recipient
20
+ attr_accessor :lodging_data
21
+ attr_accessor :type_information
22
+
23
+ # @return (Hash)
24
+ def to_h
25
+ hash = super
26
+ hash['airlineData'] = @airline_data.to_h if @airline_data
27
+ hash['loanRecipient'] = @loan_recipient.to_h if @loan_recipient
28
+ hash['lodgingData'] = @lodging_data.to_h if @lodging_data
29
+ hash['typeInformation'] = @type_information.to_h if @type_information
30
+ hash
31
+ end
32
+
33
+ def from_hash(hash)
34
+ super
35
+ if hash.key? 'airlineData'
36
+ raise TypeError, "value '%s' is not a Hash" % [hash['airlineData']] unless hash['airlineData'].is_a? Hash
37
+ @airline_data = OnlinePayments::SDK::Domain::AirlineData.new_from_hash(hash['airlineData'])
38
+ end
39
+ if hash.key? 'loanRecipient'
40
+ raise TypeError, "value '%s' is not a Hash" % [hash['loanRecipient']] unless hash['loanRecipient'].is_a? Hash
41
+ @loan_recipient = OnlinePayments::SDK::Domain::LoanRecipient.new_from_hash(hash['loanRecipient'])
42
+ end
43
+ if hash.key? 'lodgingData'
44
+ raise TypeError, "value '%s' is not a Hash" % [hash['lodgingData']] unless hash['lodgingData'].is_a? Hash
45
+ @lodging_data = OnlinePayments::SDK::Domain::LodgingData.new_from_hash(hash['lodgingData'])
46
+ end
47
+ if hash.key? 'typeInformation'
48
+ raise TypeError, "value '%s' is not a Hash" % [hash['typeInformation']] unless hash['typeInformation'].is_a? Hash
49
+ @type_information = OnlinePayments::SDK::Domain::OrderTypeInformation.new_from_hash(hash['typeInformation'])
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,50 @@
1
+ #
2
+ # This class was auto-generated.
3
+ #
4
+ require 'onlinepayments/sdk/data_object'
5
+
6
+ module OnlinePayments::SDK
7
+ module Domain
8
+
9
+ # @attr [String] additional_info
10
+ # @attr [String] city
11
+ # @attr [String] country_code
12
+ # @attr [String] house_number
13
+ # @attr [String] state
14
+ # @attr [String] street
15
+ # @attr [String] zip
16
+ class Address < OnlinePayments::SDK::DataObject
17
+ attr_accessor :additional_info
18
+ attr_accessor :city
19
+ attr_accessor :country_code
20
+ attr_accessor :house_number
21
+ attr_accessor :state
22
+ attr_accessor :street
23
+ attr_accessor :zip
24
+
25
+ # @return (Hash)
26
+ def to_h
27
+ hash = super
28
+ hash['additionalInfo'] = @additional_info unless @additional_info.nil?
29
+ hash['city'] = @city unless @city.nil?
30
+ hash['countryCode'] = @country_code unless @country_code.nil?
31
+ hash['houseNumber'] = @house_number unless @house_number.nil?
32
+ hash['state'] = @state unless @state.nil?
33
+ hash['street'] = @street unless @street.nil?
34
+ hash['zip'] = @zip unless @zip.nil?
35
+ hash
36
+ end
37
+
38
+ def from_hash(hash)
39
+ super
40
+ @additional_info = hash['additionalInfo'] if hash.key? 'additionalInfo'
41
+ @city = hash['city'] if hash.key? 'city'
42
+ @country_code = hash['countryCode'] if hash.key? 'countryCode'
43
+ @house_number = hash['houseNumber'] if hash.key? 'houseNumber'
44
+ @state = hash['state'] if hash.key? 'state'
45
+ @street = hash['street'] if hash.key? 'street'
46
+ @zip = hash['zip'] if hash.key? 'zip'
47
+ end
48
+ end
49
+ end
50
+ end