onlinepayments-sdk-ruby 4.23.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +5 -6
- data/Rakefile +0 -0
- data/lib/onlinepayments/sdk/api_exception.rb +47 -35
- data/lib/onlinepayments/sdk/api_resource.rb +49 -97
- data/lib/onlinepayments/sdk/authentication/authenticator.rb +19 -0
- data/lib/onlinepayments/sdk/authentication/authorization_type.rb +15 -0
- data/lib/onlinepayments/sdk/authentication/v1hmac_authenticator.rb +109 -0
- data/lib/onlinepayments/sdk/authentication.rb +1 -0
- data/lib/onlinepayments/sdk/authorization_exception.rb +14 -8
- data/lib/onlinepayments/sdk/call_context.rb +30 -21
- data/lib/onlinepayments/sdk/client.rb +36 -18
- data/lib/onlinepayments/sdk/communication/communication_exception.rb +19 -0
- data/lib/onlinepayments/sdk/communication/connection.rb +48 -0
- data/lib/onlinepayments/sdk/communication/default_connection.rb +427 -0
- data/lib/onlinepayments/sdk/communication/metadata_provider.rb +160 -0
- data/lib/onlinepayments/sdk/communication/multipart_form_data_object.rb +52 -0
- data/lib/onlinepayments/sdk/communication/multipart_form_data_request.rb +13 -0
- data/lib/onlinepayments/sdk/communication/not_found_exception.rb +19 -0
- data/lib/onlinepayments/sdk/communication/param_request.rb +14 -0
- data/lib/onlinepayments/sdk/communication/pooled_connection.rb +26 -0
- data/lib/onlinepayments/sdk/communication/request_header.rb +62 -0
- data/lib/onlinepayments/sdk/communication/request_param.rb +28 -0
- data/lib/onlinepayments/sdk/communication/response_exception.rb +56 -0
- data/lib/onlinepayments/sdk/communication/response_header.rb +78 -0
- data/lib/onlinepayments/sdk/communication.rb +1 -0
- data/lib/onlinepayments/sdk/communicator.rb +475 -268
- data/lib/onlinepayments/sdk/communicator_configuration.rb +162 -53
- data/lib/onlinepayments/sdk/declined_payment_exception.rb +28 -21
- data/lib/onlinepayments/sdk/declined_payout_exception.rb +28 -23
- data/lib/onlinepayments/sdk/declined_refund_exception.rb +28 -23
- data/lib/onlinepayments/sdk/declined_transaction_exception.rb +16 -10
- data/lib/onlinepayments/sdk/domain/account_on_file.rb +44 -35
- data/lib/onlinepayments/sdk/domain/account_on_file_attribute.rb +42 -28
- data/lib/onlinepayments/sdk/domain/account_on_file_display_hints.rb +29 -24
- data/lib/onlinepayments/sdk/domain/acquirer_information.rb +27 -22
- data/lib/onlinepayments/sdk/domain/acquirer_selection_information.rb +34 -24
- data/lib/onlinepayments/sdk/domain/additional_order_input.rb +43 -38
- data/lib/onlinepayments/sdk/domain/address.rb +65 -43
- data/lib/onlinepayments/sdk/domain/address_personal.rb +78 -52
- data/lib/onlinepayments/sdk/domain/airline_data.rb +204 -123
- data/lib/onlinepayments/sdk/domain/airline_flight_leg.rb +158 -95
- data/lib/onlinepayments/sdk/domain/airline_passenger.rb +59 -39
- data/lib/onlinepayments/sdk/domain/amount_breakdown.rb +27 -20
- data/lib/onlinepayments/sdk/domain/amount_of_money.rb +27 -20
- data/lib/onlinepayments/sdk/domain/api_error.rb +73 -47
- data/lib/onlinepayments/sdk/domain/apple_pay_line_item.rb +72 -0
- data/lib/onlinepayments/sdk/domain/apple_pay_recurring_payment_request.rb +61 -0
- data/lib/onlinepayments/sdk/domain/bank_account_iban.rb +20 -16
- data/lib/onlinepayments/sdk/domain/browser_data.rb +51 -35
- data/lib/onlinepayments/sdk/domain/calculate_surcharge_request.rb +27 -24
- data/lib/onlinepayments/sdk/domain/calculate_surcharge_response.rb +22 -20
- data/lib/onlinepayments/sdk/domain/cancel_payment_request.rb +27 -22
- data/lib/onlinepayments/sdk/domain/cancel_payment_response.rb +20 -18
- data/lib/onlinepayments/sdk/domain/capture.rb +41 -32
- data/lib/onlinepayments/sdk/domain/capture_output.rb +106 -78
- data/lib/onlinepayments/sdk/domain/capture_payment_request.rb +43 -26
- data/lib/onlinepayments/sdk/domain/capture_response.rb +41 -32
- data/lib/onlinepayments/sdk/domain/capture_status_output.rb +20 -16
- data/lib/onlinepayments/sdk/domain/captures_response.rb +22 -20
- data/lib/onlinepayments/sdk/domain/card.rb +41 -28
- data/lib/onlinepayments/sdk/domain/card_essentials.rb +41 -28
- data/lib/onlinepayments/sdk/domain/card_fraud_results.rb +34 -24
- data/lib/onlinepayments/sdk/domain/card_info.rb +27 -20
- data/lib/onlinepayments/sdk/domain/card_payment_method_specific_input.rb +199 -128
- data/lib/onlinepayments/sdk/domain/card_payment_method_specific_input_base.rb +149 -104
- data/lib/onlinepayments/sdk/domain/card_payment_method_specific_input_for_hosted_checkout.rb +36 -28
- data/lib/onlinepayments/sdk/domain/card_payment_method_specific_output.rb +133 -100
- data/lib/onlinepayments/sdk/domain/card_payout_method_specific_input.rb +41 -30
- data/lib/onlinepayments/sdk/domain/card_recurrence_details.rb +20 -16
- data/lib/onlinepayments/sdk/domain/card_source.rb +41 -30
- data/lib/onlinepayments/sdk/domain/card_without_cvv.rb +34 -24
- data/lib/onlinepayments/sdk/domain/company_information.rb +20 -16
- data/lib/onlinepayments/sdk/domain/complete_payment_card_payment_method_specific_input.rb +20 -18
- data/lib/onlinepayments/sdk/domain/complete_payment_request.rb +27 -24
- data/lib/onlinepayments/sdk/domain/complete_payment_response.rb +35 -31
- data/lib/onlinepayments/sdk/domain/contact_details.rb +51 -35
- data/lib/onlinepayments/sdk/domain/create_hosted_checkout_request.rb +76 -59
- data/lib/onlinepayments/sdk/domain/create_hosted_checkout_response.rb +60 -43
- data/lib/onlinepayments/sdk/domain/create_hosted_tokenization_request.rb +57 -42
- data/lib/onlinepayments/sdk/domain/create_hosted_tokenization_response.rb +57 -44
- data/lib/onlinepayments/sdk/domain/create_mandate_request.rb +71 -48
- data/lib/onlinepayments/sdk/domain/create_mandate_response.rb +27 -24
- data/lib/onlinepayments/sdk/domain/create_mandate_with_return_url.rb +71 -48
- data/lib/onlinepayments/sdk/domain/create_payment_link_request.rb +120 -87
- data/lib/onlinepayments/sdk/domain/create_payment_request.rb +82 -60
- data/lib/onlinepayments/sdk/domain/create_payment_response.rb +35 -31
- data/lib/onlinepayments/sdk/domain/create_payout_request.rb +61 -40
- data/lib/onlinepayments/sdk/domain/create_token_request.rb +27 -22
- data/lib/onlinepayments/sdk/domain/created_payment_output.rb +27 -22
- data/lib/onlinepayments/sdk/domain/created_token_response.rb +50 -38
- data/lib/onlinepayments/sdk/domain/credit_card_specific_input_hosted_tokenization.rb +29 -26
- data/lib/onlinepayments/sdk/domain/credit_card_validation_rules_hosted_tokenization.rb +27 -20
- data/lib/onlinepayments/sdk/domain/currency_conversion.rb +27 -22
- data/lib/onlinepayments/sdk/domain/currency_conversion_input.rb +27 -20
- data/lib/onlinepayments/sdk/domain/currency_conversion_request.rb +27 -24
- data/lib/onlinepayments/sdk/domain/currency_conversion_response.rb +34 -28
- data/lib/onlinepayments/sdk/domain/currency_conversion_result.rb +27 -20
- data/lib/onlinepayments/sdk/domain/currency_conversion_specific_input.rb +20 -16
- data/lib/onlinepayments/sdk/domain/customer.rb +87 -68
- data/lib/onlinepayments/sdk/domain/customer_account.rb +77 -55
- data/lib/onlinepayments/sdk/domain/customer_account_authentication.rb +34 -20
- data/lib/onlinepayments/sdk/domain/customer_bank_account.rb +34 -24
- data/lib/onlinepayments/sdk/domain/customer_device.rb +64 -44
- data/lib/onlinepayments/sdk/domain/customer_device_output.rb +20 -16
- data/lib/onlinepayments/sdk/domain/customer_output.rb +20 -18
- data/lib/onlinepayments/sdk/domain/customer_payment_activity.rb +34 -24
- data/lib/onlinepayments/sdk/domain/customer_token.rb +35 -31
- data/lib/onlinepayments/sdk/domain/data_object.rb +32 -0
- data/lib/onlinepayments/sdk/domain/dcc_card_source.rb +41 -30
- data/lib/onlinepayments/sdk/domain/dcc_proposal.rb +51 -41
- data/lib/onlinepayments/sdk/domain/decrypted_payment_data.rb +51 -35
- data/lib/onlinepayments/sdk/domain/directory_entry.rb +34 -24
- data/lib/onlinepayments/sdk/domain/discount.rb +20 -16
- data/lib/onlinepayments/sdk/domain/empty_validator.rb +7 -6
- data/lib/onlinepayments/sdk/domain/error_response.rb +29 -24
- data/lib/onlinepayments/sdk/domain/external_cardholder_authentication_data.rb +86 -55
- data/lib/onlinepayments/sdk/domain/external_token_linked.rb +35 -24
- data/lib/onlinepayments/sdk/domain/feedbacks.rb +30 -0
- data/lib/onlinepayments/sdk/domain/fixed_list_validator.rb +22 -20
- data/lib/onlinepayments/sdk/domain/fraud_fields.rb +37 -28
- data/lib/onlinepayments/sdk/domain/fraud_results.rb +20 -16
- data/lib/onlinepayments/sdk/domain/g_pay_three_d_secure.rb +50 -36
- data/lib/onlinepayments/sdk/domain/get_hosted_checkout_response.rb +27 -22
- data/lib/onlinepayments/sdk/domain/get_hosted_tokenization_response.rb +27 -22
- data/lib/onlinepayments/sdk/domain/get_iin_details_request.rb +27 -22
- data/lib/onlinepayments/sdk/domain/get_iin_details_response.rb +52 -38
- data/lib/onlinepayments/sdk/domain/get_mandate_response.rb +20 -18
- data/lib/onlinepayments/sdk/domain/get_payment_product_groups_response.rb +22 -20
- data/lib/onlinepayments/sdk/domain/get_payment_products_response.rb +22 -20
- data/lib/onlinepayments/sdk/domain/get_privacy_policy_response.rb +20 -16
- data/lib/onlinepayments/sdk/domain/gift_card_purchase.rb +27 -22
- data/lib/onlinepayments/sdk/domain/hosted_checkout_specific_input.rb +83 -56
- data/lib/onlinepayments/sdk/domain/hosted_checkout_specific_output.rb +27 -20
- data/lib/onlinepayments/sdk/domain/iin_detail.rb +34 -24
- data/lib/onlinepayments/sdk/domain/label_template_element.rb +27 -20
- data/lib/onlinepayments/sdk/domain/length_validator.rb +27 -20
- data/lib/onlinepayments/sdk/domain/line_item.rb +44 -31
- data/lib/onlinepayments/sdk/domain/line_item_invoice_data.rb +20 -16
- data/lib/onlinepayments/sdk/domain/loan_recipient.rb +51 -35
- data/lib/onlinepayments/sdk/domain/lodging_data.rb +20 -16
- data/lib/onlinepayments/sdk/domain/mandate_address.rb +51 -35
- data/lib/onlinepayments/sdk/domain/mandate_address_response.rb +51 -35
- data/lib/onlinepayments/sdk/domain/mandate_contact_details.rb +20 -16
- data/lib/onlinepayments/sdk/domain/mandate_customer.rb +52 -44
- data/lib/onlinepayments/sdk/domain/mandate_customer_response.rb +52 -44
- data/lib/onlinepayments/sdk/domain/mandate_merchant_action.rb +27 -22
- data/lib/onlinepayments/sdk/domain/mandate_personal_information.rb +27 -22
- data/lib/onlinepayments/sdk/domain/mandate_personal_information_response.rb +27 -22
- data/lib/onlinepayments/sdk/domain/mandate_personal_name.rb +27 -20
- data/lib/onlinepayments/sdk/domain/mandate_personal_name_response.rb +27 -20
- data/lib/onlinepayments/sdk/domain/mandate_redirect_data.rb +27 -20
- data/lib/onlinepayments/sdk/domain/mandate_response.rb +64 -44
- data/lib/onlinepayments/sdk/domain/merchant_action.rb +43 -28
- data/lib/onlinepayments/sdk/domain/mobile_payment_data.rb +27 -20
- data/lib/onlinepayments/sdk/domain/mobile_payment_method_hosted_checkout_specific_input.rb +43 -26
- data/lib/onlinepayments/sdk/domain/mobile_payment_method_specific_input.rb +71 -50
- data/lib/onlinepayments/sdk/domain/mobile_payment_method_specific_output.rb +58 -45
- data/lib/onlinepayments/sdk/domain/mobile_payment_product302_specific_input.rb +32 -0
- data/lib/onlinepayments/sdk/domain/mobile_payment_product320_specific_input.rb +20 -18
- data/lib/onlinepayments/sdk/domain/mobile_three_d_secure_challenge_parameters.rb +51 -0
- data/lib/onlinepayments/sdk/domain/multiple_payment_information.rb +27 -20
- data/lib/onlinepayments/sdk/domain/omnichannel_payout_specific_input.rb +20 -16
- data/lib/onlinepayments/sdk/domain/operation_output.rb +67 -45
- data/lib/onlinepayments/sdk/domain/operation_payment_references.rb +30 -0
- data/lib/onlinepayments/sdk/domain/order.rb +75 -66
- data/lib/onlinepayments/sdk/domain/order_line_details.rb +79 -47
- data/lib/onlinepayments/sdk/domain/order_references.rb +34 -24
- data/lib/onlinepayments/sdk/domain/order_status_output.rb +52 -38
- data/lib/onlinepayments/sdk/domain/order_type_information.rb +27 -20
- data/lib/onlinepayments/sdk/domain/other_details.rb +37 -0
- data/lib/onlinepayments/sdk/domain/payment_account_on_file.rb +27 -20
- data/lib/onlinepayments/sdk/domain/payment_context.rb +34 -26
- data/lib/onlinepayments/sdk/domain/payment_creation_output.rb +41 -28
- data/lib/onlinepayments/sdk/domain/payment_details_response.rb +60 -49
- data/lib/onlinepayments/sdk/domain/payment_error_response.rb +37 -31
- data/lib/onlinepayments/sdk/domain/payment_link_event.rb +34 -24
- data/lib/onlinepayments/sdk/domain/payment_link_order_input.rb +34 -28
- data/lib/onlinepayments/sdk/domain/payment_link_order_output.rb +34 -28
- data/lib/onlinepayments/sdk/domain/payment_link_response.rb +74 -51
- data/lib/onlinepayments/sdk/domain/payment_link_specific_input.rb +36 -24
- data/lib/onlinepayments/sdk/domain/payment_output.rb +115 -94
- data/lib/onlinepayments/sdk/domain/payment_product.rb +117 -85
- data/lib/onlinepayments/sdk/domain/payment_product130_specific_input.rb +20 -18
- data/lib/onlinepayments/sdk/domain/payment_product130_specific_three_d_secure.rb +41 -28
- data/lib/onlinepayments/sdk/domain/payment_product3012.rb +27 -20
- data/lib/onlinepayments/sdk/domain/payment_product3012_specific_input.rb +51 -0
- data/lib/onlinepayments/sdk/domain/payment_product302_specific_data.rb +22 -20
- data/lib/onlinepayments/sdk/domain/payment_product3203_specific_output.rb +27 -24
- data/lib/onlinepayments/sdk/domain/payment_product3208_specific_input.rb +20 -16
- data/lib/onlinepayments/sdk/domain/payment_product3208_specific_output.rb +20 -16
- data/lib/onlinepayments/sdk/domain/payment_product3209_specific_input.rb +20 -16
- data/lib/onlinepayments/sdk/domain/payment_product3209_specific_output.rb +20 -16
- data/lib/onlinepayments/sdk/domain/payment_product320_specific_data.rb +29 -24
- data/lib/onlinepayments/sdk/domain/payment_product5001_specific_output.rb +48 -16
- data/lib/onlinepayments/sdk/domain/payment_product5100_specific_input.rb +20 -16
- data/lib/onlinepayments/sdk/domain/payment_product5402_specific_output.rb +20 -16
- data/lib/onlinepayments/sdk/domain/payment_product5404.rb +27 -20
- data/lib/onlinepayments/sdk/domain/payment_product5407.rb +27 -20
- data/lib/onlinepayments/sdk/domain/payment_product5500_specific_output.rb +41 -24
- data/lib/onlinepayments/sdk/domain/payment_product771_specific_output.rb +20 -16
- data/lib/onlinepayments/sdk/domain/payment_product840_customer_account.rb +72 -47
- data/lib/onlinepayments/sdk/domain/payment_product840_specific_output.rb +43 -38
- data/lib/onlinepayments/sdk/domain/payment_product_display_hints.rb +34 -24
- data/lib/onlinepayments/sdk/domain/payment_product_field.rb +41 -32
- data/lib/onlinepayments/sdk/domain/payment_product_field_data_restrictions.rb +27 -22
- data/lib/onlinepayments/sdk/domain/payment_product_field_display_element.rb +41 -28
- data/lib/onlinepayments/sdk/domain/payment_product_field_display_hints.rb +84 -56
- data/lib/onlinepayments/sdk/domain/payment_product_field_form_element.rb +30 -24
- data/lib/onlinepayments/sdk/domain/payment_product_field_tooltip.rb +28 -20
- data/lib/onlinepayments/sdk/domain/payment_product_field_validators.rb +83 -73
- data/lib/onlinepayments/sdk/domain/payment_product_filter.rb +32 -29
- data/lib/onlinepayments/sdk/domain/payment_product_filter_hosted_tokenization.rb +22 -20
- data/lib/onlinepayments/sdk/domain/payment_product_filters_hosted_checkout.rb +27 -24
- data/lib/onlinepayments/sdk/domain/payment_product_filters_hosted_tokenization.rb +27 -24
- data/lib/onlinepayments/sdk/domain/payment_product_group.rb +44 -37
- data/lib/onlinepayments/sdk/domain/payment_product_networks_response.rb +22 -20
- data/lib/onlinepayments/sdk/domain/payment_references.rb +27 -20
- data/lib/onlinepayments/sdk/domain/payment_response.rb +51 -41
- data/lib/onlinepayments/sdk/domain/payment_status_output.rb +66 -46
- data/lib/onlinepayments/sdk/domain/payout_error_response.rb +37 -31
- data/lib/onlinepayments/sdk/domain/payout_output.rb +27 -22
- data/lib/onlinepayments/sdk/domain/payout_response.rb +41 -32
- data/lib/onlinepayments/sdk/domain/payout_result.rb +41 -32
- data/lib/onlinepayments/sdk/domain/payout_status_output.rb +34 -24
- data/lib/onlinepayments/sdk/domain/personal_information.rb +34 -26
- data/lib/onlinepayments/sdk/domain/personal_information_token.rb +20 -18
- data/lib/onlinepayments/sdk/domain/personal_name.rb +34 -24
- data/lib/onlinepayments/sdk/domain/personal_name_token.rb +27 -20
- data/lib/onlinepayments/sdk/domain/product_directory.rb +22 -20
- data/lib/onlinepayments/sdk/domain/protection_eligibility.rb +27 -20
- data/lib/onlinepayments/sdk/domain/range_validator.rb +27 -20
- data/lib/onlinepayments/sdk/domain/rate_details.rb +51 -35
- data/lib/onlinepayments/sdk/domain/redirect_data.rb +27 -20
- data/lib/onlinepayments/sdk/domain/redirect_payment_method_specific_input.rb +139 -88
- data/lib/onlinepayments/sdk/domain/redirect_payment_method_specific_output.rb +95 -75
- data/lib/onlinepayments/sdk/domain/redirect_payment_product3203_specific_input.rb +20 -16
- data/lib/onlinepayments/sdk/domain/redirect_payment_product3302_specific_input.rb +44 -0
- data/lib/onlinepayments/sdk/domain/redirect_payment_product3306_specific_input.rb +20 -16
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5001_specific_input.rb +20 -16
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5300_specific_input.rb +74 -0
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5406_specific_input.rb +20 -18
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5408_specific_input.rb +27 -22
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5410_specific_input.rb +32 -0
- data/lib/onlinepayments/sdk/domain/redirect_payment_product809_specific_input.rb +20 -16
- data/lib/onlinepayments/sdk/domain/redirect_payment_product840_specific_input.rb +41 -20
- data/lib/onlinepayments/sdk/domain/redirection_data.rb +20 -16
- data/lib/onlinepayments/sdk/domain/refund_card_method_specific_output.rb +34 -26
- data/lib/onlinepayments/sdk/domain/refund_e_wallet_method_specific_output.rb +34 -26
- data/lib/onlinepayments/sdk/domain/refund_error_response.rb +37 -31
- data/lib/onlinepayments/sdk/domain/refund_mobile_method_specific_output.rb +34 -24
- data/lib/onlinepayments/sdk/domain/refund_output.rb +89 -64
- data/lib/onlinepayments/sdk/domain/refund_payment_product840_customer_account.rb +34 -24
- data/lib/onlinepayments/sdk/domain/refund_payment_product840_specific_output.rb +20 -18
- data/lib/onlinepayments/sdk/domain/refund_redirect_method_specific_output.rb +27 -20
- data/lib/onlinepayments/sdk/domain/refund_request.rb +43 -24
- data/lib/onlinepayments/sdk/domain/refund_response.rb +41 -32
- data/lib/onlinepayments/sdk/domain/refunds_response.rb +22 -20
- data/lib/onlinepayments/sdk/domain/regular_expression_validator.rb +20 -16
- data/lib/onlinepayments/sdk/domain/send_test_request.rb +30 -0
- data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_method_specific_input.rb +27 -22
- data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_method_specific_input_base.rb +27 -22
- data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_method_specific_output.rb +34 -28
- data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_product771_specific_input.rb +27 -22
- data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_product771_specific_input_base.rb +27 -22
- data/lib/onlinepayments/sdk/domain/session_request.rb +22 -20
- data/lib/onlinepayments/sdk/domain/session_response.rb +53 -39
- data/lib/onlinepayments/sdk/domain/shipping.rb +76 -52
- data/lib/onlinepayments/sdk/domain/shipping_method.rb +41 -28
- data/lib/onlinepayments/sdk/domain/shopping_cart.rb +62 -48
- data/lib/onlinepayments/sdk/domain/shopping_cart_extension.rb +51 -43
- data/lib/onlinepayments/sdk/domain/show_form_data.rb +35 -31
- data/lib/onlinepayments/sdk/domain/subsequent_card_payment_method_specific_input.rb +60 -39
- data/lib/onlinepayments/sdk/domain/subsequent_payment_product5001_specific_input.rb +20 -16
- data/lib/onlinepayments/sdk/domain/subsequent_payment_request.rb +35 -31
- data/lib/onlinepayments/sdk/domain/subsequent_payment_response.rb +20 -18
- data/lib/onlinepayments/sdk/domain/surcharge.rb +59 -48
- data/lib/onlinepayments/sdk/domain/surcharge_calculation_card.rb +27 -20
- data/lib/onlinepayments/sdk/domain/surcharge_for_payment_link.rb +20 -16
- data/lib/onlinepayments/sdk/domain/surcharge_rate.rb +41 -28
- data/lib/onlinepayments/sdk/domain/surcharge_specific_input.rb +27 -22
- data/lib/onlinepayments/sdk/domain/surcharge_specific_output.rb +34 -28
- data/lib/onlinepayments/sdk/domain/test_connection.rb +20 -16
- data/lib/onlinepayments/sdk/domain/three_d_secure.rb +98 -63
- data/lib/onlinepayments/sdk/domain/three_d_secure_base.rb +78 -52
- data/lib/onlinepayments/sdk/domain/three_d_secure_data.rb +34 -24
- data/lib/onlinepayments/sdk/domain/three_d_secure_results.rb +107 -67
- data/lib/onlinepayments/sdk/domain/token_card.rb +27 -22
- data/lib/onlinepayments/sdk/domain/token_card_data.rb +27 -18
- data/lib/onlinepayments/sdk/domain/token_card_specific_input.rb +20 -18
- data/lib/onlinepayments/sdk/domain/token_data.rb +27 -18
- data/lib/onlinepayments/sdk/domain/token_e_wallet.rb +28 -22
- data/lib/onlinepayments/sdk/domain/token_response.rb +58 -45
- data/lib/onlinepayments/sdk/domain/transaction.rb +20 -18
- data/lib/onlinepayments/sdk/domain/uploadable_file.rb +33 -0
- data/lib/onlinepayments/sdk/domain/validate_credentials_request.rb +37 -0
- data/lib/onlinepayments/sdk/domain/validate_credentials_response.rb +30 -0
- data/lib/onlinepayments/sdk/domain/value_mapping_element.rb +29 -24
- data/lib/onlinepayments/sdk/domain.rb +4 -0
- data/lib/onlinepayments/sdk/exception_factory.rb +76 -0
- data/lib/onlinepayments/sdk/factory.rb +163 -118
- data/lib/onlinepayments/sdk/idempotence_exception.rb +23 -19
- data/lib/onlinepayments/sdk/json/default_marshaller.rb +34 -0
- data/lib/onlinepayments/sdk/json/marshaller.rb +27 -0
- data/lib/onlinepayments/sdk/json/marshaller_syntax_exception.rb +9 -0
- data/lib/onlinepayments/sdk/json.rb +1 -0
- data/lib/onlinepayments/sdk/logging/communicator_logger.rb +18 -16
- data/lib/onlinepayments/sdk/logging/log_message_builder.rb +80 -47
- data/lib/onlinepayments/sdk/logging/logging_capable.rb +1 -1
- data/lib/onlinepayments/sdk/logging/obfuscation/body_obfuscator.rb +113 -0
- data/lib/onlinepayments/sdk/logging/obfuscation/header_obfuscator.rb +54 -0
- data/lib/onlinepayments/sdk/logging/obfuscation/obfuscation_capable.rb +21 -0
- data/lib/onlinepayments/sdk/logging/obfuscation/obfuscation_rule.rb +47 -0
- data/lib/onlinepayments/sdk/logging/obfuscation.rb +1 -0
- data/lib/onlinepayments/sdk/logging/request_log_message_builder.rb +40 -29
- data/lib/onlinepayments/sdk/logging/response_log_message_builder.rb +30 -23
- data/lib/onlinepayments/sdk/logging/ruby_communicator_logger.rb +49 -45
- data/lib/onlinepayments/sdk/logging/stdout_communicator_logger.rb +20 -23
- data/lib/onlinepayments/sdk/logging.rb +1 -10
- data/lib/onlinepayments/sdk/merchant/captures/captures_client.rb +57 -0
- data/lib/onlinepayments/sdk/merchant/captures.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/complete/complete_client.rb +60 -0
- data/lib/onlinepayments/sdk/merchant/complete.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/hostedcheckout/hosted_checkout_client.rb +72 -71
- data/lib/onlinepayments/sdk/merchant/hostedcheckout.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/hostedtokenization/hosted_tokenization_client.rb +72 -71
- data/lib/onlinepayments/sdk/merchant/hostedtokenization.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/mandates/mandates_client.rb +165 -164
- data/lib/onlinepayments/sdk/merchant/mandates.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/merchant_client.rb +116 -64
- data/lib/onlinepayments/sdk/merchant/paymentlinks/payment_links_client.rb +102 -101
- data/lib/onlinepayments/sdk/merchant/paymentlinks.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/payments/payments_client.rb +233 -332
- data/lib/onlinepayments/sdk/merchant/payments.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/payouts/payouts_client.rb +73 -71
- data/lib/onlinepayments/sdk/merchant/payouts.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/privacypolicy/get_privacy_policy_params.rb +32 -0
- data/lib/onlinepayments/sdk/merchant/privacypolicy/privacy_policy_client.rb +54 -0
- data/lib/onlinepayments/sdk/merchant/privacypolicy.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/productgroups/get_product_group_params.rb +50 -47
- data/lib/onlinepayments/sdk/merchant/productgroups/get_product_groups_params.rb +50 -47
- data/lib/onlinepayments/sdk/merchant/productgroups/product_groups_client.rb +72 -72
- data/lib/onlinepayments/sdk/merchant/productgroups.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/products/get_payment_product_networks_params.rb +27 -25
- data/lib/onlinepayments/sdk/merchant/products/get_payment_product_params.rb +50 -47
- data/lib/onlinepayments/sdk/merchant/products/get_payment_products_params.rb +50 -47
- data/lib/onlinepayments/sdk/merchant/products/get_product_directory_params.rb +21 -19
- data/lib/onlinepayments/sdk/merchant/products/products_client.rb +134 -136
- data/lib/onlinepayments/sdk/merchant/products.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/refunds/refunds_client.rb +57 -0
- data/lib/onlinepayments/sdk/merchant/refunds.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/services/services_client.rb +124 -155
- data/lib/onlinepayments/sdk/merchant/services.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/sessions/sessions_client.rb +42 -41
- data/lib/onlinepayments/sdk/merchant/sessions.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/tokens/tokens_client.rb +101 -100
- data/lib/onlinepayments/sdk/merchant/tokens.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/webhooks/webhooks_client.rb +83 -0
- data/lib/onlinepayments/sdk/merchant/webhooks.rb +4 -0
- data/lib/onlinepayments/sdk/merchant.rb +4 -0
- data/lib/onlinepayments/sdk/platform_exception.rb +19 -0
- data/lib/onlinepayments/sdk/proxy_configuration.rb +60 -60
- data/lib/onlinepayments/sdk/reference_exception.rb +14 -9
- data/lib/onlinepayments/sdk/validation_exception.rb +14 -9
- data/lib/onlinepayments/sdk/webhooks/api_version_mismatch_exception.rb +17 -15
- data/lib/onlinepayments/sdk/webhooks/in_memory_secret_key_store.rb +46 -43
- data/lib/onlinepayments/sdk/webhooks/secret_key_not_available_exception.rb +16 -12
- data/lib/onlinepayments/sdk/webhooks/secret_key_store.rb +13 -11
- data/lib/onlinepayments/sdk/webhooks/signature_validation_exception.rb +15 -14
- data/lib/onlinepayments/sdk/webhooks/signature_validator.rb +81 -0
- data/lib/onlinepayments/sdk/webhooks/webhooks_event.rb +84 -53
- data/lib/onlinepayments/sdk/webhooks/webhooks_helper.rb +28 -90
- data/lib/onlinepayments/sdk/webhooks.rb +1 -11
- data/lib/onlinepayments/sdk.rb +4 -26
- data/onlinepayments-sdk-ruby.gemspec +3 -2
- metadata +89 -35
- data/lib/onlinepayments/sdk/authenticator.rb +0 -16
- data/lib/onlinepayments/sdk/communication_exception.rb +0 -16
- data/lib/onlinepayments/sdk/connection.rb +0 -41
- data/lib/onlinepayments/sdk/data_object.rb +0 -31
- data/lib/onlinepayments/sdk/defaultimpl/authorization_type.rb +0 -24
- data/lib/onlinepayments/sdk/defaultimpl/default_authenticator.rb +0 -108
- data/lib/onlinepayments/sdk/defaultimpl/default_connection.rb +0 -365
- data/lib/onlinepayments/sdk/defaultimpl/default_marshaller.rb +0 -32
- data/lib/onlinepayments/sdk/defaultimpl.rb +0 -6
- data/lib/onlinepayments/sdk/endpoint_configuration.rb +0 -127
- data/lib/onlinepayments/sdk/exceptions.rb +0 -8
- data/lib/onlinepayments/sdk/logging/logging_util.rb +0 -286
- data/lib/onlinepayments/sdk/marshaller.rb +0 -24
- data/lib/onlinepayments/sdk/marshaller_syntax_exception.rb +0 -6
- data/lib/onlinepayments/sdk/merchant/services/get_privacy_policy_params.rb +0 -30
- data/lib/onlinepayments/sdk/meta_data_provider.rb +0 -150
- data/lib/onlinepayments/sdk/modules.rb +0 -62
- data/lib/onlinepayments/sdk/multipart_form_data_object.rb +0 -44
- data/lib/onlinepayments/sdk/multipart_form_data_request.rb +0 -9
- data/lib/onlinepayments/sdk/not_found_exception.rb +0 -16
- data/lib/onlinepayments/sdk/param_request.rb +0 -11
- data/lib/onlinepayments/sdk/payment_platform_exception.rb +0 -15
- data/lib/onlinepayments/sdk/pooled_connection.rb +0 -21
- data/lib/onlinepayments/sdk/request_header.rb +0 -50
- data/lib/onlinepayments/sdk/request_param.rb +0 -23
- data/lib/onlinepayments/sdk/response_exception.rb +0 -47
- data/lib/onlinepayments/sdk/response_header.rb +0 -42
- data/lib/onlinepayments/sdk/uploadable_file.rb +0 -30
- data/lib/onlinepayments/sdk/webhooks/webhooks.rb +0 -22
- data/lib/onlinepayments/sdk/webhooks/webhooks_helper_builder.rb +0 -25
@@ -1,310 +1,517 @@
|
|
1
|
+
require 'date'
|
1
2
|
require 'uri'
|
2
|
-
require 'onlinepayments/sdk/
|
3
|
-
require 'onlinepayments/sdk/
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
class Communicator
|
18
|
-
include Logging::LoggingCapable
|
19
|
-
|
20
|
-
# Creates a new Communicator based on the given arguments.
|
3
|
+
require 'onlinepayments/sdk/communication/communication_exception'
|
4
|
+
require 'onlinepayments/sdk/communication/multipart_form_data_object'
|
5
|
+
require 'onlinepayments/sdk/communication/multipart_form_data_request'
|
6
|
+
require 'onlinepayments/sdk/communication/not_found_exception'
|
7
|
+
require 'onlinepayments/sdk/communication/pooled_connection'
|
8
|
+
require 'onlinepayments/sdk/communication/request_header'
|
9
|
+
require 'onlinepayments/sdk/communication/response_exception'
|
10
|
+
require 'onlinepayments/sdk/communication/response_header'
|
11
|
+
require 'onlinepayments/sdk/logging/logging_capable'
|
12
|
+
require 'onlinepayments/sdk/logging/obfuscation/obfuscation_capable'
|
13
|
+
|
14
|
+
module OnlinePayments
|
15
|
+
module SDK
|
16
|
+
# Class responsible for facilitating communication with the Online Payments platform.
|
17
|
+
# It combines the following classes to provide communication functionality:
|
21
18
|
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
19
|
+
# api_endpoint:: the base URL to the Online Payments platform
|
20
|
+
# connection:: {OnlinePayments::SDK::Communication::Connection} used to communicate with the Online Payments platform
|
21
|
+
# authenticator:: {OnlinePayments::SDK::Authentication::Authenticator} used for authenticating messages sent
|
22
|
+
# metadata_provider:: {OnlinePayments::SDK::Communication::MetadataProvider} object containing information relevant for sending requests
|
23
|
+
# marshaller:: {OnlinePayments::SDK::JSON::Marshaller} that is used to marshal and unmarshal data to and from JSON format
|
27
24
|
#
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
25
|
+
# @attr_reader [OnlinePayments::SDK::JSON::Marshaller] marshaller A Marshaller instance used by the communicator for serializing/deserializing to/from JSON
|
26
|
+
#
|
27
|
+
class Communicator
|
28
|
+
include Logging::LoggingCapable
|
29
|
+
include Logging::Obfuscation::ObfuscationCapable
|
30
|
+
|
31
|
+
# Creates a new Communicator.
|
32
|
+
#
|
33
|
+
# @param api_endpoint [String] the base URL to the Online Payments platform
|
34
|
+
# @param connection [OnlinePayments::SDK::Communication::Connection] used to communicate with the Online Payments platform
|
35
|
+
# @param authenticator [OnlinePayments::SDK::Authentication::Authenticator] used for authenticating messages sent
|
36
|
+
# @param metadata_provider [OnlinePayments::SDK::Communication::MetadataProvider] object containing information relevant for sending requests
|
37
|
+
# @param marshaller [OnlinePayments::SDK::JSON::Marshaller] used to marshal and unmarshal data to and from JSON format
|
38
|
+
#
|
39
|
+
def initialize(api_endpoint, connection, authenticator, metadata_provider, marshaller)
|
40
|
+
raise ArgumentError.new('api_endpoint is required') unless api_endpoint
|
41
|
+
raise ArgumentError.new('connection is required') unless connection
|
42
|
+
raise ArgumentError.new('authenticator is required') unless authenticator
|
43
|
+
raise ArgumentError.new('metadata_provider is required') unless metadata_provider
|
44
|
+
raise ArgumentError('marshaller is required') if marshaller.nil?
|
45
|
+
|
46
|
+
uri = URI(api_endpoint)
|
47
|
+
raise RuntimeError('api_endpoint should not contain a path') unless uri.path.nil? || uri.path.empty?
|
48
|
+
unless uri.userinfo.nil? && uri.query.nil? && uri.fragment.nil?
|
49
|
+
raise RuntimeError('api_endpoint should not contain user info, query or fragment')
|
50
|
+
end
|
51
|
+
@api_endpoint = uri
|
52
|
+
@connection = connection
|
53
|
+
@authenticator = authenticator
|
54
|
+
@metadata_provider = metadata_provider
|
55
|
+
@marshaller = marshaller
|
38
56
|
end
|
39
|
-
@connection = connection
|
40
|
-
@authenticator = authenticator
|
41
|
-
@meta_data_provider = meta_data_provider
|
42
|
-
@marshaller = marshaller
|
43
|
-
end
|
44
57
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
58
|
+
# Performs a GET request to the Online Payments platform and returns the response as the given response type.
|
59
|
+
#
|
60
|
+
# @param relative_path [String] path relative to the API endpoint
|
61
|
+
# @param request_headers [Array<OnlinePayments::SDK::Communication::RequestHeader>, nil] optional array of request headers
|
62
|
+
# @param request_parameters [OnlinePayments::SDK::Communication::ParamRequest, nil] optional request parameters
|
63
|
+
# @param response_type [Type] the response type.
|
64
|
+
# @param context [OnlinePayments::SDK::CallContext, nil] optional call context.
|
65
|
+
# @return the response of the GET request as the given response type
|
66
|
+
# @raise [OnlinePayments::SDK::Communication::ResponseException] if the request could not be fulfilled successfully.
|
67
|
+
# This occurs for example if the request is not authenticated correctly
|
68
|
+
# @raise [OnlinePayments::SDK::Communication::NotFoundException] if the requested resource is not found
|
69
|
+
# @raise [OnlinePayments::SDK::Communication::CommunicationException] if there is an error in communicating with the Online Payments platform.
|
70
|
+
# This occurs for example if a timeout occurs.
|
71
|
+
def get(relative_path, request_headers, request_parameters, response_type, context)
|
72
|
+
request_parameter_list = request_parameters && request_parameters.to_request_parameters
|
73
|
+
uri = to_absolute_uri(relative_path, request_parameter_list)
|
74
|
+
|
75
|
+
request_headers = [] if request_headers.nil?
|
76
|
+
add_generic_headers('GET', uri, request_headers, context)
|
77
|
+
|
78
|
+
response_status_code, response_headers, response_body = nil
|
79
|
+
@connection.get(uri, request_headers) do |status_code, headers, content|
|
80
|
+
response_status_code = status_code
|
81
|
+
response_headers = headers
|
82
|
+
response_body = content.read.force_encoding('UTF-8')
|
83
|
+
end
|
84
|
+
process_response(response_body, response_status_code, response_headers, response_type, relative_path, context)
|
71
85
|
end
|
72
|
-
process_response(response_body, response_status_code, response_headers, response_type, relative_path, context)
|
73
|
-
end
|
74
86
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
87
|
+
# Performs a GET request to the Online Payments platform and yields the response as the headers and body.
|
88
|
+
#
|
89
|
+
# @param relative_path [String] Path relative to the API endpoint
|
90
|
+
# @param request_headers [Array<OnlinePayments::SDK::Communication::RequestHeader>, nil] Optional array of request headers
|
91
|
+
# @param request_parameters [OnlinePayments::SDK::Communication::ParamRequest, nil] Optional request parameters
|
92
|
+
# @param context [OnlinePayments::SDK::CallContext, nil] Optional call context.
|
93
|
+
# @yield [Array<OnlinePayments::SDK::Communication::ResponseHeader>, IO] The response headers and body.
|
94
|
+
# @raise [OnlinePayments::SDK::Communication::ResponseException] if the request could not be fulfilled successfully.
|
95
|
+
# This occurs for example if the request is not authenticated correctly
|
96
|
+
# @raise [OnlinePayments::SDK::Communication::NotFoundException] if the requested resource is not found
|
97
|
+
# @raise [OnlinePayments::SDK::Communication::CommunicationException] if there is an error in communicating with the Online Payments platform.
|
98
|
+
# This occurs for example if a timeout occurs.
|
99
|
+
def get_with_binary_response(relative_path, request_headers, request_parameters, context)
|
100
|
+
request_parameter_list = request_parameters && request_parameters.to_request_parameters
|
101
|
+
uri = to_absolute_uri(relative_path, request_parameter_list)
|
102
|
+
|
103
|
+
request_headers = [] if request_headers.nil?
|
104
|
+
add_generic_headers('GET', uri, request_headers, context)
|
105
|
+
|
106
|
+
response_status_code, response_headers, response_body = nil
|
107
|
+
@connection.get(uri, request_headers) do |status_code, headers, content|
|
108
|
+
response_status_code = status_code
|
109
|
+
response_headers = headers
|
110
|
+
response_body = process_binary_response(status_code, content, headers, context) do |h, c|
|
111
|
+
yield h, c
|
112
|
+
end
|
113
|
+
end
|
114
|
+
throw_exception_if_necessary(response_body, response_status_code, response_headers, relative_path)
|
100
115
|
end
|
101
|
-
process_response(response_body, response_status_code, response_headers, response_type, relative_path, context)
|
102
|
-
end
|
103
116
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
request_headers.push(RequestHeader.new('Content-Type', multipart.content_type))
|
131
|
-
body = multipart
|
132
|
-
elsif request_body
|
133
|
-
request_headers.push(RequestHeader.new('Content-Type', 'application/json'))
|
134
|
-
body = @marshaller.marshal(request_body)
|
135
|
-
else
|
136
|
-
# Set the content-type, even though there is no body, to prevent the httpClient from
|
137
|
-
# adding a content-type header after authentication has been generated.
|
138
|
-
request_headers.push(RequestHeader.new('Content-Type', 'text/plain'))
|
117
|
+
# Performs a DELETE request to the Online Payments platform and returns the response as the given response type.
|
118
|
+
#
|
119
|
+
# @param relative_path [String] Path relative to the API endpoint
|
120
|
+
# @param request_headers [Array<OnlinePayments::SDK::Communication::RequestHeader>, nil] Optional array of request headers
|
121
|
+
# @param request_parameters [OnlinePayments::SDK::Communication::ParamRequest, nil] Optional request parameters
|
122
|
+
# @param response_type [Type] The response type.
|
123
|
+
# @param context [OnlinePayments::SDK::CallContext, nil] Optional call context.
|
124
|
+
# @return The response of the DELETE request as the given response type
|
125
|
+
# @raise [OnlinePayments::SDK::Communication::ResponseException] if the request could not be fulfilled successfully.
|
126
|
+
# This occurs for example if the request is not authenticated correctly
|
127
|
+
# @raise [OnlinePayments::SDK::Communication::NotFoundException] if the requested resource is not found
|
128
|
+
# @raise [OnlinePayments::SDK::Communication::CommunicationException] if there is an error in communicating with the Online Payments platform.
|
129
|
+
# This occurs for example if a timeout occurs.
|
130
|
+
def delete(relative_path, request_headers, request_parameters, response_type, context)
|
131
|
+
request_parameter_list = request_parameters && request_parameters.to_request_parameters
|
132
|
+
uri = to_absolute_uri(relative_path, request_parameter_list)
|
133
|
+
request_headers = [] if request_headers.nil?
|
134
|
+
add_generic_headers('DELETE', uri, request_headers, context)
|
135
|
+
|
136
|
+
response_status_code, response_headers, response_body = nil
|
137
|
+
@connection.delete(uri, request_headers) do |status_code, headers, content|
|
138
|
+
response_status_code = status_code
|
139
|
+
response_headers = headers
|
140
|
+
response_body = content.read.force_encoding('UTF-8')
|
141
|
+
end
|
142
|
+
process_response(response_body, response_status_code, response_headers, response_type, relative_path, context)
|
139
143
|
end
|
140
144
|
|
141
|
-
|
145
|
+
# Performs a DELETE request to the Online Payments platform and yields the response as the headers and body.
|
146
|
+
#
|
147
|
+
# @param relative_path [String] Path relative to the API endpoint
|
148
|
+
# @param request_headers [Array<OnlinePayments::SDK::Communication::RequestHeader>, nil] Optional array of request headers
|
149
|
+
# @param request_parameters [OnlinePayments::SDK::Communication::ParamRequest, nil] Optional request parameters
|
150
|
+
# @param context [OnlinePayments::SDK::CallContext, nil] Optional call context.
|
151
|
+
# @yield [Array<OnlinePayments::SDK::Communication::ResponseHeader>, IO] The response headers and body.
|
152
|
+
# @raise [OnlinePayments::SDK::Communication::ResponseException] if the request could not be fulfilled successfully.
|
153
|
+
# This occurs for example if the request is not authenticated correctly
|
154
|
+
# @raise [OnlinePayments::SDK::Communication::NotFoundException] if the requested resource is not found
|
155
|
+
# @raise [OnlinePayments::SDK::Communication::CommunicationException] if there is an error in communicating with the Online Payments platform.
|
156
|
+
# This occurs for example if a timeout occurs.
|
157
|
+
def delete_with_binary_response(relative_path, request_headers, request_parameters, context)
|
158
|
+
request_parameter_list = request_parameters && request_parameters.to_request_parameters
|
159
|
+
uri = to_absolute_uri(relative_path, request_parameter_list)
|
160
|
+
request_headers = [] if request_headers.nil?
|
161
|
+
add_generic_headers('DELETE', uri, request_headers, context)
|
162
|
+
|
163
|
+
response_status_code, response_headers, response_body = nil
|
164
|
+
@connection.delete(uri, request_headers) do |status_code, headers, content|
|
165
|
+
response_status_code = status_code
|
166
|
+
response_headers = headers
|
167
|
+
response_body = process_binary_response(status_code, content, headers, context) do |h, c|
|
168
|
+
yield h, c
|
169
|
+
end
|
170
|
+
end
|
171
|
+
throw_exception_if_necessary(response_body, response_status_code, response_headers, relative_path)
|
172
|
+
end
|
142
173
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
174
|
+
# Performs a POST request to the Online Payments platform and returns the response as the given response type.
|
175
|
+
#
|
176
|
+
# @param relative_path [String] Path relative to the API endpoint
|
177
|
+
# @param request_headers [Array<OnlinePayments::SDK::Communication::RequestHeader>, nil] Optional array of request headers
|
178
|
+
# @param request_parameters [OnlinePayments::SDK::Communication::ParamRequest, nil] Optional request parameters
|
179
|
+
# @param request_body [OnlinePayments::SDK::Domain::DataObject, OnlinePayments::SDK::Communication::MultipartFormDataObject, OnlinePayments::SDK::Communication::MultipartFormDataRequest, nil]
|
180
|
+
# The optional request body
|
181
|
+
# @param response_type [Type] The response type.
|
182
|
+
# @param context [OnlinePayments::SDK::CallContext, nil] Optional call context.
|
183
|
+
# @return The response of the POST request as the given response type
|
184
|
+
# @raise [OnlinePayments::SDK::Communication::ResponseException] if the request could not be fulfilled successfully.
|
185
|
+
# This occurs for example if the request is not authenticated correctly
|
186
|
+
# @raise [OnlinePayments::SDK::Communication::NotFoundException] if the requested resource is not found
|
187
|
+
# @raise [OnlinePayments::SDK::Communication::CommunicationException] if there is an error in communicating with the Online Payments platform.
|
188
|
+
# This occurs for example if a timeout occurs.
|
189
|
+
def post(relative_path, request_headers, request_parameters, request_body, response_type, context)
|
190
|
+
request_parameter_list = request_parameters && request_parameters.to_request_parameters
|
191
|
+
uri = to_absolute_uri(relative_path, request_parameter_list)
|
192
|
+
request_headers = [] if request_headers.nil?
|
193
|
+
|
194
|
+
body = nil
|
195
|
+
if request_body.is_a? Communication::MultipartFormDataObject
|
196
|
+
request_headers.push(Communication::RequestHeader.new('Content-Type', request_body.content_type))
|
197
|
+
body = request_body
|
198
|
+
elsif request_body.is_a? Communication::MultipartFormDataRequest
|
199
|
+
multipart = request_body.to_multipart_form_data_object
|
200
|
+
request_headers.push(Communication::RequestHeader.new('Content-Type', multipart.content_type))
|
201
|
+
body = multipart
|
202
|
+
elsif !request_body.nil?
|
203
|
+
request_headers.push(Communication::RequestHeader.new('Content-Type', 'application/json'))
|
204
|
+
body = @marshaller.marshal(request_body)
|
205
|
+
else
|
206
|
+
# Set the content-type, even though there is no body, to prevent the httpClient from
|
207
|
+
# adding a content-type header after authentication has been generated.
|
208
|
+
request_headers.push(Communication::RequestHeader.new('Content-Type', 'text/plain'))
|
209
|
+
end
|
210
|
+
|
211
|
+
add_generic_headers('POST', uri, request_headers, context)
|
212
|
+
|
213
|
+
response_status_code, response_headers, response_body = nil
|
214
|
+
@connection.post(uri, request_headers, body) do |status_code, headers, content|
|
215
|
+
response_status_code = status_code
|
216
|
+
response_headers = headers
|
217
|
+
response_body = content.read.force_encoding('UTF-8')
|
218
|
+
end
|
219
|
+
process_response(response_body, response_status_code, response_headers, response_type, relative_path, context)
|
148
220
|
end
|
149
|
-
process_response(response_body, response_status_code, response_headers, response_type, relative_path, context)
|
150
|
-
end
|
151
221
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
222
|
+
# Performs a POST request to the Online Payments platform and yields the response as the headers and body.
|
223
|
+
#
|
224
|
+
# @param relative_path [String] Path relative to the API endpoint
|
225
|
+
# @param request_headers [Array<OnlinePayments::SDK::Communication::RequestHeader>, nil] Optional array of request headers
|
226
|
+
# @param request_parameters [OnlinePayments::SDK::Communication::ParamRequest, nil] Optional request parameters
|
227
|
+
# @param request_body [OnlinePayments::SDK::Domain::DataObject, OnlinePayments::SDK::Communication::MultipartFormDataObject, OnlinePayments::SDK::Communication::MultipartFormDataRequest, nil]
|
228
|
+
# The optional request body
|
229
|
+
# @param context [OnlinePayments::SDK::CallContext, nil] Optional call context.
|
230
|
+
# @yield [Array<OnlinePayments::SDK::Communication::ResponseHeader>, IO] The response headers and body.
|
231
|
+
# @raise [OnlinePayments::SDK::Communication::ResponseException] if the request could not be fulfilled successfully.
|
232
|
+
# This occurs for example if the request is not authenticated correctly
|
233
|
+
# @raise [OnlinePayments::SDK::Communication::NotFoundException] if the requested resource is not found
|
234
|
+
# @raise [OnlinePayments::SDK::Communication::CommunicationException] if there is an error in communicating with the Online Payments platform.
|
235
|
+
# This occurs for example if a timeout occurs.
|
236
|
+
def post_with_binary_response(relative_path, request_headers, request_parameters, request_body, context)
|
237
|
+
request_parameter_list = request_parameters && request_parameters.to_request_parameters
|
238
|
+
uri = to_absolute_uri(relative_path, request_parameter_list)
|
239
|
+
request_headers = [] if request_headers.nil?
|
240
|
+
|
241
|
+
body = nil
|
242
|
+
if request_body.is_a? Communication::MultipartFormDataObject
|
243
|
+
request_headers.push(Communication::RequestHeader.new('Content-Type', request_body.content_type))
|
244
|
+
body = request_body
|
245
|
+
elsif request_body.is_a? Communication::MultipartFormDataRequest
|
246
|
+
multipart = request_body.to_multipart_form_data_object
|
247
|
+
request_headers.push(Communication::RequestHeader.new('Content-Type', multipart.content_type))
|
248
|
+
body = multipart
|
249
|
+
elsif !request_body.nil?
|
250
|
+
request_headers.push(Communication::RequestHeader.new('Content-Type', 'application/json'))
|
251
|
+
body = @marshaller.marshal(request_body)
|
252
|
+
else
|
253
|
+
# Set the content-type, even though there is no body, to prevent the httpClient from
|
254
|
+
# adding a content-type header after authentication has been generated.
|
255
|
+
request_headers.push(Communication::RequestHeader.new('Content-Type', 'text/plain'))
|
256
|
+
end
|
257
|
+
add_generic_headers('POST', uri, request_headers, context)
|
258
|
+
|
259
|
+
response_status_code, response_headers, response_body = nil
|
260
|
+
@connection.post(uri, request_headers, body) do |status_code, headers, content|
|
261
|
+
response_status_code = status_code
|
262
|
+
response_headers = headers
|
263
|
+
response_body = process_binary_response(status_code, content, headers, context) do |h, c|
|
264
|
+
yield h, c
|
265
|
+
end
|
266
|
+
end
|
267
|
+
throw_exception_if_necessary(response_body, response_status_code, response_headers, relative_path)
|
180
268
|
end
|
181
|
-
add_generic_headers('PUT', uri, request_headers, context)
|
182
269
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
270
|
+
# Performs a PUT request to the Online Payments platform and returns the response as the given response type.
|
271
|
+
#
|
272
|
+
# @param relative_path [String] Path relative to the API endpoint
|
273
|
+
# @param request_headers [Array<OnlinePayments::SDK::Communication::RequestHeader>, nil] Optional array of request headers
|
274
|
+
# @param request_parameters [OnlinePayments::SDK::Communication::ParamRequest, nil] Optional request parameters
|
275
|
+
# @param request_body [OnlinePayments::SDK::Domain::DataObject, OnlinePayments::SDK::Communication::MultipartFormDataObject, OnlinePayments::SDK::Communication::MultipartFormDataRequest, nil]
|
276
|
+
# The optional request body
|
277
|
+
# @param response_type [Type] The response type.
|
278
|
+
# @param context [OnlinePayments::SDK::CallContext, nil] Optional call context.
|
279
|
+
# @return The response of the PUT request as the given response type
|
280
|
+
# @raise [OnlinePayments::SDK::Communication::ResponseException] if the request could not be fulfilled successfully.
|
281
|
+
# This occurs for example if the request is not authenticated correctly
|
282
|
+
# @raise [OnlinePayments::SDK::Communication::NotFoundException] if the requested resource is not found
|
283
|
+
# @raise [OnlinePayments::SDK::Communication::CommunicationException] if there is an error in communicating with the Online Payments platform.
|
284
|
+
# This occurs for example if a timeout occurs.
|
285
|
+
def put(relative_path, request_headers, request_parameters, request_body, response_type, context)
|
286
|
+
request_parameter_list = request_parameters && request_parameters.to_request_parameters
|
287
|
+
uri = to_absolute_uri(relative_path, request_parameter_list)
|
288
|
+
request_headers = [] if request_headers.nil?
|
289
|
+
|
290
|
+
body = nil
|
291
|
+
if request_body.is_a? Communication::MultipartFormDataObject
|
292
|
+
request_headers.push(Communication::RequestHeader.new('Content-Type', request_body.content_type))
|
293
|
+
body = request_body
|
294
|
+
elsif request_body.is_a? Communication::MultipartFormDataRequest
|
295
|
+
multipart = request_body.to_multipart_form_data_object
|
296
|
+
request_headers.push(Communication::RequestHeader.new('Content-Type', multipart.content_type))
|
297
|
+
body = multipart
|
298
|
+
elsif !request_body.nil?
|
299
|
+
request_headers.push(Communication::RequestHeader.new('Content-Type', 'application/json'))
|
300
|
+
body = @marshaller.marshal(request_body)
|
301
|
+
else
|
302
|
+
# Set the content-type, even though there is no body, to prevent the httpClient from
|
303
|
+
# adding a content-type header after authentication has been generated.
|
304
|
+
request_headers.push(Communication::RequestHeader.new('Content-Type', 'text/plain'))
|
305
|
+
end
|
306
|
+
add_generic_headers('PUT', uri, request_headers, context)
|
307
|
+
|
308
|
+
response_status_code, response_headers, response_body = nil
|
309
|
+
@connection.put(uri, request_headers, body) do |status_code, headers, content|
|
310
|
+
response_status_code = status_code
|
311
|
+
response_headers = headers
|
312
|
+
response_body = content.read.force_encoding('UTF-8')
|
313
|
+
end
|
314
|
+
process_response(response_body, response_status_code, response_headers, response_type, relative_path, context)
|
188
315
|
end
|
189
|
-
process_response(response_body, response_status_code, response_headers, response_type, relative_path, context)
|
190
|
-
end
|
191
316
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
@
|
196
|
-
|
317
|
+
# Performs a PUT request to the Online Payments platform and yields the response as the headers and body.
|
318
|
+
#
|
319
|
+
# @param relative_path [String] Path relative to the API endpoint
|
320
|
+
# @param request_headers [Array<OnlinePayments::SDK::Communication::RequestHeader>, nil] Optional array of request headers
|
321
|
+
# @param request_parameters [OnlinePayments::SDK::Communication::ParamRequest, nil] Optional request parameters
|
322
|
+
# @param request_body [OnlinePayments::SDK::Domain::DataObject, OnlinePayments::SDK::Communication::MultipartFormDataObject, OnlinePayments::SDK::Communication::MultipartFormDataRequest, nil]
|
323
|
+
# The optional request body
|
324
|
+
# @param context [OnlinePayments::SDK::CallContext, nil] Optional call context.
|
325
|
+
# @yield [Array<OnlinePayments::SDK::Communication::ResponseHeader>, IO] The response headers and body.
|
326
|
+
# @raise [OnlinePayments::SDK::Communication::ResponseException] if the request could not be fulfilled successfully.
|
327
|
+
# This occurs for example if the request is not authenticated correctly
|
328
|
+
# @raise [OnlinePayments::SDK::Communication::NotFoundException] if the requested resource is not found
|
329
|
+
# @raise [OnlinePayments::SDK::Communication::CommunicationException] if there is an error in communicating with the Online Payments platform.
|
330
|
+
# This occurs for example if a timeout occurs.
|
331
|
+
def put_with_binary_response(relative_path, request_headers, request_parameters, request_body, context)
|
332
|
+
request_parameter_list = request_parameters && request_parameters.to_request_parameters
|
333
|
+
uri = to_absolute_uri(relative_path, request_parameter_list)
|
334
|
+
request_headers = [] if request_headers.nil?
|
335
|
+
|
336
|
+
body = nil
|
337
|
+
if request_body.is_a? Communication::MultipartFormDataObject
|
338
|
+
request_headers.push(Communication::RequestHeader.new('Content-Type', request_body.content_type))
|
339
|
+
body = request_body
|
340
|
+
elsif request_body.is_a? Communication::MultipartFormDataRequest
|
341
|
+
multipart = request_body.to_multipart_form_data_object
|
342
|
+
request_headers.push(Communication::RequestHeader.new('Content-Type', multipart.content_type))
|
343
|
+
body = multipart
|
344
|
+
elsif !request_body.nil?
|
345
|
+
request_headers.push(Communication::RequestHeader.new('Content-Type', 'application/json'))
|
346
|
+
body = @marshaller.marshal(request_body)
|
347
|
+
else
|
348
|
+
# Set the content-type, even though there is no body, to prevent the httpClient from
|
349
|
+
# adding a content-type header after authentication has been generated.
|
350
|
+
request_headers.push(Communication::RequestHeader.new('Content-Type', 'text/plain'))
|
351
|
+
end
|
352
|
+
add_generic_headers('PUT', uri, request_headers, context)
|
353
|
+
|
354
|
+
response_status_code, response_headers, response_body = nil
|
355
|
+
@connection.put(uri, request_headers, body) do |status_code, headers, content|
|
356
|
+
response_status_code = status_code
|
357
|
+
response_headers = headers
|
358
|
+
response_body = process_binary_response(status_code, content, headers, context) do |h, c|
|
359
|
+
yield h, c
|
360
|
+
end
|
361
|
+
end
|
362
|
+
throw_exception_if_necessary(response_body, response_status_code, response_headers, relative_path)
|
363
|
+
end
|
197
364
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
365
|
+
# Closes any connections idle for more than _idle_time_ seconds.
|
366
|
+
# Will not have any effect if the connection is not a pooled connection (an instance of {OnlinePayments::SDK::Communication::PooledConnection}).
|
367
|
+
def close_idle_connections(idle_time)
|
368
|
+
@connection.close_idle_connections(idle_time) if @connection.is_a? PooledConnection
|
369
|
+
end
|
203
370
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
def enable_logging(communicator_logger)
|
210
|
-
@connection.enable_logging(communicator_logger)
|
211
|
-
end
|
371
|
+
# Closes any connections that have expired.
|
372
|
+
# Will not have any effect if the connection is not a pooled connection (an instance of {OnlinePayments::SDK::Communication::PooledConnection}).
|
373
|
+
def close_expired_connections
|
374
|
+
@connection.close_expired_connections if @connection.is_a? PooledConnection
|
375
|
+
end
|
212
376
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
377
|
+
# Sets the current body obfuscator to use.
|
378
|
+
# @param body_obfuscator [OnlinePayments::SDK::Logging::Obfuscation::BodyObfuscator]
|
379
|
+
def set_body_obfuscator(body_obfuscator)
|
380
|
+
@connection.set_body_obfuscator(body_obfuscator)
|
381
|
+
end
|
217
382
|
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
end
|
383
|
+
# Sets the current header obfuscator to use.
|
384
|
+
# @param header_obfuscator [OnlinePayments::SDK::Logging::Obfuscation::HeaderObfuscator]
|
385
|
+
def set_header_obfuscator(header_obfuscator)
|
386
|
+
@connection.set_header_obfuscator(header_obfuscator)
|
387
|
+
end
|
224
388
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
389
|
+
# Enables logging outgoing requests and incoming responses by registering the _communicator_logger_.
|
390
|
+
# Note that only one logger can be registered at a time and calling _enable_logging_
|
391
|
+
# a second time will override the old logger instance with the new one.
|
392
|
+
#
|
393
|
+
# @param communicator_logger [OnlinePayments::SDK::Logging::CommunicatorLogger] The communicator logger the requests and responses are logged to
|
394
|
+
def enable_logging(communicator_logger)
|
395
|
+
@connection.enable_logging(communicator_logger)
|
396
|
+
end
|
230
397
|
|
231
|
-
|
398
|
+
# Disables logging by unregistering any previous logger that might be registered.
|
399
|
+
def disable_logging
|
400
|
+
@connection.disable_logging
|
401
|
+
end
|
232
402
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
# which represent the parameter name and value respectively.
|
239
|
-
def to_absolute_uri(relative_path, request_parameters)
|
240
|
-
raise RuntimeError('api_endpoint should not contain a path') unless @api_endpoint.path.nil? || @api_endpoint.path.empty?
|
241
|
-
|
242
|
-
if @api_endpoint.userinfo || @api_endpoint.query || @api_endpoint.fragment
|
243
|
-
raise RuntimeError, 'api_endpoint should not contain user info, query or fragment'
|
403
|
+
# Frees networking resources by closing the underlying network connections.
|
404
|
+
# After calling _close_, any use of the _get_, _delete_, _post_ and _put_ methods will not function
|
405
|
+
# and likely result in an error.
|
406
|
+
def close
|
407
|
+
@connection.close
|
244
408
|
end
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
409
|
+
|
410
|
+
attr_reader :marshaller
|
411
|
+
|
412
|
+
protected
|
413
|
+
|
414
|
+
# Constructs a full URL using the base URL and the given relative path and request_parameters.
|
415
|
+
# The returned URL is a *URI* object.
|
416
|
+
#
|
417
|
+
# @param relative_path [String] The relative path of the URL.
|
418
|
+
# @param request_parameters [Array<OnlinePayments::SDK::Communication::RequestParam>] A list of request parameters that each have #name and #value
|
419
|
+
# which represent the parameter name and value respectively.
|
420
|
+
def to_absolute_uri(relative_path, request_parameters)
|
421
|
+
absolute_path = relative_path.start_with?('/') ? relative_path : '/' + relative_path
|
422
|
+
uri = URI::HTTP.new(@api_endpoint.scheme, nil, @api_endpoint.host,
|
423
|
+
@api_endpoint.port, nil, absolute_path, nil, nil, nil)
|
424
|
+
unless request_parameters.nil?
|
425
|
+
request_parameters.each do |nvp|
|
426
|
+
parameters = URI.decode_www_form(uri.query || '') << [nvp.name, nvp.value]
|
427
|
+
uri.query = URI.encode_www_form(parameters)
|
428
|
+
end
|
429
|
+
end
|
430
|
+
uri
|
251
431
|
end
|
252
|
-
uri
|
253
|
-
end
|
254
432
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
433
|
+
# Adds several standard headers to the http headers.
|
434
|
+
# This method will add the 'Date' and 'Authorization' header;
|
435
|
+
# the 'X-GCS-Idempotence-Key' header will also be added if an idempotence context is given
|
436
|
+
#
|
437
|
+
# @param http_method [String] 'GET', 'DELETE', 'POST' or 'PUT' depending on the HTTP method being used
|
438
|
+
# @param uri [URI::HTTP] The full URI to the Online Payments platform,
|
439
|
+
# including the relative path and request parameters.
|
440
|
+
# @param request_headers [Array<OnlinePayments::SDK::Communication::RequestHeader>] List of request headers in which which new headers will be added
|
441
|
+
# @param context [OnlinePayments::SDK::CallContext, nil] optional call context.
|
442
|
+
def add_generic_headers(http_method, uri, request_headers, context = nil)
|
443
|
+
request_headers.concat(@metadata_provider.metadata_headers)
|
444
|
+
request_headers.push(Communication::RequestHeader.new('Date', get_header_date_string))
|
445
|
+
if !context.nil? && !context.idempotence_key.nil?
|
446
|
+
request_headers.push(Communication::RequestHeader.new('X-GCS-Idempotence-Key', context.idempotence_key))
|
447
|
+
end
|
448
|
+
authorization = @authenticator.get_authorization(http_method, uri, request_headers)
|
449
|
+
request_headers.push(Communication::RequestHeader.new('Authorization', authorization))
|
270
450
|
end
|
271
|
-
authentication_signature = @authenticator.create_simple_authentication_signature(http_method, uri, request_headers)
|
272
|
-
request_headers.push(RequestHeader.new('Authorization', authentication_signature))
|
273
|
-
end
|
274
451
|
|
275
|
-
|
276
|
-
|
277
|
-
|
452
|
+
def get_header_date_string
|
453
|
+
Time.now.utc.strftime('%a, %d %b %Y %H:%M:%S GMT')
|
454
|
+
end
|
278
455
|
|
279
|
-
|
280
|
-
|
456
|
+
def process_response(body, status, headers, response_type, request_path, context)
|
457
|
+
update_context(headers, context) unless context.nil?
|
281
458
|
|
282
|
-
|
283
|
-
|
284
|
-
|
459
|
+
throw_exception_if_necessary(body, status, headers, request_path)
|
460
|
+
@marshaller.unmarshal(body, response_type)
|
461
|
+
end
|
285
462
|
|
286
|
-
|
287
|
-
|
288
|
-
end
|
463
|
+
def process_binary_response(status, body, headers, context)
|
464
|
+
update_context(response.headers, context) unless context.nil?
|
289
465
|
|
290
|
-
|
291
|
-
|
292
|
-
|
466
|
+
if status < 400
|
467
|
+
yield headers, body
|
468
|
+
''
|
469
|
+
else
|
470
|
+
body.read.force_encoding('UTF-8')
|
471
|
+
end
|
472
|
+
end
|
293
473
|
|
294
|
-
|
295
|
-
|
296
|
-
|
474
|
+
def update_context(headers, context)
|
475
|
+
idempotence_request_timestamp_value = Communication::ResponseHeader.get_header_value(headers, 'X-GCS-Idempotence-Request-Timestamp')
|
476
|
+
if idempotence_request_timestamp_value.nil?
|
477
|
+
context.idempotence_request_timestamp = nil
|
478
|
+
else
|
479
|
+
context.idempotence_request_timestamp = idempotence_request_timestamp_value
|
480
|
+
end
|
481
|
+
idempotence_response_date_time_value = Communication::ResponseHeader.get_header_value(headers, 'IdempotencyResponseDatetime')
|
482
|
+
if idempotence_response_date_time_value.nil?
|
483
|
+
context.idempotence_response_date_time = nil
|
484
|
+
else
|
485
|
+
context.idempotence_response_date_time = DateTime.parse(idempotence_response_date_time_value)
|
486
|
+
end
|
297
487
|
end
|
298
488
|
|
299
|
-
|
300
|
-
|
489
|
+
def throw_exception_if_necessary(body, status_code, headers, request_path)
|
490
|
+
if status_code < 200 || status_code >= 300
|
491
|
+
if !body.nil? && !is_json(headers)
|
492
|
+
cause = Communication::ResponseException.new(status_code, headers, body)
|
493
|
+
if status_code == 404
|
494
|
+
raise Communication::NotFoundException.new(cause, 'The requested resource was not found; invalid path: ' +
|
495
|
+
request_path)
|
496
|
+
else
|
497
|
+
raise Communication::CommunicationException, cause
|
498
|
+
end
|
499
|
+
else
|
500
|
+
raise Communication::ResponseException.new(status_code, headers, body)
|
501
|
+
end
|
502
|
+
end
|
503
|
+
end
|
301
504
|
|
302
|
-
|
505
|
+
private
|
303
506
|
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
507
|
+
def is_json(headers)
|
508
|
+
content_type = Communication::ResponseHeader.get_header_value(headers, 'Content-Type')
|
509
|
+
if content_type.nil? || 'application/json'.casecmp(content_type) == 0 || 'application/problem+json'.casecmp(content_type) == 0
|
510
|
+
return true
|
511
|
+
end
|
512
|
+
content_type = content_type.downcase
|
513
|
+
content_type.start_with?('application/json') || content_type.start_with?('application/problem+json')
|
514
|
+
end
|
308
515
|
end
|
309
516
|
end
|
310
517
|
end
|