postfinancecheckout-ruby-sdk 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +8 -0
- data/LICENSE +201 -0
- data/README.md +137 -0
- data/Rakefile +13 -0
- data/lib/.DS_Store +0 -0
- data/lib/postfinancecheckout-ruby-sdk.rb +392 -0
- data/lib/postfinancecheckout-ruby-sdk/api/account_service_api.rb +368 -0
- data/lib/postfinancecheckout-ruby-sdk/api/application_user_service_api.rb +368 -0
- data/lib/postfinancecheckout-ruby-sdk/api/bank_account_service_api.rb +213 -0
- data/lib/postfinancecheckout-ruby-sdk/api/bank_transaction_service_api.rb +213 -0
- data/lib/postfinancecheckout-ruby-sdk/api/charge_attempt_service_api.rb +213 -0
- data/lib/postfinancecheckout-ruby-sdk/api/charge_bank_transaction_service_api.rb +213 -0
- data/lib/postfinancecheckout-ruby-sdk/api/charge_flow_level_payment_link_service_api.rb +213 -0
- data/lib/postfinancecheckout-ruby-sdk/api/charge_flow_level_service_api.rb +276 -0
- data/lib/postfinancecheckout-ruby-sdk/api/charge_flow_service_api.rb +348 -0
- data/lib/postfinancecheckout-ruby-sdk/api/condition_type_service_api.rb +139 -0
- data/lib/postfinancecheckout-ruby-sdk/api/country_service_api.rb +81 -0
- data/lib/postfinancecheckout-ruby-sdk/api/country_state_service_api.rb +139 -0
- data/lib/postfinancecheckout-ruby-sdk/api/currency_bank_account_service_api.rb +213 -0
- data/lib/postfinancecheckout-ruby-sdk/api/currency_service_api.rb +81 -0
- data/lib/postfinancecheckout-ruby-sdk/api/customer_address_service_api.rb +460 -0
- data/lib/postfinancecheckout-ruby-sdk/api/customer_comment_service_api.rb +522 -0
- data/lib/postfinancecheckout-ruby-sdk/api/customer_service_api.rb +398 -0
- data/lib/postfinancecheckout-ruby-sdk/api/delivery_indication_service_api.rb +337 -0
- data/lib/postfinancecheckout-ruby-sdk/api/document_template_service_api.rb +213 -0
- data/lib/postfinancecheckout-ruby-sdk/api/document_template_type_service_api.rb +139 -0
- data/lib/postfinancecheckout-ruby-sdk/api/external_transfer_bank_transaction_service_api.rb +213 -0
- data/lib/postfinancecheckout-ruby-sdk/api/human_user_service_api.rb +425 -0
- data/lib/postfinancecheckout-ruby-sdk/api/internal_transfer_bank_transaction_service_api.rb +213 -0
- data/lib/postfinancecheckout-ruby-sdk/api/label_description_group_service_api.rb +139 -0
- data/lib/postfinancecheckout-ruby-sdk/api/label_description_service_api.rb +139 -0
- data/lib/postfinancecheckout-ruby-sdk/api/language_service_api.rb +81 -0
- data/lib/postfinancecheckout-ruby-sdk/api/legal_organization_form_service_api.rb +197 -0
- data/lib/postfinancecheckout-ruby-sdk/api/manual_task_service_api.rb +213 -0
- data/lib/postfinancecheckout-ruby-sdk/api/payment_connector_configuration_service_api.rb +213 -0
- data/lib/postfinancecheckout-ruby-sdk/api/payment_connector_service_api.rb +139 -0
- data/lib/postfinancecheckout-ruby-sdk/api/payment_link_service_api.rb +398 -0
- data/lib/postfinancecheckout-ruby-sdk/api/payment_method_brand_service_api.rb +139 -0
- data/lib/postfinancecheckout-ruby-sdk/api/payment_method_configuration_service_api.rb +213 -0
- data/lib/postfinancecheckout-ruby-sdk/api/payment_method_service_api.rb +139 -0
- data/lib/postfinancecheckout-ruby-sdk/api/payment_processor_configuration_service_api.rb +213 -0
- data/lib/postfinancecheckout-ruby-sdk/api/payment_processor_service_api.rb +139 -0
- data/lib/postfinancecheckout-ruby-sdk/api/payment_terminal_service_api.rb +213 -0
- data/lib/postfinancecheckout-ruby-sdk/api/payment_terminal_till_service_api.rb +170 -0
- data/lib/postfinancecheckout-ruby-sdk/api/permission_service_api.rb +139 -0
- data/lib/postfinancecheckout-ruby-sdk/api/refund_bank_transaction_service_api.rb +213 -0
- data/lib/postfinancecheckout-ruby-sdk/api/refund_comment_service_api.rb +464 -0
- data/lib/postfinancecheckout-ruby-sdk/api/refund_recovery_bank_transaction_service_api.rb +213 -0
- data/lib/postfinancecheckout-ruby-sdk/api/refund_service_api.rb +532 -0
- data/lib/postfinancecheckout-ruby-sdk/api/shopify_recurring_order_service_api.rb +274 -0
- data/lib/postfinancecheckout-ruby-sdk/api/shopify_subscriber_service_api.rb +275 -0
- data/lib/postfinancecheckout-ruby-sdk/api/shopify_subscription_product_service_api.rb +337 -0
- data/lib/postfinancecheckout-ruby-sdk/api/shopify_subscription_service_api.rb +466 -0
- data/lib/postfinancecheckout-ruby-sdk/api/shopify_subscription_suspension_service_api.rb +337 -0
- data/lib/postfinancecheckout-ruby-sdk/api/shopify_subscription_version_service_api.rb +213 -0
- data/lib/postfinancecheckout-ruby-sdk/api/shopify_transaction_service_api.rb +213 -0
- data/lib/postfinancecheckout-ruby-sdk/api/space_service_api.rb +368 -0
- data/lib/postfinancecheckout-ruby-sdk/api/static_value_service_api.rb +139 -0
- data/lib/postfinancecheckout-ruby-sdk/api/token_service_api.rb +650 -0
- data/lib/postfinancecheckout-ruby-sdk/api/token_version_service_api.rb +276 -0
- data/lib/postfinancecheckout-ruby-sdk/api/transaction_comment_service_api.rb +464 -0
- data/lib/postfinancecheckout-ruby-sdk/api/transaction_completion_service_api.rb +463 -0
- data/lib/postfinancecheckout-ruby-sdk/api/transaction_iframe_service_api.rb +91 -0
- data/lib/postfinancecheckout-ruby-sdk/api/transaction_invoice_comment_service_api.rb +464 -0
- data/lib/postfinancecheckout-ruby-sdk/api/transaction_invoice_service_api.rb +600 -0
- data/lib/postfinancecheckout-ruby-sdk/api/transaction_lightbox_service_api.rb +91 -0
- data/lib/postfinancecheckout-ruby-sdk/api/transaction_mobile_sdk_service_api.rb +86 -0
- data/lib/postfinancecheckout-ruby-sdk/api/transaction_payment_page_service_api.rb +91 -0
- data/lib/postfinancecheckout-ruby-sdk/api/transaction_service_api.rb +1210 -0
- data/lib/postfinancecheckout-ruby-sdk/api/transaction_terminal_service_api.rb +161 -0
- data/lib/postfinancecheckout-ruby-sdk/api/transaction_void_service_api.rb +339 -0
- data/lib/postfinancecheckout-ruby-sdk/api/user_account_role_service_api.rb +219 -0
- data/lib/postfinancecheckout-ruby-sdk/api/user_space_role_service_api.rb +216 -0
- data/lib/postfinancecheckout-ruby-sdk/api/webhook_listener_service_api.rb +398 -0
- data/lib/postfinancecheckout-ruby-sdk/api/webhook_url_service_api.rb +398 -0
- data/lib/postfinancecheckout-ruby-sdk/api_client.rb +405 -0
- data/lib/postfinancecheckout-ruby-sdk/api_error.rb +43 -0
- data/lib/postfinancecheckout-ruby-sdk/configuration.rb +140 -0
- data/lib/postfinancecheckout-ruby-sdk/models/abstract_account_update.rb +234 -0
- data/lib/postfinancecheckout-ruby-sdk/models/abstract_application_user_update.rb +225 -0
- data/lib/postfinancecheckout-ruby-sdk/models/abstract_customer_active.rb +312 -0
- data/lib/postfinancecheckout-ruby-sdk/models/abstract_customer_address_active.rb +200 -0
- data/lib/postfinancecheckout-ruby-sdk/models/abstract_customer_comment_active.rb +205 -0
- data/lib/postfinancecheckout-ruby-sdk/models/abstract_human_user_update.rb +320 -0
- data/lib/postfinancecheckout-ruby-sdk/models/abstract_payment_link_update.rb +309 -0
- data/lib/postfinancecheckout-ruby-sdk/models/abstract_refund_comment_active.rb +205 -0
- data/lib/postfinancecheckout-ruby-sdk/models/abstract_shopify_subscription_product_update.rb +320 -0
- data/lib/postfinancecheckout-ruby-sdk/models/abstract_space_update.rb +286 -0
- data/lib/postfinancecheckout-ruby-sdk/models/abstract_token_update.rb +270 -0
- data/lib/postfinancecheckout-ruby-sdk/models/abstract_transaction_comment_active.rb +205 -0
- data/lib/postfinancecheckout-ruby-sdk/models/abstract_transaction_invoice_comment_active.rb +205 -0
- data/lib/postfinancecheckout-ruby-sdk/models/abstract_transaction_pending.rb +486 -0
- data/lib/postfinancecheckout-ruby-sdk/models/abstract_webhook_listener_update.rb +237 -0
- data/lib/postfinancecheckout-ruby-sdk/models/abstract_webhook_url_update.rb +249 -0
- data/lib/postfinancecheckout-ruby-sdk/models/account.rb +375 -0
- data/lib/postfinancecheckout-ruby-sdk/models/account_create.rb +260 -0
- data/lib/postfinancecheckout-ruby-sdk/models/account_state.rb +39 -0
- data/lib/postfinancecheckout-ruby-sdk/models/account_type.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/account_update.rb +265 -0
- data/lib/postfinancecheckout-ruby-sdk/models/address.rb +606 -0
- data/lib/postfinancecheckout-ruby-sdk/models/address_create.rb +606 -0
- data/lib/postfinancecheckout-ruby-sdk/models/application_user.rb +286 -0
- data/lib/postfinancecheckout-ruby-sdk/models/application_user_create.rb +241 -0
- data/lib/postfinancecheckout-ruby-sdk/models/application_user_create_with_mac_key.rb +296 -0
- data/lib/postfinancecheckout-ruby-sdk/models/application_user_update.rb +256 -0
- data/lib/postfinancecheckout-ruby-sdk/models/bank_account.rb +291 -0
- data/lib/postfinancecheckout-ruby-sdk/models/bank_account_environment.rb +35 -0
- data/lib/postfinancecheckout-ruby-sdk/models/bank_account_state.rb +37 -0
- data/lib/postfinancecheckout-ruby-sdk/models/bank_account_type.rb +227 -0
- data/lib/postfinancecheckout-ruby-sdk/models/bank_transaction.rb +387 -0
- data/lib/postfinancecheckout-ruby-sdk/models/bank_transaction_flow_direction.rb +35 -0
- data/lib/postfinancecheckout-ruby-sdk/models/bank_transaction_source.rb +215 -0
- data/lib/postfinancecheckout-ruby-sdk/models/bank_transaction_state.rb +35 -0
- data/lib/postfinancecheckout-ruby-sdk/models/bank_transaction_type.rb +215 -0
- data/lib/postfinancecheckout-ruby-sdk/models/charge.rb +331 -0
- data/lib/postfinancecheckout-ruby-sdk/models/charge_attempt.rb +468 -0
- data/lib/postfinancecheckout-ruby-sdk/models/charge_attempt_environment.rb +35 -0
- data/lib/postfinancecheckout-ruby-sdk/models/charge_attempt_state.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/charge_bank_transaction.rb +291 -0
- data/lib/postfinancecheckout-ruby-sdk/models/charge_flow.rb +263 -0
- data/lib/postfinancecheckout-ruby-sdk/models/charge_flow_level.rb +311 -0
- data/lib/postfinancecheckout-ruby-sdk/models/charge_flow_level_configuration.rb +296 -0
- data/lib/postfinancecheckout-ruby-sdk/models/charge_flow_level_configuration_type.rb +227 -0
- data/lib/postfinancecheckout-ruby-sdk/models/charge_flow_level_payment_link.rb +231 -0
- data/lib/postfinancecheckout-ruby-sdk/models/charge_flow_level_state.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/charge_state.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/charge_type.rb +37 -0
- data/lib/postfinancecheckout-ruby-sdk/models/client_error.rb +231 -0
- data/lib/postfinancecheckout-ruby-sdk/models/client_error_type.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/completion_line_item.rb +226 -0
- data/lib/postfinancecheckout-ruby-sdk/models/completion_line_item_create.rb +245 -0
- data/lib/postfinancecheckout-ruby-sdk/models/condition.rb +266 -0
- data/lib/postfinancecheckout-ruby-sdk/models/condition_type.rb +215 -0
- data/lib/postfinancecheckout-ruby-sdk/models/connector_invocation.rb +271 -0
- data/lib/postfinancecheckout-ruby-sdk/models/connector_invocation_stage.rb +37 -0
- data/lib/postfinancecheckout-ruby-sdk/models/creation_entity_state.rb +38 -0
- data/lib/postfinancecheckout-ruby-sdk/models/criteria_operator.rb +45 -0
- data/lib/postfinancecheckout-ruby-sdk/models/currency_bank_account.rb +241 -0
- data/lib/postfinancecheckout-ruby-sdk/models/customer.rb +353 -0
- data/lib/postfinancecheckout-ruby-sdk/models/customer_active.rb +343 -0
- data/lib/postfinancecheckout-ruby-sdk/models/customer_address.rb +261 -0
- data/lib/postfinancecheckout-ruby-sdk/models/customer_address_active.rb +231 -0
- data/lib/postfinancecheckout-ruby-sdk/models/customer_address_create.rb +216 -0
- data/lib/postfinancecheckout-ruby-sdk/models/customer_address_type.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/customer_comment.rb +296 -0
- data/lib/postfinancecheckout-ruby-sdk/models/customer_comment_active.rb +236 -0
- data/lib/postfinancecheckout-ruby-sdk/models/customer_comment_create.rb +221 -0
- data/lib/postfinancecheckout-ruby-sdk/models/customer_create.rb +313 -0
- data/lib/postfinancecheckout-ruby-sdk/models/customer_postal_address.rb +606 -0
- data/lib/postfinancecheckout-ruby-sdk/models/customer_postal_address_create.rb +606 -0
- data/lib/postfinancecheckout-ruby-sdk/models/customers_presence.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/data_collection_type.rb +35 -0
- data/lib/postfinancecheckout-ruby-sdk/models/database_translated_string.rb +215 -0
- data/lib/postfinancecheckout-ruby-sdk/models/database_translated_string_item.rb +226 -0
- data/lib/postfinancecheckout-ruby-sdk/models/delivery_indication.rb +321 -0
- data/lib/postfinancecheckout-ruby-sdk/models/delivery_indication_decision_reason.rb +215 -0
- data/lib/postfinancecheckout-ruby-sdk/models/delivery_indication_state.rb +37 -0
- data/lib/postfinancecheckout-ruby-sdk/models/document_template.rb +306 -0
- data/lib/postfinancecheckout-ruby-sdk/models/document_template_type.rb +235 -0
- data/lib/postfinancecheckout-ruby-sdk/models/document_template_type_group.rb +203 -0
- data/lib/postfinancecheckout-ruby-sdk/models/entity_export_request.rb +208 -0
- data/lib/postfinancecheckout-ruby-sdk/models/entity_query.rb +233 -0
- data/lib/postfinancecheckout-ruby-sdk/models/entity_query_filter.rb +238 -0
- data/lib/postfinancecheckout-ruby-sdk/models/entity_query_filter_type.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/entity_query_order_by.rb +211 -0
- data/lib/postfinancecheckout-ruby-sdk/models/entity_query_order_by_type.rb +35 -0
- data/lib/postfinancecheckout-ruby-sdk/models/environment.rb +35 -0
- data/lib/postfinancecheckout-ruby-sdk/models/external_transfer_bank_transaction.rb +251 -0
- data/lib/postfinancecheckout-ruby-sdk/models/failure_category.rb +38 -0
- data/lib/postfinancecheckout-ruby-sdk/models/failure_reason.rb +237 -0
- data/lib/postfinancecheckout-ruby-sdk/models/feature.rb +277 -0
- data/lib/postfinancecheckout-ruby-sdk/models/feature_category.rb +225 -0
- data/lib/postfinancecheckout-ruby-sdk/models/gender.rb +35 -0
- data/lib/postfinancecheckout-ruby-sdk/models/human_user.rb +361 -0
- data/lib/postfinancecheckout-ruby-sdk/models/human_user_create.rb +331 -0
- data/lib/postfinancecheckout-ruby-sdk/models/human_user_update.rb +351 -0
- data/lib/postfinancecheckout-ruby-sdk/models/internal_transfer_bank_transaction.rb +231 -0
- data/lib/postfinancecheckout-ruby-sdk/models/label.rb +231 -0
- data/lib/postfinancecheckout-ruby-sdk/models/label_descriptor.rb +267 -0
- data/lib/postfinancecheckout-ruby-sdk/models/label_descriptor_category.rb +35 -0
- data/lib/postfinancecheckout-ruby-sdk/models/label_descriptor_group.rb +225 -0
- data/lib/postfinancecheckout-ruby-sdk/models/label_descriptor_type.rb +215 -0
- data/lib/postfinancecheckout-ruby-sdk/models/legal_organization_form.rb +235 -0
- data/lib/postfinancecheckout-ruby-sdk/models/line_item.rb +449 -0
- data/lib/postfinancecheckout-ruby-sdk/models/line_item_attribute.rb +231 -0
- data/lib/postfinancecheckout-ruby-sdk/models/line_item_attribute_create.rb +249 -0
- data/lib/postfinancecheckout-ruby-sdk/models/line_item_create.rb +372 -0
- data/lib/postfinancecheckout-ruby-sdk/models/line_item_reduction.rb +226 -0
- data/lib/postfinancecheckout-ruby-sdk/models/line_item_reduction_create.rb +245 -0
- data/lib/postfinancecheckout-ruby-sdk/models/line_item_type.rb +37 -0
- data/lib/postfinancecheckout-ruby-sdk/models/localized_string.rb +211 -0
- data/lib/postfinancecheckout-ruby-sdk/models/manual_task.rb +283 -0
- data/lib/postfinancecheckout-ruby-sdk/models/manual_task_action.rb +223 -0
- data/lib/postfinancecheckout-ruby-sdk/models/manual_task_action_style.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/manual_task_state.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/manual_task_type.rb +227 -0
- data/lib/postfinancecheckout-ruby-sdk/models/one_click_payment_mode.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_adjustment.rb +231 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_adjustment_type.rb +215 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_connector.rb +321 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_connector_configuration.rb +342 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_connector_feature.rb +211 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_contract.rb +331 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_contract_state.rb +38 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_contract_type.rb +225 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_information_hash.rb +211 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_information_hash_type.rb +203 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_link.rb +390 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_link_active.rb +350 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_link_address_handling_mode.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_link_create.rb +345 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_link_protection_mode.rb +35 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_link_update.rb +340 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_method.rb +261 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_method_brand.rb +245 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_method_configuration.rb +370 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_primary_risk_taker.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_processor.rb +271 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_processor_configuration.rb +276 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_terminal.rb +306 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_terminal_address.rb +396 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_terminal_configuration.rb +266 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_terminal_configuration_state.rb +37 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_terminal_configuration_version.rb +323 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_terminal_configuration_version_state.rb +38 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_terminal_location.rb +266 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_terminal_location_state.rb +37 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_terminal_location_version.rb +281 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_terminal_location_version_state.rb +38 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_terminal_receipt_type.rb +215 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_terminal_state.rb +38 -0
- data/lib/postfinancecheckout-ruby-sdk/models/payment_terminal_type.rb +215 -0
- data/lib/postfinancecheckout-ruby-sdk/models/permission.rb +299 -0
- data/lib/postfinancecheckout-ruby-sdk/models/refund.rb +567 -0
- data/lib/postfinancecheckout-ruby-sdk/models/refund_bank_transaction.rb +281 -0
- data/lib/postfinancecheckout-ruby-sdk/models/refund_comment.rb +296 -0
- data/lib/postfinancecheckout-ruby-sdk/models/refund_comment_active.rb +236 -0
- data/lib/postfinancecheckout-ruby-sdk/models/refund_comment_create.rb +221 -0
- data/lib/postfinancecheckout-ruby-sdk/models/refund_create.rb +306 -0
- data/lib/postfinancecheckout-ruby-sdk/models/refund_recovery_bank_transaction.rb +293 -0
- data/lib/postfinancecheckout-ruby-sdk/models/refund_state.rb +39 -0
- data/lib/postfinancecheckout-ruby-sdk/models/refund_type.rb +37 -0
- data/lib/postfinancecheckout-ruby-sdk/models/rendered_document.rb +223 -0
- data/lib/postfinancecheckout-ruby-sdk/models/rendered_terminal_receipt.rb +223 -0
- data/lib/postfinancecheckout-ruby-sdk/models/resource_path.rb +275 -0
- data/lib/postfinancecheckout-ruby-sdk/models/resource_state.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/rest_address_format.rb +227 -0
- data/lib/postfinancecheckout-ruby-sdk/models/rest_address_format_field.rb +43 -0
- data/lib/postfinancecheckout-ruby-sdk/models/rest_country.rb +243 -0
- data/lib/postfinancecheckout-ruby-sdk/models/rest_country_state.rb +221 -0
- data/lib/postfinancecheckout-ruby-sdk/models/rest_currency.rb +211 -0
- data/lib/postfinancecheckout-ruby-sdk/models/rest_language.rb +241 -0
- data/lib/postfinancecheckout-ruby-sdk/models/role.rb +263 -0
- data/lib/postfinancecheckout-ruby-sdk/models/role_state.rb +37 -0
- data/lib/postfinancecheckout-ruby-sdk/models/sales_channel.rb +245 -0
- data/lib/postfinancecheckout-ruby-sdk/models/scope.rb +350 -0
- data/lib/postfinancecheckout-ruby-sdk/models/server_error.rb +211 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_additional_line_item_data.rb +35 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_integration.rb +470 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_integration_payment_app_version.rb +34 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_integration_subscription_app_version.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_recurring_order.rb +351 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_recurring_order_state.rb +39 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_recurring_order_update_request.rb +201 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscriber.rb +281 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscriber_active.rb +241 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscriber_creation.rb +216 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscriber_state.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription.rb +375 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_address.rb +546 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_address_create.rb +546 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_billing_interval_unit.rb +39 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_creation_request.rb +363 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_model_billing_configuration.rb +271 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_model_item.rb +233 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_model_tax_line.rb +201 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_product.rb +471 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_product_create.rb +366 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_product_pricing_option.rb +38 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_product_state.rb +39 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_product_update.rb +351 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_state.rb +39 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_suspension.rb +311 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_suspension_create.rb +226 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_suspension_initiator.rb +35 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_suspension_state.rb +35 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_suspension_type.rb +35 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_update_addresses_request.rb +211 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_update_request.rb +233 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_version.rb +463 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_version_item.rb +233 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_version_item_price_strategy.rb +35 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_version_state.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_subscription_weekday.rb +40 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_tax_line.rb +231 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_transaction.rb +301 -0
- data/lib/postfinancecheckout-ruby-sdk/models/shopify_transaction_state.rb +38 -0
- data/lib/postfinancecheckout-ruby-sdk/models/space.rb +407 -0
- data/lib/postfinancecheckout-ruby-sdk/models/space_address.rb +416 -0
- data/lib/postfinancecheckout-ruby-sdk/models/space_address_create.rb +416 -0
- data/lib/postfinancecheckout-ruby-sdk/models/space_create.rb +302 -0
- data/lib/postfinancecheckout-ruby-sdk/models/space_update.rb +317 -0
- data/lib/postfinancecheckout-ruby-sdk/models/space_view.rb +275 -0
- data/lib/postfinancecheckout-ruby-sdk/models/static_value.rb +227 -0
- data/lib/postfinancecheckout-ruby-sdk/models/tax.rb +225 -0
- data/lib/postfinancecheckout-ruby-sdk/models/tax_create.rb +239 -0
- data/lib/postfinancecheckout-ruby-sdk/models/tenant_database.rb +226 -0
- data/lib/postfinancecheckout-ruby-sdk/models/terminal_receipt_fetch_request.rb +221 -0
- data/lib/postfinancecheckout-ruby-sdk/models/terminal_receipt_format.rb +35 -0
- data/lib/postfinancecheckout-ruby-sdk/models/token.rb +341 -0
- data/lib/postfinancecheckout-ruby-sdk/models/token_create.rb +296 -0
- data/lib/postfinancecheckout-ruby-sdk/models/token_update.rb +301 -0
- data/lib/postfinancecheckout-ruby-sdk/models/token_version.rb +445 -0
- data/lib/postfinancecheckout-ruby-sdk/models/token_version_state.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/token_version_type.rb +225 -0
- data/lib/postfinancecheckout-ruby-sdk/models/tokenization_mode.rb +37 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction.rb +1011 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_aware_entity.rb +211 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_comment.rb +296 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_comment_active.rb +236 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_comment_create.rb +221 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_completion.rb +528 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_completion_behavior.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_completion_mode.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_completion_request.rb +291 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_completion_state.rb +38 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_create.rb +596 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_environment_selection_strategy.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_group.rb +276 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_group_state.rb +36 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_invoice.rb +452 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_invoice_comment.rb +296 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_invoice_comment_active.rb +236 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_invoice_comment_create.rb +221 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_invoice_replacement.rb +296 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_invoice_state.rb +40 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_line_item_update_request.rb +208 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_line_item_version.rb +313 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_pending.rb +517 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_state.rb +43 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_user_interface_type.rb +38 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_void.rb +373 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_void_mode.rb +35 -0
- data/lib/postfinancecheckout-ruby-sdk/models/transaction_void_state.rb +37 -0
- data/lib/postfinancecheckout-ruby-sdk/models/two_factor_authentication_type.rb +235 -0
- data/lib/postfinancecheckout-ruby-sdk/models/user.rb +241 -0
- data/lib/postfinancecheckout-ruby-sdk/models/user_account_role.rb +241 -0
- data/lib/postfinancecheckout-ruby-sdk/models/user_space_role.rb +231 -0
- data/lib/postfinancecheckout-ruby-sdk/models/user_type.rb +38 -0
- data/lib/postfinancecheckout-ruby-sdk/models/webhook_identity.rb +256 -0
- data/lib/postfinancecheckout-ruby-sdk/models/webhook_listener.rb +308 -0
- data/lib/postfinancecheckout-ruby-sdk/models/webhook_listener_create.rb +278 -0
- data/lib/postfinancecheckout-ruby-sdk/models/webhook_listener_entity.rb +213 -0
- data/lib/postfinancecheckout-ruby-sdk/models/webhook_listener_update.rb +268 -0
- data/lib/postfinancecheckout-ruby-sdk/models/webhook_url.rb +300 -0
- data/lib/postfinancecheckout-ruby-sdk/models/webhook_url_create.rb +250 -0
- data/lib/postfinancecheckout-ruby-sdk/models/webhook_url_update.rb +280 -0
- data/lib/postfinancecheckout-ruby-sdk/version.rb +20 -0
- data/postfinancecheckout-ruby-sdk.gemspec +44 -0
- data/test/condition_type_service_test.rb +22 -0
- data/test/transaction_create_service_test.rb +89 -0
- data/test/transaction_payment_page_service_test.rb +91 -0
- metadata +469 -0
@@ -0,0 +1,398 @@
|
|
1
|
+
=begin
|
2
|
+
The PostFinance Checkout API allows an easy interaction with the PostFinance Checkout web service.
|
3
|
+
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
you may not use this file except in compliance with the License.
|
6
|
+
You may obtain a copy of the License at
|
7
|
+
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
See the License for the specific language governing permissions and
|
14
|
+
limitations under the License.
|
15
|
+
|
16
|
+
=end
|
17
|
+
|
18
|
+
require "uri"
|
19
|
+
|
20
|
+
module PostFinanceCheckout
|
21
|
+
class WebhookUrlService
|
22
|
+
attr_accessor :api_client
|
23
|
+
|
24
|
+
def initialize(api_client = ApiClient.default)
|
25
|
+
@api_client = api_client
|
26
|
+
end
|
27
|
+
|
28
|
+
# Count
|
29
|
+
# Counts the number of items in the database as restricted by the given filter.
|
30
|
+
# @param space_id
|
31
|
+
# @param [Hash] opts the optional parameters
|
32
|
+
# @option opts [EntityQueryFilter] :filter The filter which restricts the entities which are used to calculate the count.
|
33
|
+
# @return [Integer]
|
34
|
+
def count(space_id, opts = {})
|
35
|
+
data, _status_code, _headers = count_with_http_info(space_id, opts)
|
36
|
+
return data
|
37
|
+
end
|
38
|
+
|
39
|
+
# Count
|
40
|
+
# Counts the number of items in the database as restricted by the given filter.
|
41
|
+
# @param space_id
|
42
|
+
# @param [Hash] opts the optional parameters
|
43
|
+
# @option opts [EntityQueryFilter] :filter The filter which restricts the entities which are used to calculate the count.
|
44
|
+
# @return [Array<(Integer, Fixnum, Hash)>] Integer data, response status code and response headers
|
45
|
+
def count_with_http_info(space_id, opts = {})
|
46
|
+
if @api_client.config.debugging
|
47
|
+
@api_client.config.logger.debug "Calling API: WebhookUrlService.count ..."
|
48
|
+
end
|
49
|
+
# verify the required parameter 'space_id' is set
|
50
|
+
fail ArgumentError, "Missing the required parameter 'space_id' when calling WebhookUrlService.count" if space_id.nil?
|
51
|
+
# resource path
|
52
|
+
local_var_path = "/webhook-url/count".sub('{format}','json')
|
53
|
+
|
54
|
+
# query parameters
|
55
|
+
query_params = {}
|
56
|
+
query_params[:'spaceId'] = space_id
|
57
|
+
|
58
|
+
# header parameters
|
59
|
+
header_params = {}
|
60
|
+
|
61
|
+
# HTTP header 'Accept' (if needed)
|
62
|
+
local_header_accept = ['application/json;charset=utf-8']
|
63
|
+
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
64
|
+
|
65
|
+
# HTTP header 'Content-Type'
|
66
|
+
local_header_content_type = ['application/json;charset=utf-8']
|
67
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
68
|
+
|
69
|
+
# form parameters
|
70
|
+
form_params = {}
|
71
|
+
|
72
|
+
# http body (model)
|
73
|
+
post_body = @api_client.object_to_http_body(opts[:'filter'])
|
74
|
+
auth_names = []
|
75
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
76
|
+
:header_params => header_params,
|
77
|
+
:query_params => query_params,
|
78
|
+
:form_params => form_params,
|
79
|
+
:body => post_body,
|
80
|
+
:auth_names => auth_names,
|
81
|
+
:return_type => 'Integer')
|
82
|
+
if @api_client.config.debugging
|
83
|
+
@api_client.config.logger.debug "API called: WebhookUrlService#count\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
84
|
+
end
|
85
|
+
return data, status_code, headers
|
86
|
+
end
|
87
|
+
|
88
|
+
# Create
|
89
|
+
# Creates the entity with the given properties.
|
90
|
+
# @param space_id
|
91
|
+
# @param entity The webhook url object with the properties which should be created.
|
92
|
+
# @param [Hash] opts the optional parameters
|
93
|
+
# @return [WebhookUrl]
|
94
|
+
def create(space_id, entity, opts = {})
|
95
|
+
data, _status_code, _headers = create_with_http_info(space_id, entity, opts)
|
96
|
+
return data
|
97
|
+
end
|
98
|
+
|
99
|
+
# Create
|
100
|
+
# Creates the entity with the given properties.
|
101
|
+
# @param space_id
|
102
|
+
# @param entity The webhook url object with the properties which should be created.
|
103
|
+
# @param [Hash] opts the optional parameters
|
104
|
+
# @return [Array<(WebhookUrl, Fixnum, Hash)>] WebhookUrl data, response status code and response headers
|
105
|
+
def create_with_http_info(space_id, entity, opts = {})
|
106
|
+
if @api_client.config.debugging
|
107
|
+
@api_client.config.logger.debug "Calling API: WebhookUrlService.create ..."
|
108
|
+
end
|
109
|
+
# verify the required parameter 'space_id' is set
|
110
|
+
fail ArgumentError, "Missing the required parameter 'space_id' when calling WebhookUrlService.create" if space_id.nil?
|
111
|
+
# verify the required parameter 'entity' is set
|
112
|
+
fail ArgumentError, "Missing the required parameter 'entity' when calling WebhookUrlService.create" if entity.nil?
|
113
|
+
# resource path
|
114
|
+
local_var_path = "/webhook-url/create".sub('{format}','json')
|
115
|
+
|
116
|
+
# query parameters
|
117
|
+
query_params = {}
|
118
|
+
query_params[:'spaceId'] = space_id
|
119
|
+
|
120
|
+
# header parameters
|
121
|
+
header_params = {}
|
122
|
+
|
123
|
+
# HTTP header 'Accept' (if needed)
|
124
|
+
local_header_accept = ['application/json;charset=utf-8']
|
125
|
+
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
126
|
+
|
127
|
+
# HTTP header 'Content-Type'
|
128
|
+
local_header_content_type = ['application/json;charset=utf-8']
|
129
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
130
|
+
|
131
|
+
# form parameters
|
132
|
+
form_params = {}
|
133
|
+
|
134
|
+
# http body (model)
|
135
|
+
post_body = @api_client.object_to_http_body(entity)
|
136
|
+
auth_names = []
|
137
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
138
|
+
:header_params => header_params,
|
139
|
+
:query_params => query_params,
|
140
|
+
:form_params => form_params,
|
141
|
+
:body => post_body,
|
142
|
+
:auth_names => auth_names,
|
143
|
+
:return_type => 'WebhookUrl')
|
144
|
+
if @api_client.config.debugging
|
145
|
+
@api_client.config.logger.debug "API called: WebhookUrlService#create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
146
|
+
end
|
147
|
+
return data, status_code, headers
|
148
|
+
end
|
149
|
+
|
150
|
+
# Delete
|
151
|
+
# Deletes the entity with the given id.
|
152
|
+
# @param space_id
|
153
|
+
# @param id
|
154
|
+
# @param [Hash] opts the optional parameters
|
155
|
+
# @return [nil]
|
156
|
+
def delete(space_id, id, opts = {})
|
157
|
+
delete_with_http_info(space_id, id, opts)
|
158
|
+
return nil
|
159
|
+
end
|
160
|
+
|
161
|
+
# Delete
|
162
|
+
# Deletes the entity with the given id.
|
163
|
+
# @param space_id
|
164
|
+
# @param id
|
165
|
+
# @param [Hash] opts the optional parameters
|
166
|
+
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
|
167
|
+
def delete_with_http_info(space_id, id, opts = {})
|
168
|
+
if @api_client.config.debugging
|
169
|
+
@api_client.config.logger.debug "Calling API: WebhookUrlService.delete ..."
|
170
|
+
end
|
171
|
+
# verify the required parameter 'space_id' is set
|
172
|
+
fail ArgumentError, "Missing the required parameter 'space_id' when calling WebhookUrlService.delete" if space_id.nil?
|
173
|
+
# verify the required parameter 'id' is set
|
174
|
+
fail ArgumentError, "Missing the required parameter 'id' when calling WebhookUrlService.delete" if id.nil?
|
175
|
+
# resource path
|
176
|
+
local_var_path = "/webhook-url/delete".sub('{format}','json')
|
177
|
+
|
178
|
+
# query parameters
|
179
|
+
query_params = {}
|
180
|
+
query_params[:'spaceId'] = space_id
|
181
|
+
|
182
|
+
# header parameters
|
183
|
+
header_params = {}
|
184
|
+
|
185
|
+
# HTTP header 'Accept' (if needed)
|
186
|
+
local_header_accept = ['application/json;charset=utf-8']
|
187
|
+
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
188
|
+
|
189
|
+
# HTTP header 'Content-Type'
|
190
|
+
local_header_content_type = ['application/json;charset=utf-8']
|
191
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
192
|
+
|
193
|
+
# form parameters
|
194
|
+
form_params = {}
|
195
|
+
|
196
|
+
# http body (model)
|
197
|
+
post_body = @api_client.object_to_http_body(id)
|
198
|
+
auth_names = []
|
199
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
200
|
+
:header_params => header_params,
|
201
|
+
:query_params => query_params,
|
202
|
+
:form_params => form_params,
|
203
|
+
:body => post_body,
|
204
|
+
:auth_names => auth_names)
|
205
|
+
if @api_client.config.debugging
|
206
|
+
@api_client.config.logger.debug "API called: WebhookUrlService#delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
207
|
+
end
|
208
|
+
return data, status_code, headers
|
209
|
+
end
|
210
|
+
|
211
|
+
# Read
|
212
|
+
# Reads the entity with the given 'id' and returns it.
|
213
|
+
# @param space_id
|
214
|
+
# @param id The id of the webhook url which should be returned.
|
215
|
+
# @param [Hash] opts the optional parameters
|
216
|
+
# @return [WebhookUrl]
|
217
|
+
def read(space_id, id, opts = {})
|
218
|
+
data, _status_code, _headers = read_with_http_info(space_id, id, opts)
|
219
|
+
return data
|
220
|
+
end
|
221
|
+
|
222
|
+
# Read
|
223
|
+
# Reads the entity with the given 'id' and returns it.
|
224
|
+
# @param space_id
|
225
|
+
# @param id The id of the webhook url which should be returned.
|
226
|
+
# @param [Hash] opts the optional parameters
|
227
|
+
# @return [Array<(WebhookUrl, Fixnum, Hash)>] WebhookUrl data, response status code and response headers
|
228
|
+
def read_with_http_info(space_id, id, opts = {})
|
229
|
+
if @api_client.config.debugging
|
230
|
+
@api_client.config.logger.debug "Calling API: WebhookUrlService.read ..."
|
231
|
+
end
|
232
|
+
# verify the required parameter 'space_id' is set
|
233
|
+
fail ArgumentError, "Missing the required parameter 'space_id' when calling WebhookUrlService.read" if space_id.nil?
|
234
|
+
# verify the required parameter 'id' is set
|
235
|
+
fail ArgumentError, "Missing the required parameter 'id' when calling WebhookUrlService.read" if id.nil?
|
236
|
+
# resource path
|
237
|
+
local_var_path = "/webhook-url/read".sub('{format}','json')
|
238
|
+
|
239
|
+
# query parameters
|
240
|
+
query_params = {}
|
241
|
+
query_params[:'spaceId'] = space_id
|
242
|
+
query_params[:'id'] = id
|
243
|
+
|
244
|
+
# header parameters
|
245
|
+
header_params = {}
|
246
|
+
|
247
|
+
# HTTP header 'Accept' (if needed)
|
248
|
+
local_header_accept = ['application/json;charset=utf-8']
|
249
|
+
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
250
|
+
|
251
|
+
# HTTP header 'Content-Type'
|
252
|
+
local_header_content_type = ['*/*']
|
253
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
254
|
+
|
255
|
+
# form parameters
|
256
|
+
form_params = {}
|
257
|
+
|
258
|
+
# http body (model)
|
259
|
+
post_body = nil
|
260
|
+
auth_names = []
|
261
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
|
262
|
+
:header_params => header_params,
|
263
|
+
:query_params => query_params,
|
264
|
+
:form_params => form_params,
|
265
|
+
:body => post_body,
|
266
|
+
:auth_names => auth_names,
|
267
|
+
:return_type => 'WebhookUrl')
|
268
|
+
if @api_client.config.debugging
|
269
|
+
@api_client.config.logger.debug "API called: WebhookUrlService#read\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
270
|
+
end
|
271
|
+
return data, status_code, headers
|
272
|
+
end
|
273
|
+
|
274
|
+
# Search
|
275
|
+
# Searches for the entities as specified by the given query.
|
276
|
+
# @param space_id
|
277
|
+
# @param query The query restricts the webhook urls which are returned by the search.
|
278
|
+
# @param [Hash] opts the optional parameters
|
279
|
+
# @return [Array<WebhookUrl>]
|
280
|
+
def search(space_id, query, opts = {})
|
281
|
+
data, _status_code, _headers = search_with_http_info(space_id, query, opts)
|
282
|
+
return data
|
283
|
+
end
|
284
|
+
|
285
|
+
# Search
|
286
|
+
# Searches for the entities as specified by the given query.
|
287
|
+
# @param space_id
|
288
|
+
# @param query The query restricts the webhook urls which are returned by the search.
|
289
|
+
# @param [Hash] opts the optional parameters
|
290
|
+
# @return [Array<(Array<WebhookUrl>, Fixnum, Hash)>] Array<WebhookUrl> data, response status code and response headers
|
291
|
+
def search_with_http_info(space_id, query, opts = {})
|
292
|
+
if @api_client.config.debugging
|
293
|
+
@api_client.config.logger.debug "Calling API: WebhookUrlService.search ..."
|
294
|
+
end
|
295
|
+
# verify the required parameter 'space_id' is set
|
296
|
+
fail ArgumentError, "Missing the required parameter 'space_id' when calling WebhookUrlService.search" if space_id.nil?
|
297
|
+
# verify the required parameter 'query' is set
|
298
|
+
fail ArgumentError, "Missing the required parameter 'query' when calling WebhookUrlService.search" if query.nil?
|
299
|
+
# resource path
|
300
|
+
local_var_path = "/webhook-url/search".sub('{format}','json')
|
301
|
+
|
302
|
+
# query parameters
|
303
|
+
query_params = {}
|
304
|
+
query_params[:'spaceId'] = space_id
|
305
|
+
|
306
|
+
# header parameters
|
307
|
+
header_params = {}
|
308
|
+
|
309
|
+
# HTTP header 'Accept' (if needed)
|
310
|
+
local_header_accept = ['application/json;charset=utf-8']
|
311
|
+
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
312
|
+
|
313
|
+
# HTTP header 'Content-Type'
|
314
|
+
local_header_content_type = ['application/json;charset=utf-8']
|
315
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
316
|
+
|
317
|
+
# form parameters
|
318
|
+
form_params = {}
|
319
|
+
|
320
|
+
# http body (model)
|
321
|
+
post_body = @api_client.object_to_http_body(query)
|
322
|
+
auth_names = []
|
323
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
324
|
+
:header_params => header_params,
|
325
|
+
:query_params => query_params,
|
326
|
+
:form_params => form_params,
|
327
|
+
:body => post_body,
|
328
|
+
:auth_names => auth_names,
|
329
|
+
:return_type => 'Array<WebhookUrl>')
|
330
|
+
if @api_client.config.debugging
|
331
|
+
@api_client.config.logger.debug "API called: WebhookUrlService#search\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
332
|
+
end
|
333
|
+
return data, status_code, headers
|
334
|
+
end
|
335
|
+
|
336
|
+
# Update
|
337
|
+
# This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
|
338
|
+
# @param space_id
|
339
|
+
# @param entity The webhook url object with all the properties which should be updated. The id and the version are required properties.
|
340
|
+
# @param [Hash] opts the optional parameters
|
341
|
+
# @return [WebhookUrl]
|
342
|
+
def update(space_id, entity, opts = {})
|
343
|
+
data, _status_code, _headers = update_with_http_info(space_id, entity, opts)
|
344
|
+
return data
|
345
|
+
end
|
346
|
+
|
347
|
+
# Update
|
348
|
+
# This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
|
349
|
+
# @param space_id
|
350
|
+
# @param entity The webhook url object with all the properties which should be updated. The id and the version are required properties.
|
351
|
+
# @param [Hash] opts the optional parameters
|
352
|
+
# @return [Array<(WebhookUrl, Fixnum, Hash)>] WebhookUrl data, response status code and response headers
|
353
|
+
def update_with_http_info(space_id, entity, opts = {})
|
354
|
+
if @api_client.config.debugging
|
355
|
+
@api_client.config.logger.debug "Calling API: WebhookUrlService.update ..."
|
356
|
+
end
|
357
|
+
# verify the required parameter 'space_id' is set
|
358
|
+
fail ArgumentError, "Missing the required parameter 'space_id' when calling WebhookUrlService.update" if space_id.nil?
|
359
|
+
# verify the required parameter 'entity' is set
|
360
|
+
fail ArgumentError, "Missing the required parameter 'entity' when calling WebhookUrlService.update" if entity.nil?
|
361
|
+
# resource path
|
362
|
+
local_var_path = "/webhook-url/update".sub('{format}','json')
|
363
|
+
|
364
|
+
# query parameters
|
365
|
+
query_params = {}
|
366
|
+
query_params[:'spaceId'] = space_id
|
367
|
+
|
368
|
+
# header parameters
|
369
|
+
header_params = {}
|
370
|
+
|
371
|
+
# HTTP header 'Accept' (if needed)
|
372
|
+
local_header_accept = ['application/json;charset=utf-8']
|
373
|
+
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
374
|
+
|
375
|
+
# HTTP header 'Content-Type'
|
376
|
+
local_header_content_type = ['application/json;charset=utf-8']
|
377
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
378
|
+
|
379
|
+
# form parameters
|
380
|
+
form_params = {}
|
381
|
+
|
382
|
+
# http body (model)
|
383
|
+
post_body = @api_client.object_to_http_body(entity)
|
384
|
+
auth_names = []
|
385
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
386
|
+
:header_params => header_params,
|
387
|
+
:query_params => query_params,
|
388
|
+
:form_params => form_params,
|
389
|
+
:body => post_body,
|
390
|
+
:auth_names => auth_names,
|
391
|
+
:return_type => 'WebhookUrl')
|
392
|
+
if @api_client.config.debugging
|
393
|
+
@api_client.config.logger.debug "API called: WebhookUrlService#update\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
394
|
+
end
|
395
|
+
return data, status_code, headers
|
396
|
+
end
|
397
|
+
end
|
398
|
+
end
|
@@ -0,0 +1,405 @@
|
|
1
|
+
=begin
|
2
|
+
The PostFinance Checkout API allows an easy interaction with the PostFinance Checkout web service.
|
3
|
+
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
you may not use this file except in compliance with the License.
|
6
|
+
You may obtain a copy of the License at
|
7
|
+
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
See the License for the specific language governing permissions and
|
14
|
+
limitations under the License.
|
15
|
+
|
16
|
+
=end
|
17
|
+
|
18
|
+
require 'date'
|
19
|
+
require 'json'
|
20
|
+
require 'logger'
|
21
|
+
require 'tempfile'
|
22
|
+
require 'typhoeus'
|
23
|
+
require 'addressable/uri'
|
24
|
+
require 'base64'
|
25
|
+
require 'time'
|
26
|
+
require 'openssl'
|
27
|
+
|
28
|
+
module PostFinanceCheckout
|
29
|
+
class ApiClient
|
30
|
+
# The Configuration object holding settings to be used in the API client.
|
31
|
+
attr_accessor :config
|
32
|
+
|
33
|
+
# Defines the headers to be used in HTTP requests of all API calls by default.
|
34
|
+
#
|
35
|
+
# @return [Hash]
|
36
|
+
attr_accessor :default_headers
|
37
|
+
|
38
|
+
# Initializes the ApiClient
|
39
|
+
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
40
|
+
def initialize(config = Configuration.default)
|
41
|
+
@config = config
|
42
|
+
@user_agent = "Typhoeus"
|
43
|
+
@default_headers = {
|
44
|
+
'Content-Type' => "application/json",
|
45
|
+
'User-Agent' => @user_agent
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.default
|
50
|
+
@@default ||= ApiClient.new
|
51
|
+
end
|
52
|
+
|
53
|
+
# Call an API with given options.
|
54
|
+
#
|
55
|
+
# @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements:
|
56
|
+
# the data deserialized from response body (could be nil), response status code and response headers.
|
57
|
+
def call_api(http_method, path, opts = {})
|
58
|
+
request = build_request(http_method, path, opts)
|
59
|
+
response = request.run
|
60
|
+
|
61
|
+
if @config.debugging
|
62
|
+
@config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
|
63
|
+
end
|
64
|
+
|
65
|
+
unless response.success?
|
66
|
+
if response.timed_out?
|
67
|
+
fail ApiError.new('Connection timed out')
|
68
|
+
elsif response.code == 0
|
69
|
+
# Errors from libcurl will be made visible here
|
70
|
+
fail ApiError.new(:code => 0,
|
71
|
+
:message => response.return_message)
|
72
|
+
else
|
73
|
+
fail ApiError.new(:code => response.code,
|
74
|
+
:response_headers => response.headers.to_h,
|
75
|
+
:response_body => response.body),
|
76
|
+
response.status_message
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
if opts[:return_type]
|
81
|
+
data = deserialize(response, opts[:return_type])
|
82
|
+
else
|
83
|
+
data = nil
|
84
|
+
end
|
85
|
+
return data, response.code, response.headers
|
86
|
+
end
|
87
|
+
|
88
|
+
# Builds the HTTP request
|
89
|
+
#
|
90
|
+
# @param [String] http_method HTTP method/verb (e.g. POST)
|
91
|
+
# @param [String] path URL path (e.g. /account/new)
|
92
|
+
# @option opts [Hash] :header_params Header parameters
|
93
|
+
# @option opts [Hash] :query_params Query parameters
|
94
|
+
# @option opts [Hash] :form_params Query parameters
|
95
|
+
# @option opts [Object] :body HTTP body (JSON/XML)
|
96
|
+
# @return [Typhoeus::Request] A Typhoeus Request
|
97
|
+
def build_request(http_method, path, opts = {})
|
98
|
+
url = build_request_url(path)
|
99
|
+
http_method = http_method.to_sym.downcase
|
100
|
+
|
101
|
+
header_params = @default_headers.merge(opts[:header_params] || {})
|
102
|
+
query_params = opts[:query_params] || {}
|
103
|
+
form_params = opts[:form_params] || {}
|
104
|
+
|
105
|
+
|
106
|
+
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
|
107
|
+
_verify_ssl_host = true
|
108
|
+
|
109
|
+
header_params = header_params.merge(get_authentication_headers(http_method, path, query_params))
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
req_opts = {
|
114
|
+
:method => http_method,
|
115
|
+
:headers => header_params,
|
116
|
+
:params => query_params,
|
117
|
+
:params_encoding => @config.params_encoding,
|
118
|
+
:timeout => @config.timeout,
|
119
|
+
:ssl_verifypeer => true,
|
120
|
+
:ssl_verifyhost => 2,
|
121
|
+
:sslcert => @config.cert_file,
|
122
|
+
:sslkey => @config.key_file,
|
123
|
+
:verbose => @config.debugging
|
124
|
+
}
|
125
|
+
|
126
|
+
req_opts.merge!(multipart: true) if header_params['Content-Type'].start_with? "multipart/"
|
127
|
+
|
128
|
+
# set custom cert, if provided
|
129
|
+
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
|
130
|
+
|
131
|
+
if [:post, :patch, :put, :delete].include?(http_method)
|
132
|
+
req_body = build_request_body(header_params, form_params, opts[:body])
|
133
|
+
req_opts.update :body => req_body
|
134
|
+
if @config.debugging
|
135
|
+
@config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
Typhoeus::Request.new(url, req_opts)
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
# Returns the headers required for the HTTP authentication
|
145
|
+
# @param [String] http_method HTTP method/verb (e.g. POST)
|
146
|
+
# @param [String] path URL path (e.g. /account/new)
|
147
|
+
# @return [Hash] the authentication headers
|
148
|
+
def get_authentication_headers(http_method, path, query)
|
149
|
+
base_url = URI(@config.base_url)
|
150
|
+
completed_path = "#{base_url.path}#{path}"
|
151
|
+
completed_path += "?" + query.map{|k,v| "#{k}=#{v}"}.join('&') unless query.empty?
|
152
|
+
version = "1"
|
153
|
+
timestamp = Time.now.to_i
|
154
|
+
securedData = "#{version}|#{@config.user_id}|#{timestamp}|#{http_method.upcase}|#{completed_path}"
|
155
|
+
{
|
156
|
+
"x-mac-version": version,
|
157
|
+
"x-mac-userid": @config.user_id,
|
158
|
+
"x-mac-timestamp": timestamp,
|
159
|
+
"x-mac-value": calculate_hmac(securedData)
|
160
|
+
}
|
161
|
+
end
|
162
|
+
|
163
|
+
# Returns the calculated sha512 hmac for the given data
|
164
|
+
# @param [String] secured_data to hash
|
165
|
+
# @return [String] the calulated hmac
|
166
|
+
def calculate_hmac(secured_data)
|
167
|
+
decoded_secret = Base64.decode64(@config.authentication_key);
|
168
|
+
digest = OpenSSL::Digest.new('sha512')
|
169
|
+
Base64.strict_encode64(OpenSSL::HMAC.digest(digest, decoded_secret, secured_data)).strip;
|
170
|
+
end
|
171
|
+
|
172
|
+
# Check if the given MIME is a JSON MIME.
|
173
|
+
# JSON MIME examples:
|
174
|
+
# application/json
|
175
|
+
# application/json; charset=UTF8
|
176
|
+
# APPLICATION/JSON
|
177
|
+
# */*
|
178
|
+
# @param [String] mime MIME
|
179
|
+
# @return [Boolean] True if the MIME is application/json
|
180
|
+
def json_mime?(mime)
|
181
|
+
(mime == "*/*") || !(mime =~ /\Aapplication\/json(;.*)?\z/i).nil?
|
182
|
+
end
|
183
|
+
|
184
|
+
# Deserialize the response to the given return type.
|
185
|
+
#
|
186
|
+
# @param [Response] response HTTP response
|
187
|
+
# @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
|
188
|
+
def deserialize(response, return_type)
|
189
|
+
body = response.body
|
190
|
+
return nil if body.nil? || body.empty?
|
191
|
+
|
192
|
+
# return response body directly for String return type
|
193
|
+
return body if return_type == 'String'
|
194
|
+
|
195
|
+
# handle file downloading - save response body into a tmp file and return the File instance
|
196
|
+
return download_file(response) if return_type == 'File'
|
197
|
+
|
198
|
+
# ensuring a default content type
|
199
|
+
content_type = response.headers['Content-Type'] || 'application/json'
|
200
|
+
|
201
|
+
fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
|
202
|
+
|
203
|
+
begin
|
204
|
+
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
|
205
|
+
rescue JSON::ParserError => e
|
206
|
+
if %w(String Date DateTime).include?(return_type)
|
207
|
+
data = body
|
208
|
+
else
|
209
|
+
raise e
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
convert_to_type data, return_type
|
214
|
+
end
|
215
|
+
|
216
|
+
# Convert data to the given return type.
|
217
|
+
# @param [Object] data Data to be converted
|
218
|
+
# @param [String] return_type Return type
|
219
|
+
# @return [Mixed] Data in a particular type
|
220
|
+
def convert_to_type(data, return_type)
|
221
|
+
return nil if data.nil?
|
222
|
+
case return_type
|
223
|
+
when 'String'
|
224
|
+
data.to_s
|
225
|
+
when 'Integer'
|
226
|
+
data.to_i
|
227
|
+
when 'Float'
|
228
|
+
data.to_f
|
229
|
+
when 'BOOLEAN'
|
230
|
+
data == true
|
231
|
+
when 'DateTime'
|
232
|
+
# parse date time (expecting ISO 8601 format)
|
233
|
+
DateTime.parse data
|
234
|
+
when 'Date'
|
235
|
+
# parse date time (expecting ISO 8601 format)
|
236
|
+
Date.parse data
|
237
|
+
when 'Object'
|
238
|
+
# generic object (usually a Hash), return directly
|
239
|
+
data
|
240
|
+
when /\AArray<(.+)>\z/
|
241
|
+
# e.g. Array<Pet>
|
242
|
+
sub_type = $1
|
243
|
+
data.map {|item| convert_to_type(item, sub_type) }
|
244
|
+
when /\AHash\<String, (.+)\>\z/
|
245
|
+
# e.g. Hash<String, Integer>
|
246
|
+
sub_type = $1
|
247
|
+
{}.tap do |hash|
|
248
|
+
data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
|
249
|
+
end
|
250
|
+
else
|
251
|
+
# models, e.g. Pet
|
252
|
+
PostFinanceCheckout.const_get(return_type).new.tap do |model|
|
253
|
+
model.build_from_hash data
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
# Save response body into a file in (the defined) temporary folder, using the filename
|
259
|
+
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
260
|
+
#
|
261
|
+
# @see Configuration#temp_folder_path
|
262
|
+
# @return [Tempfile] the file downloaded
|
263
|
+
def download_file(response)
|
264
|
+
content_disposition = response.headers['Content-Disposition']
|
265
|
+
if content_disposition and content_disposition =~ /filename=/i
|
266
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
267
|
+
prefix = sanitize_filename(filename)
|
268
|
+
else
|
269
|
+
prefix = 'download-'
|
270
|
+
end
|
271
|
+
prefix = prefix + '-' unless prefix.end_with?('-')
|
272
|
+
|
273
|
+
tempfile = nil
|
274
|
+
encoding = response.body.encoding
|
275
|
+
Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) do |file|
|
276
|
+
file.write(response.body)
|
277
|
+
tempfile = file
|
278
|
+
end
|
279
|
+
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
280
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
281
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
282
|
+
"explicitly with `tempfile.delete`"
|
283
|
+
tempfile
|
284
|
+
end
|
285
|
+
|
286
|
+
# Sanitize filename by removing path.
|
287
|
+
# e.g. ../../sun.gif becomes sun.gif
|
288
|
+
#
|
289
|
+
# @param [String] filename the filename to be sanitized
|
290
|
+
# @return [String] the sanitized filename
|
291
|
+
def sanitize_filename(filename)
|
292
|
+
filename.gsub(/.*[\/\\]/, '')
|
293
|
+
end
|
294
|
+
|
295
|
+
def build_request_url(path)
|
296
|
+
# Add leading and trailing slashes to path
|
297
|
+
path = "/#{path}".gsub(/\/+/, '/')
|
298
|
+
Addressable::URI.encode(@config.base_url + path)
|
299
|
+
end
|
300
|
+
|
301
|
+
# Builds the HTTP request body
|
302
|
+
#
|
303
|
+
# @param [Hash] header_params Header parameters
|
304
|
+
# @param [Hash] form_params Query parameters
|
305
|
+
# @param [Object] body HTTP body (JSON/XML)
|
306
|
+
# @return [String] HTTP body data in the form of string
|
307
|
+
def build_request_body(header_params, form_params, body)
|
308
|
+
# http form
|
309
|
+
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
310
|
+
header_params['Content-Type'] == 'multipart/form-data'
|
311
|
+
data = {}
|
312
|
+
form_params.each do |key, value|
|
313
|
+
case value
|
314
|
+
when File, Array, nil
|
315
|
+
# let typhoeus handle File, Array and nil parameters
|
316
|
+
data[key] = value
|
317
|
+
else
|
318
|
+
data[key] = value.to_s
|
319
|
+
end
|
320
|
+
end
|
321
|
+
elsif body
|
322
|
+
data = body.is_a?(String) ? body : body.to_json
|
323
|
+
else
|
324
|
+
data = nil
|
325
|
+
end
|
326
|
+
data
|
327
|
+
end
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
# Sets user agent in HTTP header
|
332
|
+
#
|
333
|
+
# @param [String] user_agent User agent (e.g. swagger-codegen/ruby/1.0.0)
|
334
|
+
def user_agent=(user_agent)
|
335
|
+
@user_agent = user_agent
|
336
|
+
@default_headers['User-Agent'] = @user_agent
|
337
|
+
end
|
338
|
+
|
339
|
+
# Return Accept header based on an array of accepts provided.
|
340
|
+
# @param [Array] accepts array for Accept
|
341
|
+
# @return [String] the Accept header (e.g. application/json)
|
342
|
+
def select_header_accept(accepts)
|
343
|
+
return nil if accepts.nil? || accepts.empty?
|
344
|
+
# use JSON when present, otherwise use all of the provided
|
345
|
+
json_accept = accepts.find { |s| json_mime?(s) }
|
346
|
+
return json_accept || accepts.join(',')
|
347
|
+
end
|
348
|
+
|
349
|
+
# Return Content-Type header based on an array of content types provided.
|
350
|
+
# @param [Array] content_types array for Content-Type
|
351
|
+
# @return [String] the Content-Type header (e.g. application/json)
|
352
|
+
def select_header_content_type(content_types)
|
353
|
+
# use application/json by default
|
354
|
+
return 'application/json' if content_types.nil? || content_types.empty?
|
355
|
+
# use JSON when present, otherwise use the first one
|
356
|
+
json_content_type = content_types.find { |s| json_mime?(s) }
|
357
|
+
return json_content_type || content_types.first
|
358
|
+
end
|
359
|
+
|
360
|
+
# Convert object (array, hash, object, etc) to JSON string.
|
361
|
+
# @param [Object] model object to be converted into JSON string
|
362
|
+
# @return [String] JSON string representation of the object
|
363
|
+
def object_to_http_body(model)
|
364
|
+
return model if model.nil? || model.is_a?(String)
|
365
|
+
local_body = nil
|
366
|
+
if model.is_a?(Array)
|
367
|
+
local_body = model.map{|m| object_to_hash(m) }
|
368
|
+
else
|
369
|
+
local_body = object_to_hash(model)
|
370
|
+
end
|
371
|
+
local_body.to_json
|
372
|
+
end
|
373
|
+
|
374
|
+
# Convert object(non-array) to hash.
|
375
|
+
# @param [Object] obj object to be converted into JSON string
|
376
|
+
# @return [String] JSON string representation of the object
|
377
|
+
def object_to_hash(obj)
|
378
|
+
if obj.respond_to?(:to_hash)
|
379
|
+
obj.to_hash
|
380
|
+
else
|
381
|
+
obj
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
# Build parameter value according to the given collection format.
|
386
|
+
# @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
|
387
|
+
def build_collection_param(param, collection_format)
|
388
|
+
case collection_format
|
389
|
+
when :csv
|
390
|
+
param.join(',')
|
391
|
+
when :ssv
|
392
|
+
param.join(' ')
|
393
|
+
when :tsv
|
394
|
+
param.join("\t")
|
395
|
+
when :pipes
|
396
|
+
param.join('|')
|
397
|
+
when :multi
|
398
|
+
# return the array directly as typhoeus will handle it as expected
|
399
|
+
param
|
400
|
+
else
|
401
|
+
fail "unknown collection format: #{collection_format.inspect}"
|
402
|
+
end
|
403
|
+
end
|
404
|
+
end
|
405
|
+
end
|