connect-sdk-ruby 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +140 -0
- data/Rakefile +34 -0
- data/connect-sdk-ruby.gemspec +28 -0
- data/examples/merchant/example_configuration.yml +6 -0
- data/examples/merchant/hostedcheckouts/create_hosted_checkout_example.rb +53 -0
- data/examples/merchant/hostedcheckouts/get_hosted_checkout_example.rb +22 -0
- data/examples/merchant/payments/approve_payment_example.rb +42 -0
- data/examples/merchant/payments/cancel_approval_payment_example.rb +22 -0
- data/examples/merchant/payments/cancel_payment_example.rb +22 -0
- data/examples/merchant/payments/create_payment_example.rb +177 -0
- data/examples/merchant/payments/get_payment_example.rb +22 -0
- data/examples/merchant/payments/process_challenged_payment_example.rb +22 -0
- data/examples/merchant/payments/refund_payment_example.rb +85 -0
- data/examples/merchant/payments/tokenize_payment_example.rb +27 -0
- data/examples/merchant/payouts/approve_payout_example.rb +27 -0
- data/examples/merchant/payouts/cancel_approval_payout_example.rb +22 -0
- data/examples/merchant/payouts/cancel_payout_example.rb +22 -0
- data/examples/merchant/payouts/create_payout_example.rb +96 -0
- data/examples/merchant/payouts/get_payout_example.rb +22 -0
- data/examples/merchant/productgroups/get_payment_product_group_example.rb +32 -0
- data/examples/merchant/productgroups/get_payment_product_groups_example.rb +32 -0
- data/examples/merchant/products/get_directory_example.rb +28 -0
- data/examples/merchant/products/get_payment_product_example.rb +32 -0
- data/examples/merchant/products/get_payment_products_example.rb +32 -0
- data/examples/merchant/refunds/approve_refund_example.rb +27 -0
- data/examples/merchant/refunds/cancel_approval_refund_example.rb +22 -0
- data/examples/merchant/refunds/cancel_refund_example.rb +22 -0
- data/examples/merchant/refunds/get_refund_example.rb +22 -0
- data/examples/merchant/riskassessments/risk_assessment_bank_account_example.rb +54 -0
- data/examples/merchant/riskassessments/risk_assessment_cards_example.rb +114 -0
- data/examples/merchant/services/convert_amount_example.rb +29 -0
- data/examples/merchant/services/convert_bank_account_example.rb +34 -0
- data/examples/merchant/services/iin_details_example.rb +27 -0
- data/examples/merchant/services/test_connection_example.rb +22 -0
- data/examples/merchant/sessions/create_session_example.rb +34 -0
- data/examples/merchant/tokens/approve_sepa_direct_debit_token_example.rb +29 -0
- data/examples/merchant/tokens/create_token_example.rb +82 -0
- data/examples/merchant/tokens/delete_token_example.rb +27 -0
- data/examples/merchant/tokens/get_token_example.rb +22 -0
- data/examples/merchant/tokens/update_token_example.rb +76 -0
- data/lib/ingenico/connect/sdk.rb +27 -0
- data/lib/ingenico/connect/sdk/api_exception.rb +52 -0
- data/lib/ingenico/connect/sdk/api_resource.rb +126 -0
- data/lib/ingenico/connect/sdk/authenticator.rb +15 -0
- data/lib/ingenico/connect/sdk/authorization_exception.rb +13 -0
- data/lib/ingenico/connect/sdk/call_context.rb +26 -0
- data/lib/ingenico/connect/sdk/client.rb +92 -0
- data/lib/ingenico/connect/sdk/communication_exception.rb +15 -0
- data/lib/ingenico/connect/sdk/communicator.rb +277 -0
- data/lib/ingenico/connect/sdk/communicator_configuration.rb +98 -0
- data/lib/ingenico/connect/sdk/connection.rb +31 -0
- data/lib/ingenico/connect/sdk/data_object.rb +43 -0
- data/lib/ingenico/connect/sdk/declined_payment_exception.rb +44 -0
- data/lib/ingenico/connect/sdk/declined_payout_exception.rb +44 -0
- data/lib/ingenico/connect/sdk/declined_refund_exception.rb +46 -0
- data/lib/ingenico/connect/sdk/declined_transaction_exception.rb +16 -0
- data/lib/ingenico/connect/sdk/defaultimpl.rb +6 -0
- data/lib/ingenico/connect/sdk/defaultimpl/authorization_type.rb +18 -0
- data/lib/ingenico/connect/sdk/defaultimpl/default_authenticator.rb +106 -0
- data/lib/ingenico/connect/sdk/defaultimpl/default_connection.rb +242 -0
- data/lib/ingenico/connect/sdk/defaultimpl/default_marshaller.rb +35 -0
- data/lib/ingenico/connect/sdk/domain/definitions/abstract_order_status.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/abstract_payment_method_specific_input.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/additional_order_input_airline_data.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/definitions/address.rb +81 -0
- data/lib/ingenico/connect/sdk/domain/definitions/airline_data.rb +165 -0
- data/lib/ingenico/connect/sdk/domain/definitions/airline_flight_leg.rb +102 -0
- data/lib/ingenico/connect/sdk/domain/definitions/amount_of_money.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/definitions/bank_account.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/bank_account_bban.rb +67 -0
- data/lib/ingenico/connect/sdk/domain/definitions/bank_account_iban.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/card.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/card_essentials.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/definitions/card_fraud_results.rb +50 -0
- data/lib/ingenico/connect/sdk/domain/definitions/card_without_cvv.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/definitions/company_information.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/contact_details_base.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/definitions/customer_base.rb +50 -0
- data/lib/ingenico/connect/sdk/domain/definitions/fraud_fields.rb +115 -0
- data/lib/ingenico/connect/sdk/domain/definitions/fraud_results.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/fraud_results_retail_decisions.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/definitions/key_value_pair.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/definitions/order_status_output.rb +67 -0
- data/lib/ingenico/connect/sdk/domain/definitions/payment_product_filter.rb +51 -0
- data/lib/ingenico/connect/sdk/domain/definitions/personal_name_base.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/definitions/result_do_risk_assessment.rb +61 -0
- data/lib/ingenico/connect/sdk/domain/definitions/retail_decisions_cc_fraud_check_output.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/definitions/validation_bank_account_check.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/definitions/validation_bank_account_output.rb +67 -0
- data/lib/ingenico/connect/sdk/domain/errors/api_error.rb +60 -0
- data/lib/ingenico/connect/sdk/domain/errors/error_response.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/create_hosted_checkout_request.rb +102 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/create_hosted_checkout_response.rb +59 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/created_payment_output.rb +72 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/displayed_data.rb +53 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/get_hosted_checkout_response.rb +43 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/hosted_checkout_specific_input.rb +78 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/payment_product_filters_hosted_checkout.rb +53 -0
- data/lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb +48 -0
- data/lib/ingenico/connect/sdk/domain/payment/abstract_payment_method_specific_output.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/additional_order_input.rb +72 -0
- data/lib/ingenico/connect/sdk/domain/payment/address_personal.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/approve_payment_card_payment_method_specific_output.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/approve_payment_non_sepa_direct_debit_payment_method_specific_input.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/approve_payment_payment_method_specific_input.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/approve_payment_request.rb +65 -0
- data/lib/ingenico/connect/sdk/domain/payment/approve_payment_sepa_direct_debit_payment_method_specific_input.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/bank_transfer_payment_method_specific_input.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/bank_transfer_payment_method_specific_input_base.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/bank_transfer_payment_method_specific_output.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/cancel_approval_payment_response.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/cancel_payment_card_payment_method_specific_output.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/cancel_payment_response.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/payment/card_payment_method_specific_input.rb +61 -0
- data/lib/ingenico/connect/sdk/domain/payment/card_payment_method_specific_input_base.rb +60 -0
- data/lib/ingenico/connect/sdk/domain/payment/card_payment_method_specific_output.rb +65 -0
- data/lib/ingenico/connect/sdk/domain/payment/cash_payment_method_specific_input.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/payment/cash_payment_method_specific_input_base.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/cash_payment_method_specific_output.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/cash_payment_product1503_specific_input.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/cash_payment_product1504_specific_input.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/contact_details.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/create_payment_request.rb +131 -0
- data/lib/ingenico/connect/sdk/domain/payment/create_payment_response.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/create_payment_result.rb +58 -0
- data/lib/ingenico/connect/sdk/domain/payment/customer.rb +83 -0
- data/lib/ingenico/connect/sdk/domain/payment/external_cardholder_authentication_data.rb +60 -0
- data/lib/ingenico/connect/sdk/domain/payment/invoice_payment_method_specific_input.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/invoice_payment_method_specific_output.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/level3_summary_data.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/payment/line_item.rb +58 -0
- data/lib/ingenico/connect/sdk/domain/payment/line_item_invoice_data.rb +60 -0
- data/lib/ingenico/connect/sdk/domain/payment/line_item_level3_interchange_information.rb +81 -0
- data/lib/ingenico/connect/sdk/domain/payment/merchant_action.rb +64 -0
- data/lib/ingenico/connect/sdk/domain/payment/non_sepa_direct_debit_payment_method_specific_input.rb +71 -0
- data/lib/ingenico/connect/sdk/domain/payment/non_sepa_direct_debit_payment_method_specific_output.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/non_sepa_direct_debit_payment_product705_specific_input.rb +50 -0
- data/lib/ingenico/connect/sdk/domain/payment/order.rb +83 -0
- data/lib/ingenico/connect/sdk/domain/payment/order_approve_payment.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/payment/order_invoice_data.rb +59 -0
- data/lib/ingenico/connect/sdk/domain/payment/order_output.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/payment/order_references.rb +57 -0
- data/lib/ingenico/connect/sdk/domain/payment/order_references_approve_payment.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/order_type_information.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment.rb +54 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_approval_response.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_creation_output.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_creation_references.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_error_response.rb +57 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_output.rb +116 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_product836_specific_output.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_product840_customer_account.rb +88 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_product840_specific_output.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_references.rb +67 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_response.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_status_output.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/personal_information.rb +50 -0
- data/lib/ingenico/connect/sdk/domain/payment/personal_name.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_data.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_method_specific_input.rb +72 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_method_specific_input_base.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_method_specific_output.rb +58 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_product809_specific_input.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_product816_specific_input.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_product882_specific_input.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_bank_method_specific_output.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_card_method_specific_output.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_e_wallet_method_specific_output.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_method_specific_output.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_output.rb +72 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_payment_product840_customer_account.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_payment_product840_specific_output.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/sepa_direct_debit_payment_method_specific_input.rb +60 -0
- data/lib/ingenico/connect/sdk/domain/payment/sepa_direct_debit_payment_method_specific_output.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/three_d_secure_results.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/payment/tokenize_payment_request.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payout/approve_payout_request.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payout/create_payout_request.rb +101 -0
- data/lib/ingenico/connect/sdk/domain/payout/payout_customer.rb +76 -0
- data/lib/ingenico/connect/sdk/domain/payout/payout_error_response.rb +57 -0
- data/lib/ingenico/connect/sdk/domain/payout/payout_references.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/payout/payout_response.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payout/payout_result.rb +54 -0
- data/lib/ingenico/connect/sdk/domain/product/account_on_file.rb +64 -0
- data/lib/ingenico/connect/sdk/domain/product/account_on_file_attribute.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/account_on_file_display_hints.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/product/directory.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/directory_entry.rb +59 -0
- data/lib/ingenico/connect/sdk/domain/product/empty_validator.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/product/fixed_list_validator.rb +38 -0
- data/lib/ingenico/connect/sdk/domain/product/label_template_element.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/length_validator.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product.rb +134 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_display_hints.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_field.rb +61 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_field_data_restrictions.rb +43 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_field_display_hints.rb +96 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_field_form_element.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_field_tooltip.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_field_validators.rb +100 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_group.rb +71 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_group_response.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_groups.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_response.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_products.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/range_validator.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/regular_expression_validator.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/product/value_mapping_element.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/refund/approve_refund_request.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/refund/bank_account_bban_refund.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/refund/bank_refund_method_specific_input.rb +54 -0
- data/lib/ingenico/connect/sdk/domain/refund/refund_customer.rb +58 -0
- data/lib/ingenico/connect/sdk/domain/refund/refund_error_response.rb +57 -0
- data/lib/ingenico/connect/sdk/domain/refund/refund_references.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/refund/refund_request.rb +76 -0
- data/lib/ingenico/connect/sdk/domain/refund/refund_response.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/refund/refund_result.rb +54 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/customer_risk_assessment.rb +65 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/order_risk_assessment.rb +58 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/personal_information_risk_assessment.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/personal_name_risk_assessment.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/risk_assessment.rb +54 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/risk_assessment_bank_account.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/risk_assessment_card.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/risk_assessment_response.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/services/bank_data.rb +53 -0
- data/lib/ingenico/connect/sdk/domain/services/bank_details.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/services/bank_details_request.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/services/bank_details_response.rb +69 -0
- data/lib/ingenico/connect/sdk/domain/services/convert_amount.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/services/get_iin_details_request.rb +43 -0
- data/lib/ingenico/connect/sdk/domain/services/get_iin_details_response.rb +60 -0
- data/lib/ingenico/connect/sdk/domain/services/iin_detail.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/services/payment_context.rb +50 -0
- data/lib/ingenico/connect/sdk/domain/services/swift.rb +95 -0
- data/lib/ingenico/connect/sdk/domain/services/test_connection.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/sessions/payment_product_filters_client_session.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/sessions/session_request.rb +49 -0
- data/lib/ingenico/connect/sdk/domain/sessions/session_response.rb +59 -0
- data/lib/ingenico/connect/sdk/domain/token/abstract_token.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/token/approve_token_request.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/token/contact_details_token.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/token/create_token_request.rb +76 -0
- data/lib/ingenico/connect/sdk/domain/token/create_token_response.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/token/creditor.rb +102 -0
- data/lib/ingenico/connect/sdk/domain/token/customer_token.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/token/customer_token_with_contact_details.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/token/debtor.rb +102 -0
- data/lib/ingenico/connect/sdk/domain/token/mandate_approval.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/token/mandate_non_sepa_direct_debit.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/token/mandate_sepa_direct_debit.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/token/mandate_sepa_direct_debit_with_mandate_id.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/token/mandate_sepa_direct_debit_without_creditor.rb +79 -0
- data/lib/ingenico/connect/sdk/domain/token/personal_information_token.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/token/personal_name_token.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/token/token_card.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/token/token_card_data.rb +50 -0
- data/lib/ingenico/connect/sdk/domain/token/token_e_wallet.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/token/token_e_wallet_data.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/token/token_non_sepa_direct_debit.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/token/token_non_sepa_direct_debit_payment_product705_specific_data.rb +43 -0
- data/lib/ingenico/connect/sdk/domain/token/token_response.rb +83 -0
- data/lib/ingenico/connect/sdk/domain/token/token_sepa_direct_debit.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/token/token_sepa_direct_debit_without_creditor.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/token/update_token_request.rb +76 -0
- data/lib/ingenico/connect/sdk/endpoint_configuration.rb +139 -0
- data/lib/ingenico/connect/sdk/exceptions.rb +8 -0
- data/lib/ingenico/connect/sdk/factory.rb +200 -0
- data/lib/ingenico/connect/sdk/global_collect_exception.rb +15 -0
- data/lib/ingenico/connect/sdk/idempotence_exception.rb +24 -0
- data/lib/ingenico/connect/sdk/logging.rb +10 -0
- data/lib/ingenico/connect/sdk/logging/communicator_logger.rb +19 -0
- data/lib/ingenico/connect/sdk/logging/log_message_builder.rb +61 -0
- data/lib/ingenico/connect/sdk/logging/logging_capable.rb +19 -0
- data/lib/ingenico/connect/sdk/logging/logging_util.rb +298 -0
- data/lib/ingenico/connect/sdk/logging/request_log_message_builder.rb +42 -0
- data/lib/ingenico/connect/sdk/logging/response_log_message_builder.rb +34 -0
- data/lib/ingenico/connect/sdk/logging/ruby_communicator_logger.rb +58 -0
- data/lib/ingenico/connect/sdk/logging/stdout_communicator_logger.rb +36 -0
- data/lib/ingenico/connect/sdk/marshaller.rb +19 -0
- data/lib/ingenico/connect/sdk/marshaller_syntax_exception.rb +6 -0
- data/lib/ingenico/connect/sdk/merchant/hostedcheckouts/hostedcheckouts_client.rb +88 -0
- data/lib/ingenico/connect/sdk/merchant/merchant_client.rb +110 -0
- data/lib/ingenico/connect/sdk/merchant/payments/payments_client.rb +319 -0
- data/lib/ingenico/connect/sdk/merchant/payouts/payouts_client.rb +197 -0
- data/lib/ingenico/connect/sdk/merchant/productgroups/find_productgroups_params.rb +55 -0
- data/lib/ingenico/connect/sdk/merchant/productgroups/get_productgroup_params.rb +55 -0
- data/lib/ingenico/connect/sdk/merchant/productgroups/productgroups_client.rb +90 -0
- data/lib/ingenico/connect/sdk/merchant/products/directory_params.rb +31 -0
- data/lib/ingenico/connect/sdk/merchant/products/find_products_params.rb +55 -0
- data/lib/ingenico/connect/sdk/merchant/products/get_product_params.rb +55 -0
- data/lib/ingenico/connect/sdk/merchant/products/products_client.rb +124 -0
- data/lib/ingenico/connect/sdk/merchant/refunds/refunds_client.rb +154 -0
- data/lib/ingenico/connect/sdk/merchant/riskassessments/riskassessments_client.rb +85 -0
- data/lib/ingenico/connect/sdk/merchant/services/convert_amount_params.rb +35 -0
- data/lib/ingenico/connect/sdk/merchant/services/services_client.rb +149 -0
- data/lib/ingenico/connect/sdk/merchant/sessions/sessions_client.rb +55 -0
- data/lib/ingenico/connect/sdk/merchant/tokens/delete_token_params.rb +27 -0
- data/lib/ingenico/connect/sdk/merchant/tokens/tokens_client.rb +192 -0
- data/lib/ingenico/connect/sdk/meta_data_provider.rb +152 -0
- data/lib/ingenico/connect/sdk/modules.rb +130 -0
- data/lib/ingenico/connect/sdk/not_found_exception.rb +19 -0
- data/lib/ingenico/connect/sdk/param_request.rb +33 -0
- data/lib/ingenico/connect/sdk/pooled_connection.rb +21 -0
- data/lib/ingenico/connect/sdk/proxy_configuration.rb +75 -0
- data/lib/ingenico/connect/sdk/reference_exception.rb +14 -0
- data/lib/ingenico/connect/sdk/request_header.rb +25 -0
- data/lib/ingenico/connect/sdk/request_param.rb +24 -0
- data/lib/ingenico/connect/sdk/response.rb +62 -0
- data/lib/ingenico/connect/sdk/response_exception.rb +54 -0
- data/lib/ingenico/connect/sdk/response_header.rb +25 -0
- data/lib/ingenico/connect/sdk/session.rb +39 -0
- data/lib/ingenico/connect/sdk/validation_exception.rb +14 -0
- data/spec/comparable_extension.rb +29 -0
- data/spec/fixtures/resources/defaultimpl/convertAmount.json +3 -0
- data/spec/fixtures/resources/defaultimpl/createPayment.failure.invalidCardNumber.json +11 -0
- data/spec/fixtures/resources/defaultimpl/createPayment.failure.rejected.json +48 -0
- data/spec/fixtures/resources/defaultimpl/createPayment.json +40 -0
- data/spec/fixtures/resources/defaultimpl/idempotence_duplicate_failure.json +8 -0
- data/spec/fixtures/resources/defaultimpl/idempotence_rejected.json +46 -0
- data/spec/fixtures/resources/defaultimpl/idempotence_success.json +39 -0
- data/spec/fixtures/resources/defaultimpl/notFound.html +1 -0
- data/spec/fixtures/resources/defaultimpl/testConnection.json +3 -0
- data/spec/fixtures/resources/defaultimpl/unknownServerError.json +10 -0
- data/spec/fixtures/resources/logging/bodyNoObfuscation.json +17 -0
- data/spec/fixtures/resources/logging/bodyWithBinObfuscated.json +3 -0
- data/spec/fixtures/resources/logging/bodyWithBinOriginal.json +3 -0
- data/spec/fixtures/resources/logging/bodyWithCardObfuscated.json +21 -0
- data/spec/fixtures/resources/logging/bodyWithCardOriginal.json +21 -0
- data/spec/fixtures/resources/logging/bodyWithIbanObfuscated.json +19 -0
- data/spec/fixtures/resources/logging/bodyWithIbanOriginal.json +19 -0
- data/spec/fixtures/resources/payment/duplicate_request.json +8 -0
- data/spec/fixtures/resources/payment/invalid_authorization.json +9 -0
- data/spec/fixtures/resources/payment/invalid_request.json +11 -0
- data/spec/fixtures/resources/payment/method_not_allowed.html +1 -0
- data/spec/fixtures/resources/payment/not_found.html +1 -0
- data/spec/fixtures/resources/payment/pending_approval.json +39 -0
- data/spec/fixtures/resources/payment/rejected.json +46 -0
- data/spec/fixtures/resources/properties.proxy.yml +13 -0
- data/spec/fixtures/resources/properties.yml +7 -0
- data/spec/integration/connection_pooling_spec.rb +78 -0
- data/spec/integration/convert_amount_spec.rb +25 -0
- data/spec/integration/idempotence_spec.rb +59 -0
- data/spec/integration/multiline_header_spec.rb +30 -0
- data/spec/integration/payment_product_groups_spec.rb +23 -0
- data/spec/integration/payment_products_spec.rb +22 -0
- data/spec/integration/risk_assessments_spec.rb +37 -0
- data/spec/integration/sdk_proxy_spec.rb +89 -0
- data/spec/integration/token_spec.rb +42 -0
- data/spec/integration_setup.rb +50 -0
- data/spec/lib/client_spec.rb +69 -0
- data/spec/lib/communicator_configuration_spec.rb +179 -0
- data/spec/lib/communicator_spec.rb +31 -0
- data/spec/lib/defaultimpl/default_authenticator_spec.rb +74 -0
- data/spec/lib/defaultimpl/default_connection_idempotence_spec.rb +142 -0
- data/spec/lib/defaultimpl/default_connection_logger_spec.rb +526 -0
- data/spec/lib/defaultimpl/default_connection_spec.rb +334 -0
- data/spec/lib/defaultimpl/default_marshaller_spec.rb +36 -0
- data/spec/lib/factory_spec.rb +41 -0
- data/spec/lib/logging/header_obfuscator_spec.rb +51 -0
- data/spec/lib/logging/logging_util_spec.rb +143 -0
- data/spec/lib/logging/obfuscator_spec.rb +52 -0
- data/spec/lib/logging/ruby_communicator_logger_spec.rb +84 -0
- data/spec/lib/logging/stdout_communicator_logger_spec.rb +64 -0
- data/spec/lib/logging/value_obfuscator_spec.rb +95 -0
- data/spec/lib/meta_data_provider_spec.rb +71 -0
- data/spec/lib/payments_client_spec.rb +157 -0
- data/spec/lib/requestparams/delete_params_spec.rb +21 -0
- data/spec/lib/requestparams/directory_params_spec.rb +27 -0
- data/spec/lib/requestparams/find_params_spec.rb +58 -0
- data/spec/lib/requestparams/get_params_spec.rb +59 -0
- data/spec/lib/requestparams/param_request_spec.rb +57 -0
- data/spec/spec_helper.rb +23 -0
- metadata +565 -0
@@ -0,0 +1,130 @@
|
|
1
|
+
# Main module of this SDK. All non-data classes that are used at multiple places in the SDK are placed in this module.
|
2
|
+
module Ingenico::Connect::SDK
|
3
|
+
end
|
4
|
+
|
5
|
+
# Contains provided implementations for abstract functionality in this SDK.
|
6
|
+
# These implementations can be replaced or adapted if desired to suit specific needs.
|
7
|
+
module Ingenico::Connect::SDK::DefaultImpl
|
8
|
+
end
|
9
|
+
|
10
|
+
# Contains all logging-related classes.
|
11
|
+
module Ingenico::Connect::SDK::Logging
|
12
|
+
end
|
13
|
+
|
14
|
+
# Contains interfaces to all GlobalCollect services. These services are accessed through a *Ingenico::Connect::SDK::Client* instance.
|
15
|
+
module Ingenico::Connect::SDK::Merchant
|
16
|
+
end
|
17
|
+
|
18
|
+
# Container for all data-containing modules.
|
19
|
+
# The data-classes contained within can be serialized and communicated with the GlobalCollect platform.
|
20
|
+
# These classes generally contain financially relevant data used in processing requests or responses.
|
21
|
+
module Ingenico::Connect::SDK::Domain
|
22
|
+
end
|
23
|
+
|
24
|
+
# Contains the client used to access the HostedCheckouts service.
|
25
|
+
# @see https://developer.globalcollect.com/documentation/api/server/#hostedcheckouts
|
26
|
+
module Ingenico::Connect::SDK::Merchant::Hostedcheckouts
|
27
|
+
end
|
28
|
+
|
29
|
+
# Contains data classes that are used in the HostedCheckouts service.
|
30
|
+
# @see https://developer.globalcollect.com/documentation/api/server/#hostedcheckouts
|
31
|
+
module Ingenico::Connect::SDK::Domain::Hostedcheckout
|
32
|
+
end
|
33
|
+
|
34
|
+
# Contains the client used to access the payment service.
|
35
|
+
# @see https://developer.globalcollect.com/documentation/api/server/#payments
|
36
|
+
module Ingenico::Connect::SDK::Merchant::Payments
|
37
|
+
end
|
38
|
+
|
39
|
+
# Contains data classes that are used in payment services.
|
40
|
+
# @see https://developer.globalcollect.com/documentation/api/server/#payments
|
41
|
+
module Ingenico::Connect::SDK::Domain::Payment
|
42
|
+
end
|
43
|
+
|
44
|
+
# Contains the client used to access the payout service.
|
45
|
+
# @see https://developer.globalcollect.com/documentation/api/server/#payouts
|
46
|
+
module Ingenico::Connect::SDK::Merchant::Payouts
|
47
|
+
end
|
48
|
+
|
49
|
+
# Contains data classes that are used in payout services.
|
50
|
+
# @see https://developer.globalcollect.com/documentation/api/server/#payouts
|
51
|
+
module Ingenico::Connect::SDK::Domain::Payout
|
52
|
+
end
|
53
|
+
|
54
|
+
# Contains the client used to access the product groups service.
|
55
|
+
# @see https://developer.globalcollect.com/documentation/api/server/#productgroups
|
56
|
+
module Ingenico::Connect::SDK::Merchant::Productgroups
|
57
|
+
end
|
58
|
+
|
59
|
+
# Contains the client used to access the products service.
|
60
|
+
# @see https://developer.globalcollect.com/documentation/api/server/#products
|
61
|
+
module Ingenico::Connect::SDK::Merchant::Products
|
62
|
+
end
|
63
|
+
|
64
|
+
# Contains data classes that are used in payment product and payment product group services.
|
65
|
+
# @see https://developer.globalcollect.com/documentation/api/server/#products
|
66
|
+
module Ingenico::Connect::SDK::Domain::Product
|
67
|
+
end
|
68
|
+
|
69
|
+
# Contains the client used to access the refunds service
|
70
|
+
# @see https://developer.globalcollect.com/documentation/api/server/#refunds
|
71
|
+
module Ingenico::Connect::SDK::Merchant::Refunds
|
72
|
+
end
|
73
|
+
|
74
|
+
# Contains data classes that are used in refund requests.
|
75
|
+
# @see https://developer.globalcollect.com/documentation/api/server/#refunds
|
76
|
+
module Ingenico::Connect::SDK::Domain::Refund
|
77
|
+
end
|
78
|
+
|
79
|
+
# Contains the client used to access the riskassessments service.
|
80
|
+
# @see https://developer.globalcollect.com/documentation/api/server/#riskassessments
|
81
|
+
module Ingenico::Connect::SDK::Merchant::Riskassessments
|
82
|
+
end
|
83
|
+
|
84
|
+
# Contains data classes that are used in riskassessment services.
|
85
|
+
# @see https://developer.globalcollect.com/documentation/api/server/#riskassessments
|
86
|
+
module Ingenico::Connect::SDK::Domain::Riskassessments
|
87
|
+
end
|
88
|
+
|
89
|
+
# Contains the client to access miscellaneous services.
|
90
|
+
# @see https://developer.globalcollect.com/documentation/api/server/#services
|
91
|
+
module Ingenico::Connect::SDK::Merchant::Services
|
92
|
+
end
|
93
|
+
|
94
|
+
# Contains data classes that are used in miscellaneous services.
|
95
|
+
# @see https://developer.globalcollect.com/documentation/api/server/#services
|
96
|
+
module Ingenico::Connect::SDK::Domain::Services
|
97
|
+
end
|
98
|
+
|
99
|
+
# Contains the client used to access the sessions service.
|
100
|
+
# @see https://developer.globalcollect.com/documentation/api/server/#sessions
|
101
|
+
module Ingenico::Connect::SDK::Merchant::Sessions
|
102
|
+
end
|
103
|
+
|
104
|
+
# Contains data classes that are used in initiating Sessions.
|
105
|
+
# @see https://developer.globalcollect.com/documentation/api/server/#sessions
|
106
|
+
module Ingenico::Connect::SDK::Domain::Sessions
|
107
|
+
end
|
108
|
+
|
109
|
+
# Contains the client used to access the tokens service.
|
110
|
+
# @see https://developer.globalcollect.com/documentation/api/server/#tokens
|
111
|
+
module Ingenico::Connect::SDK::Merchant::Tokens
|
112
|
+
end
|
113
|
+
|
114
|
+
# Contains data classes that are used in the tokenization service.
|
115
|
+
# @see https://developer.globalcollect.com/documentation/api/server/#tokens
|
116
|
+
module Ingenico::Connect::SDK::Domain::Token
|
117
|
+
end
|
118
|
+
|
119
|
+
# Contains the general data classes that are used in multiple different types of requests.
|
120
|
+
# These classes can be serialized and used in communication with the GlobalCollect platform.
|
121
|
+
module Ingenico::Connect::SDK::Domain::Definitions
|
122
|
+
end
|
123
|
+
|
124
|
+
# Contains classes that represent error responses from the GlobalCollect platform.
|
125
|
+
module Ingenico::Connect::SDK::Domain::Errors
|
126
|
+
end
|
127
|
+
|
128
|
+
# Contains data classes related to shopping cart functionality.
|
129
|
+
module Ingenico::Connect::SDK::Domain::MetaData
|
130
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Ingenico::Connect::SDK
|
2
|
+
|
3
|
+
# Raised when a resource is not found on the GlobalCollect platform.
|
4
|
+
# This error corresponds to a 404 HTTP response.
|
5
|
+
class NotFoundException < RuntimeError
|
6
|
+
|
7
|
+
def initialize(cause, message=FALSE)
|
8
|
+
if message
|
9
|
+
super(message)
|
10
|
+
else
|
11
|
+
super
|
12
|
+
end
|
13
|
+
@cause = cause
|
14
|
+
end
|
15
|
+
|
16
|
+
# The error that is the cause of this error.
|
17
|
+
attr_accessor :cause
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Ingenico::Connect::SDK
|
2
|
+
|
3
|
+
# Class that represents the URL request parameters.
|
4
|
+
# Contains a method to add a name and value pair to a parameter array as a {Ingenico::Connect::SDK::RequestParam}.
|
5
|
+
class ParamRequest
|
6
|
+
|
7
|
+
protected
|
8
|
+
|
9
|
+
# Adds a {Ingenico::Connect::SDK::RequestParam} object to the _request_parameters_ array
|
10
|
+
# where RequestParam.name = name and RequestParam.value = value.
|
11
|
+
# Allows Strings, Integers, booleans and arrays of these to be converted to RequestParams.
|
12
|
+
# If _value_ is an array, one RequestParam instance will be added for each element in the array.
|
13
|
+
# An array containing another array is explicitly disallowed and will raise an error.
|
14
|
+
def add_parameter(request_parameters, name, value)
|
15
|
+
add_param(request_parameters, name, value)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def add_param(request_parameters, name, value, allow_collection = TRUE)
|
21
|
+
if value.is_a?(String) || value.is_a?(Integer) || value.class == TrueClass ||
|
22
|
+
value.class == FalseClass
|
23
|
+
request_parameters.push(RequestParam.new(name, value.to_s))
|
24
|
+
elsif allow_collection && value.class == Array
|
25
|
+
value.each { |element|
|
26
|
+
add_param(request_parameters, name, element, FALSE)
|
27
|
+
}
|
28
|
+
elsif !value.nil?
|
29
|
+
raise ArgumentError.new("Unsupported request parameter type: #{value.class}")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Ingenico::Connect::SDK
|
2
|
+
|
3
|
+
# {Ingenico::Connect::SDK::Connection} that supports connection pooling. This is used to more efficiently communicate using HTTP.
|
4
|
+
# Connection pooling means that a number of connections are kept alive after use so they can possibly be reused.
|
5
|
+
# If the Connection does not do so automatically,
|
6
|
+
# the methods _close_idle_connections_ and _close_expired_connections_ can be used to drop connections
|
7
|
+
# that are idle for a specified amount of time or that have expired.
|
8
|
+
# @see Ingenico::Connect::SDK::DefaultImpl::DefaultConnection
|
9
|
+
class PooledConnection < Connection
|
10
|
+
|
11
|
+
# Closes all connections that have not been used for _idle_time_ seconds.
|
12
|
+
def close_idle_connections(idle_time)
|
13
|
+
raise NotImplementedError
|
14
|
+
end
|
15
|
+
|
16
|
+
# Closes all connections that have expired.
|
17
|
+
def close_expired_connections
|
18
|
+
raise NotImplementedError
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module Ingenico::Connect::SDK
|
2
|
+
|
3
|
+
# Contains the url, username and password of a proxy.
|
4
|
+
class ProxyConfiguration
|
5
|
+
|
6
|
+
# Initialize a new ProxyConfiguration from the parameter hash.
|
7
|
+
# In order to be complete either host, port and scheme, or an address is required.
|
8
|
+
# Arguments read from the hash are:
|
9
|
+
# host:: Host part of the url to the proxy.
|
10
|
+
# port:: Port the proxy will be accessed through.
|
11
|
+
# scheme:: HTTP scheme used to communicate with the proxy (HTTP or HTTPS).
|
12
|
+
# address:: Full uri to the proxy excluding username and password.
|
13
|
+
# If given this uri takes precedence over individual host, port and scheme.
|
14
|
+
# username:: Username used in authentication to the proxy.
|
15
|
+
# password:: Password used to authenticate to the proxy.
|
16
|
+
def initialize(args)
|
17
|
+
|
18
|
+
host = args[:host]
|
19
|
+
port = args[:port]
|
20
|
+
username = args[:username]
|
21
|
+
password = args[:password]
|
22
|
+
scheme = args[:scheme] || 'http'
|
23
|
+
|
24
|
+
# Don't switch the order, a given address overrides host, port and username
|
25
|
+
address = args[:address]
|
26
|
+
host = address.host if address
|
27
|
+
port = address.port if address
|
28
|
+
scheme = address.scheme if address
|
29
|
+
|
30
|
+
raise ArgumentError.new('scheme is required') unless scheme and not scheme.strip.empty?
|
31
|
+
raise ArgumentError.new('host is required') unless host and not host.strip.empty?
|
32
|
+
raise ArgumentError.new('port is required') unless port and port > 0 and port <= 65535
|
33
|
+
|
34
|
+
@host = host
|
35
|
+
@port = port
|
36
|
+
@username = username
|
37
|
+
@password = password
|
38
|
+
@scheme = scheme
|
39
|
+
end
|
40
|
+
|
41
|
+
# proxy scheme (http or https)
|
42
|
+
attr_accessor :scheme
|
43
|
+
|
44
|
+
# proxy hostname
|
45
|
+
attr_accessor :host
|
46
|
+
|
47
|
+
# proxy port
|
48
|
+
attr_accessor :port
|
49
|
+
|
50
|
+
# proxy authentication username
|
51
|
+
attr_accessor :username
|
52
|
+
|
53
|
+
# proxy authentication password
|
54
|
+
attr_accessor :password
|
55
|
+
|
56
|
+
# Returns a url string representation of the proxy, excluding authentication.
|
57
|
+
def proxy_uri
|
58
|
+
"#{scheme}://#{host}:#{port}"
|
59
|
+
end
|
60
|
+
|
61
|
+
def to_s
|
62
|
+
proxy_uri
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def self.get_port(address)
|
68
|
+
port = address.port
|
69
|
+
return port if port != -1
|
70
|
+
return 80 if address.scheme.casecmp('http') == 0
|
71
|
+
return 443 if address.scheme.casecmp('https') == 0
|
72
|
+
raise ArgumentError.new('unsupported scheme: ' + address.scheme)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ingenico::Connect::SDK
|
2
|
+
|
3
|
+
# This error is raised when the request refers to a resource or object that is not found by the GlobalCollect platform.
|
4
|
+
# The object referred to may not exist or it could have been removed recently.
|
5
|
+
class ReferenceException < ApiException
|
6
|
+
|
7
|
+
# Create a new ReferenceException.
|
8
|
+
# @see ApiException#initialize
|
9
|
+
def initialize(status_code, response_body, error_id, errors,
|
10
|
+
message='the GlobalCollect platform returned a reference error response')
|
11
|
+
super(status_code, response_body, error_id, errors, message)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Ingenico::Connect::SDK
|
2
|
+
|
3
|
+
# Represents HTTP request headers
|
4
|
+
# Each header is immutable has a #name and #value attribute
|
5
|
+
class RequestHeader
|
6
|
+
|
7
|
+
# Create a new header using the name and value given as parameters.
|
8
|
+
def initialize(name, value)
|
9
|
+
if name.nil? || name.strip.empty?
|
10
|
+
raise ArgumentError.new('name is required')
|
11
|
+
end
|
12
|
+
@name = name
|
13
|
+
@value = value
|
14
|
+
end
|
15
|
+
|
16
|
+
# HTTP header name
|
17
|
+
attr_reader :name
|
18
|
+
# HTTP header value
|
19
|
+
attr_reader :value
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
name + ':' + value
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Ingenico::Connect::SDK
|
2
|
+
|
3
|
+
# Represents a URL request parameter.
|
4
|
+
# Each parameter is immutable and has a #name and #value attribute.
|
5
|
+
class RequestParam
|
6
|
+
|
7
|
+
def initialize(name, value)
|
8
|
+
if name.nil? || name.strip.empty?
|
9
|
+
raise ArgumentError.new('name is required')
|
10
|
+
end
|
11
|
+
@name = name
|
12
|
+
@value = value
|
13
|
+
end
|
14
|
+
|
15
|
+
# parameter name
|
16
|
+
attr_reader :name
|
17
|
+
# parameter value
|
18
|
+
attr_reader :value
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
name + '=' + value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Ingenico::Connect::SDK
|
2
|
+
|
3
|
+
# Base class for HTTP responses. It provides access to the response headers, status code and response message body
|
4
|
+
class Response
|
5
|
+
|
6
|
+
# Create a new response object that stores the following:
|
7
|
+
# status_code:: HTTP status code
|
8
|
+
# body:: response message body, given as a string
|
9
|
+
# headers:: response headers as a {Ingenico::Connect::SDK::ResponseHeader} list
|
10
|
+
def initialize(status_code, body, headers)
|
11
|
+
@status_code = status_code
|
12
|
+
@body = body
|
13
|
+
if headers.nil?
|
14
|
+
@headers = [].freeze
|
15
|
+
else
|
16
|
+
@headers = headers.dup.freeze
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# HTTP status code
|
21
|
+
attr_reader :status_code
|
22
|
+
# Response message body
|
23
|
+
attr_reader :body
|
24
|
+
# Response headers as a {Ingenico::Connect::SDK::ResponseHeader} list
|
25
|
+
attr_reader :headers
|
26
|
+
|
27
|
+
# Returns the {Ingenico::Connect::SDK::ResponseHeader} that goes by the given _header_name_,
|
28
|
+
# or _nil_ if this Response does not contain a header with the given name.
|
29
|
+
def get_header(header_name)
|
30
|
+
@headers.each { |header|
|
31
|
+
if header.name.casecmp(header_name) == 0
|
32
|
+
return header
|
33
|
+
end
|
34
|
+
}
|
35
|
+
return nil
|
36
|
+
end
|
37
|
+
|
38
|
+
# Returns the header value of the header that goes by the given _header_name_,
|
39
|
+
# or _nil_ if this Response does not contain a header with the given name.
|
40
|
+
def get_header_value(header_name)
|
41
|
+
header = get_header(header_name)
|
42
|
+
if !header.nil?
|
43
|
+
header.value
|
44
|
+
else
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_s
|
50
|
+
str = self.class.name
|
51
|
+
str += '[status_code=' + @status_code.to_s
|
52
|
+
if !@body.nil? && @body.length > 0
|
53
|
+
str += ",body='" + @body + "'"
|
54
|
+
end
|
55
|
+
unless @headers.empty? || @headers.nil?
|
56
|
+
str += ',headers=' + @headers.to_s
|
57
|
+
end
|
58
|
+
str += ']'
|
59
|
+
str.to_s
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Ingenico::Connect::SDK
|
2
|
+
|
3
|
+
# Exception used internally in the SDK to indicate an error response was received from the GlobalCollect platform.
|
4
|
+
class ResponseException < RuntimeError
|
5
|
+
|
6
|
+
def initialize(response)
|
7
|
+
super('the GlobalCollect platform returned an error response')
|
8
|
+
@response = response
|
9
|
+
end
|
10
|
+
|
11
|
+
# {Ingenico::Connect::SDK::Response} object that was returned by the GlobalCollect platform
|
12
|
+
attr_reader :response
|
13
|
+
|
14
|
+
# HTTP status code that was returned by the GlobalCollect platform
|
15
|
+
def status_code
|
16
|
+
@response.status_code
|
17
|
+
end
|
18
|
+
|
19
|
+
# string HTTP message body that was returned by the GlobalCollect platform
|
20
|
+
def body
|
21
|
+
@response.body
|
22
|
+
end
|
23
|
+
|
24
|
+
# List of {Ingenico::Connect::SDK::ResponseHeader} that represent the HTTP headers used in the response from the GlobalCollect platform
|
25
|
+
def headers
|
26
|
+
@response.headers
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns the {Ingenico::Connect::SDK::ResponseHeader} that corresponds to the given _header_name_
|
30
|
+
# used in the HTTP response from the GlobalCollect platform, or *nil* if the header was not present in the response.
|
31
|
+
def get_header(header_name)
|
32
|
+
@response.get_header(header_name)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Returns the header value received that corresponds to the header named by _header_name_,
|
36
|
+
# or *nil* if _header_name_ was not a header present in the HTTP response.
|
37
|
+
def get_header_value(header_name)
|
38
|
+
@response.get_header_value(header_name)
|
39
|
+
end
|
40
|
+
|
41
|
+
def to_s
|
42
|
+
str = super.to_s
|
43
|
+
status_code = @response.status_code
|
44
|
+
if status_code > 0
|
45
|
+
str += '; status_code=' + status_code.to_s
|
46
|
+
end
|
47
|
+
response_body = @response.body
|
48
|
+
if !response_body.nil? && response_body.length > 0
|
49
|
+
str += "; response_body='" + response_body + "'"
|
50
|
+
end
|
51
|
+
str.to_s
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|