digital_femsa 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +77 -0
- data/CONTRIBUTING.md +19 -0
- data/Gemfile +9 -0
- data/LICENSE +22 -0
- data/Makefile +11 -0
- data/README.md +320 -0
- data/Rakefile +10 -0
- data/VERSION +1 -0
- data/config-ruby.json +30 -0
- data/digital_femsa.gemspec +41 -0
- data/docs/ApiKeyCreateResponse.md +40 -0
- data/docs/ApiKeyRequest.md +20 -0
- data/docs/ApiKeyResponse.md +38 -0
- data/docs/ApiKeyResponseOnDelete.md +34 -0
- data/docs/ApiKeyUpdateRequest.md +20 -0
- data/docs/ApiKeysApi.md +391 -0
- data/docs/BalanceCommonField.md +20 -0
- data/docs/BalanceResponse.md +36 -0
- data/docs/BalancesApi.md +79 -0
- data/docs/ChargeOrderResponse.md +52 -0
- data/docs/ChargeOrderResponsePaymentMethod.md +76 -0
- data/docs/ChargeRequest.md +22 -0
- data/docs/ChargeRequestPaymentMethod.md +22 -0
- data/docs/ChargeResponse.md +52 -0
- data/docs/ChargeResponseChannel.md +24 -0
- data/docs/ChargeResponsePaymentMethod.md +76 -0
- data/docs/ChargeResponseRefunds.md +26 -0
- data/docs/ChargeResponseRefundsData.md +30 -0
- data/docs/ChargeUpdateRequest.md +18 -0
- data/docs/ChargesApi.md +241 -0
- data/docs/ChargesDataResponse.md +52 -0
- data/docs/Checkout.md +34 -0
- data/docs/CheckoutOrderTemplate.md +24 -0
- data/docs/CheckoutOrderTemplateCustomerInfo.md +49 -0
- data/docs/CheckoutRequest.md +30 -0
- data/docs/CheckoutResponse.md +58 -0
- data/docs/CheckoutsResponse.md +26 -0
- data/docs/CompaniesApi.md +159 -0
- data/docs/CompanyFiscalInfoAddressResponse.md +34 -0
- data/docs/CompanyFiscalInfoResponse.md +30 -0
- data/docs/CompanyPayoutDestinationResponse.md +28 -0
- data/docs/CompanyResponse.md +32 -0
- data/docs/CreateCustomerFiscalEntitiesResponse.md +38 -0
- data/docs/CreateCustomerPaymentMethodsRequest.md +47 -0
- data/docs/CreateCustomerPaymentMethodsResponse.md +77 -0
- data/docs/Customer.md +40 -0
- data/docs/CustomerAddress.md +32 -0
- data/docs/CustomerAntifraudInfo.md +20 -0
- data/docs/CustomerAntifraudInfoResponse.md +20 -0
- data/docs/CustomerFiscalEntitiesDataResponse.md +38 -0
- data/docs/CustomerFiscalEntitiesRequest.md +28 -0
- data/docs/CustomerFiscalEntitiesResponse.md +22 -0
- data/docs/CustomerInfo.md +26 -0
- data/docs/CustomerInfoJustCustomerId.md +18 -0
- data/docs/CustomerInfoJustCustomerIdResponse.md +18 -0
- data/docs/CustomerPaymentMethodRequest.md +18 -0
- data/docs/CustomerPaymentMethodsData.md +77 -0
- data/docs/CustomerPaymentMethodsRequest.md +47 -0
- data/docs/CustomerPaymentMethodsResponse.md +26 -0
- data/docs/CustomerResponse.md +50 -0
- data/docs/CustomerResponseShippingContacts.md +22 -0
- data/docs/CustomerShippingContacts.md +32 -0
- data/docs/CustomerShippingContactsAddress.md +30 -0
- data/docs/CustomerShippingContactsDataResponse.md +38 -0
- data/docs/CustomerShippingContactsResponse.md +38 -0
- data/docs/CustomerShippingContactsResponseAddress.md +32 -0
- data/docs/CustomerUpdateFiscalEntitiesRequest.md +28 -0
- data/docs/CustomerUpdateShippingContacts.md +30 -0
- data/docs/CustomersApi.md +553 -0
- data/docs/CustomersResponse.md +26 -0
- data/docs/DeleteApiKeysResponse.md +34 -0
- data/docs/Details.md +18 -0
- data/docs/DetailsError.md +24 -0
- data/docs/DiscountLinesDataResponse.md +28 -0
- data/docs/DiscountLinesResponse.md +28 -0
- data/docs/DiscountsApi.md +405 -0
- data/docs/EmailCheckoutRequest.md +18 -0
- data/docs/Error.md +24 -0
- data/docs/EventResponse.md +32 -0
- data/docs/EventsApi.md +239 -0
- data/docs/EventsResendResponse.md +28 -0
- data/docs/FiscalEntityAddress.md +30 -0
- data/docs/GetApiKeysResponse.md +26 -0
- data/docs/GetChargesResponse.md +26 -0
- data/docs/GetCompaniesResponse.md +26 -0
- data/docs/GetCustomerPaymentMethodDataResponse.md +77 -0
- data/docs/GetEventsResponse.md +26 -0
- data/docs/GetOrderDiscountLinesResponse.md +26 -0
- data/docs/GetOrdersResponse.md +26 -0
- data/docs/GetPaymentMethodResponse.md +26 -0
- data/docs/GetTransactionsResponse.md +26 -0
- data/docs/GetTransfersResponse.md +26 -0
- data/docs/GetWebhookKeysResponse.md +26 -0
- data/docs/GetWebhooksResponse.md +26 -0
- data/docs/LogResponse.md +56 -0
- data/docs/LogsApi.md +165 -0
- data/docs/LogsResponse.md +26 -0
- data/docs/LogsResponseData.md +56 -0
- data/docs/OrderCaptureRequest.md +18 -0
- data/docs/OrderCustomerInfoResponse.md +28 -0
- data/docs/OrderDiscountLinesRequest.md +22 -0
- data/docs/OrderFiscalEntityAddressResponse.md +32 -0
- data/docs/OrderFiscalEntityRequest.md +28 -0
- data/docs/OrderFiscalEntityResponse.md +34 -0
- data/docs/OrderNextActionResponse.md +20 -0
- data/docs/OrderNextActionResponseRedirectToUrl.md +20 -0
- data/docs/OrderRefundRequest.md +22 -0
- data/docs/OrderRequest.md +44 -0
- data/docs/OrderRequestCustomerInfo.md +49 -0
- data/docs/OrderResponse.md +58 -0
- data/docs/OrderResponseCharges.md +22 -0
- data/docs/OrderResponseCheckout.md +58 -0
- data/docs/OrderResponseCustomerInfo.md +30 -0
- data/docs/OrderResponseDiscountLines.md +22 -0
- data/docs/OrderResponseProducts.md +26 -0
- data/docs/OrderResponseShippingContact.md +38 -0
- data/docs/OrderTaxRequest.md +22 -0
- data/docs/OrderUpdateFiscalEntityRequest.md +28 -0
- data/docs/OrderUpdateRequest.md +40 -0
- data/docs/OrderUpdateRequestCustomerInfo.md +49 -0
- data/docs/OrdersApi.md +627 -0
- data/docs/OrdersResponse.md +18 -0
- data/docs/Page.md +20 -0
- data/docs/Pagination.md +20 -0
- data/docs/PaymentLinkApi.md +463 -0
- data/docs/PaymentMethod.md +20 -0
- data/docs/PaymentMethodCash.md +36 -0
- data/docs/PaymentMethodCashRequest.md +20 -0
- data/docs/PaymentMethodCashResponse.md +36 -0
- data/docs/PaymentMethodResponse.md +26 -0
- data/docs/PaymentMethodsApi.md +327 -0
- data/docs/Product.md +34 -0
- data/docs/ProductDataResponse.md +40 -0
- data/docs/ProductOrderResponse.md +40 -0
- data/docs/ProductsApi.md +243 -0
- data/docs/ShippingContactsApi.md +243 -0
- data/docs/ShippingOrderResponse.md +32 -0
- data/docs/ShippingRequest.md +26 -0
- data/docs/ShippingsApi.md +243 -0
- data/docs/SmsCheckoutRequest.md +18 -0
- data/docs/TaxesApi.md +243 -0
- data/docs/TransactionResponse.md +38 -0
- data/docs/TransactionsApi.md +171 -0
- data/docs/TransferDestinationResponse.md +32 -0
- data/docs/TransferMethodResponse.md +32 -0
- data/docs/TransferResponse.md +36 -0
- data/docs/TransfersApi.md +165 -0
- data/docs/TransfersResponse.md +36 -0
- data/docs/UpdateCustomer.md +40 -0
- data/docs/UpdateCustomerAntifraudInfo.md +20 -0
- data/docs/UpdateCustomerFiscalEntitiesResponse.md +38 -0
- data/docs/UpdateCustomerPaymentMethodsResponse.md +77 -0
- data/docs/UpdateOrderDiscountLinesRequest.md +22 -0
- data/docs/UpdateOrderTaxRequest.md +22 -0
- data/docs/UpdateOrderTaxResponse.md +28 -0
- data/docs/UpdatePaymentMethods.md +18 -0
- data/docs/UpdateProduct.md +34 -0
- data/docs/WebhookKeyCreateResponse.md +28 -0
- data/docs/WebhookKeyDeleteResponse.md +28 -0
- data/docs/WebhookKeyRequest.md +18 -0
- data/docs/WebhookKeyResponse.md +30 -0
- data/docs/WebhookKeyUpdateRequest.md +18 -0
- data/docs/WebhookKeysApi.md +385 -0
- data/docs/WebhookLog.md +30 -0
- data/docs/WebhookRequest.md +20 -0
- data/docs/WebhookResponse.md +36 -0
- data/docs/WebhookUpdateRequest.md +22 -0
- data/docs/WebhooksApi.md +461 -0
- data/gitleaks.toml +0 -0
- data/lib/digital_femsa/api/api_keys_api.rb +407 -0
- data/lib/digital_femsa/api/balances_api.rb +86 -0
- data/lib/digital_femsa/api/charges_api.rb +273 -0
- data/lib/digital_femsa/api/companies_api.rb +174 -0
- data/lib/digital_femsa/api/customers_api.rb +591 -0
- data/lib/digital_femsa/api/discounts_api.rb +447 -0
- data/lib/digital_femsa/api/events_api.rb +256 -0
- data/lib/digital_femsa/api/logs_api.rb +182 -0
- data/lib/digital_femsa/api/orders_api.rb +657 -0
- data/lib/digital_femsa/api/payment_link_api.rb +491 -0
- data/lib/digital_femsa/api/payment_methods_api.rb +368 -0
- data/lib/digital_femsa/api/products_api.rb +275 -0
- data/lib/digital_femsa/api/shipping_contacts_api.rb +275 -0
- data/lib/digital_femsa/api/shippings_api.rb +275 -0
- data/lib/digital_femsa/api/taxes_api.rb +275 -0
- data/lib/digital_femsa/api/transactions_api.rb +191 -0
- data/lib/digital_femsa/api/transfers_api.rb +182 -0
- data/lib/digital_femsa/api/webhook_keys_api.rb +396 -0
- data/lib/digital_femsa/api/webhooks_api.rb +477 -0
- data/lib/digital_femsa/api_client.rb +442 -0
- data/lib/digital_femsa/api_error.rb +58 -0
- data/lib/digital_femsa/configuration.rb +382 -0
- data/lib/digital_femsa/models/api_key_create_response.rb +333 -0
- data/lib/digital_femsa/models/api_key_request.rb +231 -0
- data/lib/digital_femsa/models/api_key_response.rb +317 -0
- data/lib/digital_femsa/models/api_key_response_on_delete.rb +296 -0
- data/lib/digital_femsa/models/api_key_update_request.rb +225 -0
- data/lib/digital_femsa/models/balance_common_field.rb +226 -0
- data/lib/digital_femsa/models/balance_response.rb +324 -0
- data/lib/digital_femsa/models/charge_order_response.rb +373 -0
- data/lib/digital_femsa/models/charge_order_response_payment_method.rb +53 -0
- data/lib/digital_femsa/models/charge_request.rb +241 -0
- data/lib/digital_femsa/models/charge_request_payment_method.rb +241 -0
- data/lib/digital_femsa/models/charge_response.rb +371 -0
- data/lib/digital_femsa/models/charge_response_channel.rb +241 -0
- data/lib/digital_femsa/models/charge_response_payment_method.rb +53 -0
- data/lib/digital_femsa/models/charge_response_refunds.rb +281 -0
- data/lib/digital_femsa/models/charge_response_refunds_data.rb +298 -0
- data/lib/digital_femsa/models/charge_update_request.rb +216 -0
- data/lib/digital_femsa/models/charges_data_response.rb +378 -0
- data/lib/digital_femsa/models/checkout.rb +340 -0
- data/lib/digital_femsa/models/checkout_order_template.rb +301 -0
- data/lib/digital_femsa/models/checkout_order_template_customer_info.rb +106 -0
- data/lib/digital_femsa/models/checkout_request.rb +284 -0
- data/lib/digital_femsa/models/checkout_response.rb +429 -0
- data/lib/digital_femsa/models/checkouts_response.rb +280 -0
- data/lib/digital_femsa/models/company_fiscal_info_address_response.rb +330 -0
- data/lib/digital_femsa/models/company_fiscal_info_response.rb +309 -0
- data/lib/digital_femsa/models/company_payout_destination_response.rb +312 -0
- data/lib/digital_femsa/models/company_response.rb +318 -0
- data/lib/digital_femsa/models/create_customer_fiscal_entities_response.rb +341 -0
- data/lib/digital_femsa/models/create_customer_payment_methods_request.rb +105 -0
- data/lib/digital_femsa/models/create_customer_payment_methods_response.rb +54 -0
- data/lib/digital_femsa/models/customer.rb +374 -0
- data/lib/digital_femsa/models/customer_address.rb +301 -0
- data/lib/digital_femsa/models/customer_antifraud_info.rb +223 -0
- data/lib/digital_femsa/models/customer_antifraud_info_response.rb +223 -0
- data/lib/digital_femsa/models/customer_fiscal_entities_data_response.rb +341 -0
- data/lib/digital_femsa/models/customer_fiscal_entities_request.rb +268 -0
- data/lib/digital_femsa/models/customer_fiscal_entities_response.rb +257 -0
- data/lib/digital_femsa/models/customer_info.rb +271 -0
- data/lib/digital_femsa/models/customer_info_just_customer_id.rb +221 -0
- data/lib/digital_femsa/models/customer_info_just_customer_id_response.rb +214 -0
- data/lib/digital_femsa/models/customer_payment_method_request.rb +223 -0
- data/lib/digital_femsa/models/customer_payment_methods_data.rb +54 -0
- data/lib/digital_femsa/models/customer_payment_methods_request.rb +104 -0
- data/lib/digital_femsa/models/customer_payment_methods_response.rb +280 -0
- data/lib/digital_femsa/models/customer_response.rb +425 -0
- data/lib/digital_femsa/models/customer_response_shipping_contacts.rb +257 -0
- data/lib/digital_femsa/models/customer_shipping_contacts.rb +312 -0
- data/lib/digital_femsa/models/customer_shipping_contacts_address.rb +271 -0
- data/lib/digital_femsa/models/customer_shipping_contacts_data_response.rb +366 -0
- data/lib/digital_femsa/models/customer_shipping_contacts_response.rb +328 -0
- data/lib/digital_femsa/models/customer_shipping_contacts_response_address.rb +278 -0
- data/lib/digital_femsa/models/customer_update_fiscal_entities_request.rb +261 -0
- data/lib/digital_femsa/models/customer_update_shipping_contacts.rb +274 -0
- data/lib/digital_femsa/models/customers_response.rb +280 -0
- data/lib/digital_femsa/models/delete_api_keys_response.rb +301 -0
- data/lib/digital_femsa/models/details.rb +216 -0
- data/lib/digital_femsa/models/details_error.rb +242 -0
- data/lib/digital_femsa/models/discount_lines_data_response.rb +333 -0
- data/lib/digital_femsa/models/discount_lines_response.rb +333 -0
- data/lib/digital_femsa/models/email_checkout_request.rb +221 -0
- data/lib/digital_femsa/models/error.rb +253 -0
- data/lib/digital_femsa/models/event_response.rb +301 -0
- data/lib/digital_femsa/models/events_resend_response.rb +281 -0
- data/lib/digital_femsa/models/fiscal_entity_address.rb +312 -0
- data/lib/digital_femsa/models/get_api_keys_response.rb +280 -0
- data/lib/digital_femsa/models/get_charges_response.rb +280 -0
- data/lib/digital_femsa/models/get_companies_response.rb +280 -0
- data/lib/digital_femsa/models/get_customer_payment_method_data_response.rb +54 -0
- data/lib/digital_femsa/models/get_events_response.rb +280 -0
- data/lib/digital_femsa/models/get_order_discount_lines_response.rb +280 -0
- data/lib/digital_femsa/models/get_orders_response.rb +288 -0
- data/lib/digital_femsa/models/get_payment_method_response.rb +280 -0
- data/lib/digital_femsa/models/get_transactions_response.rb +281 -0
- data/lib/digital_femsa/models/get_transfers_response.rb +281 -0
- data/lib/digital_femsa/models/get_webhook_keys_response.rb +280 -0
- data/lib/digital_femsa/models/get_webhooks_response.rb +280 -0
- data/lib/digital_femsa/models/log_response.rb +418 -0
- data/lib/digital_femsa/models/logs_response.rb +261 -0
- data/lib/digital_femsa/models/logs_response_data.rb +396 -0
- data/lib/digital_femsa/models/order_capture_request.rb +241 -0
- data/lib/digital_femsa/models/order_customer_info_response.rb +263 -0
- data/lib/digital_femsa/models/order_discount_lines_request.rb +276 -0
- data/lib/digital_femsa/models/order_fiscal_entity_address_response.rb +328 -0
- data/lib/digital_femsa/models/order_fiscal_entity_request.rb +295 -0
- data/lib/digital_femsa/models/order_fiscal_entity_response.rb +347 -0
- data/lib/digital_femsa/models/order_next_action_response.rb +225 -0
- data/lib/digital_femsa/models/order_next_action_response_redirect_to_url.rb +226 -0
- data/lib/digital_femsa/models/order_refund_request.rb +247 -0
- data/lib/digital_femsa/models/order_request.rb +413 -0
- data/lib/digital_femsa/models/order_request_customer_info.rb +106 -0
- data/lib/digital_femsa/models/order_response.rb +427 -0
- data/lib/digital_femsa/models/order_response_charges.rb +258 -0
- data/lib/digital_femsa/models/order_response_checkout.rb +418 -0
- data/lib/digital_femsa/models/order_response_customer_info.rb +280 -0
- data/lib/digital_femsa/models/order_response_discount_lines.rb +257 -0
- data/lib/digital_femsa/models/order_response_products.rb +280 -0
- data/lib/digital_femsa/models/order_response_shipping_contact.rb +334 -0
- data/lib/digital_femsa/models/order_tax_request.rb +308 -0
- data/lib/digital_femsa/models/order_update_fiscal_entity_request.rb +295 -0
- data/lib/digital_femsa/models/order_update_request.rb +352 -0
- data/lib/digital_femsa/models/order_update_request_customer_info.rb +105 -0
- data/lib/digital_femsa/models/orders_response.rb +223 -0
- data/lib/digital_femsa/models/page.rb +228 -0
- data/lib/digital_femsa/models/pagination.rb +240 -0
- data/lib/digital_femsa/models/payment_method.rb +230 -0
- data/lib/digital_femsa/models/payment_method_cash.rb +312 -0
- data/lib/digital_femsa/models/payment_method_cash_request.rb +238 -0
- data/lib/digital_femsa/models/payment_method_cash_response.rb +330 -0
- data/lib/digital_femsa/models/payment_method_response.rb +278 -0
- data/lib/digital_femsa/models/product.rb +397 -0
- data/lib/digital_femsa/models/product_data_response.rb +431 -0
- data/lib/digital_femsa/models/product_order_response.rb +431 -0
- data/lib/digital_femsa/models/shipping_order_response.rb +336 -0
- data/lib/digital_femsa/models/shipping_request.rb +302 -0
- data/lib/digital_femsa/models/sms_checkout_request.rb +221 -0
- data/lib/digital_femsa/models/transaction_response.rb +412 -0
- data/lib/digital_femsa/models/transfer_destination_response.rb +286 -0
- data/lib/digital_femsa/models/transfer_method_response.rb +286 -0
- data/lib/digital_femsa/models/transfer_response.rb +324 -0
- data/lib/digital_femsa/models/transfers_response.rb +324 -0
- data/lib/digital_femsa/models/update_customer.rb +353 -0
- data/lib/digital_femsa/models/update_customer_antifraud_info.rb +223 -0
- data/lib/digital_femsa/models/update_customer_fiscal_entities_response.rb +341 -0
- data/lib/digital_femsa/models/update_customer_payment_methods_response.rb +54 -0
- data/lib/digital_femsa/models/update_order_discount_lines_request.rb +253 -0
- data/lib/digital_femsa/models/update_order_tax_request.rb +294 -0
- data/lib/digital_femsa/models/update_order_tax_response.rb +349 -0
- data/lib/digital_femsa/models/update_payment_methods.rb +214 -0
- data/lib/digital_femsa/models/update_product.rb +349 -0
- data/lib/digital_femsa/models/webhook_key_create_response.rb +266 -0
- data/lib/digital_femsa/models/webhook_key_delete_response.rb +266 -0
- data/lib/digital_femsa/models/webhook_key_request.rb +217 -0
- data/lib/digital_femsa/models/webhook_key_response.rb +277 -0
- data/lib/digital_femsa/models/webhook_key_update_request.rb +217 -0
- data/lib/digital_femsa/models/webhook_log.rb +289 -0
- data/lib/digital_femsa/models/webhook_request.rb +261 -0
- data/lib/digital_femsa/models/webhook_response.rb +299 -0
- data/lib/digital_femsa/models/webhook_update_request.rb +267 -0
- data/lib/digital_femsa/version.rb +15 -0
- data/lib/digital_femsa.rb +197 -0
- data/lib/ssl_data/ca_bundle.crt +4039 -0
- data/spec/api/api_keys_api_spec.rb +107 -0
- data/spec/api/balances_api_spec.rb +47 -0
- data/spec/api/charges_api_spec.rb +80 -0
- data/spec/api/companies_api_spec.rb +63 -0
- data/spec/api/customers_api_spec.rb +140 -0
- data/spec/api/discounts_api_spec.rb +114 -0
- data/spec/api/events_api_spec.rb +79 -0
- data/spec/api/logs_api_spec.rb +66 -0
- data/spec/api/orders_api_spec.rb +153 -0
- data/spec/api/payment_link_api_spec.rb +119 -0
- data/spec/api/payment_methods_api_spec.rb +99 -0
- data/spec/api/products_api_spec.rb +81 -0
- data/spec/api/shipping_contacts_api_spec.rb +81 -0
- data/spec/api/shippings_api_spec.rb +81 -0
- data/spec/api/taxes_api_spec.rb +81 -0
- data/spec/api/transactions_api_spec.rb +69 -0
- data/spec/api/transfers_api_spec.rb +66 -0
- data/spec/api/webhook_keys_api_spec.rb +104 -0
- data/spec/api/webhooks_api_spec.rb +118 -0
- data/spec/spec_helper.rb +111 -0
- data/ssl_data/ca_bundle.crt +4039 -0
- data/templates/ruby/CUSTOM_VERSION.mustache +1 -0
- data/templates/ruby/api_client.mustache +257 -0
- data/templates/ruby/configuration.mustache +481 -0
- metadata +488 -0
@@ -0,0 +1,442 @@
|
|
1
|
+
=begin
|
2
|
+
#Femsa API
|
3
|
+
|
4
|
+
#Femsa sdk
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2.1.0
|
7
|
+
Contact: engineering@femsa.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
Generator version: 7.5.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'json'
|
15
|
+
require 'logger'
|
16
|
+
require 'tempfile'
|
17
|
+
require 'time'
|
18
|
+
require 'faraday'
|
19
|
+
require 'faraday/multipart' if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
|
20
|
+
require 'marcel'
|
21
|
+
|
22
|
+
|
23
|
+
module DigitalFemsa
|
24
|
+
class ApiClient
|
25
|
+
# The Configuration object holding settings to be used in the API client.
|
26
|
+
attr_accessor :config
|
27
|
+
|
28
|
+
# Defines the headers to be used in HTTP requests of all API calls by default.
|
29
|
+
#
|
30
|
+
# @return [Hash]
|
31
|
+
attr_accessor :default_headers
|
32
|
+
|
33
|
+
# Initializes the ApiClient
|
34
|
+
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
35
|
+
def initialize(config = Configuration.default)
|
36
|
+
@config = config
|
37
|
+
@user_agent = "DigitalFemsa/v2 RubyBindings/#{DigitalFemsa::VERSION}"
|
38
|
+
@default_headers = {
|
39
|
+
'Content-Type' => 'application/json',
|
40
|
+
'User-Agent' => @user_agent,
|
41
|
+
'X-DigitalFemsa-Client-User-Agent' => digitalfemsa_headers.to_json
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.default
|
46
|
+
@@default ||= ApiClient.new
|
47
|
+
end
|
48
|
+
|
49
|
+
# Call an API with given options.
|
50
|
+
#
|
51
|
+
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
|
52
|
+
# the data deserialized from response body (could be nil), response status code and response headers.
|
53
|
+
def call_api(http_method, path, opts = {})
|
54
|
+
stream = nil
|
55
|
+
begin
|
56
|
+
response = connection(opts).public_send(http_method.to_sym.downcase) do |req|
|
57
|
+
request = build_request(http_method, path, req, opts)
|
58
|
+
stream = download_file(request) if opts[:return_type] == 'File' || opts[:return_type] == 'Binary'
|
59
|
+
end
|
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.status == 0 && response.respond_to?(:return_message)
|
67
|
+
# Errors from libcurl will be made visible here
|
68
|
+
fail ApiError.new(code: 0,
|
69
|
+
message: response.return_message)
|
70
|
+
else
|
71
|
+
fail ApiError.new(code: response.status,
|
72
|
+
response_headers: response.headers,
|
73
|
+
response_body: response.body),
|
74
|
+
response.reason_phrase
|
75
|
+
end
|
76
|
+
end
|
77
|
+
rescue Faraday::TimeoutError
|
78
|
+
fail ApiError.new('Connection timed out')
|
79
|
+
rescue Faraday::ConnectionFailed
|
80
|
+
fail ApiError.new('Connection failed')
|
81
|
+
end
|
82
|
+
|
83
|
+
if opts[:return_type] == 'File' || opts[:return_type] == 'Binary'
|
84
|
+
data = deserialize_file(response, stream)
|
85
|
+
elsif opts[:return_type]
|
86
|
+
data = deserialize(response, opts[:return_type])
|
87
|
+
else
|
88
|
+
data = nil
|
89
|
+
end
|
90
|
+
return data, response.status, response.headers
|
91
|
+
end
|
92
|
+
|
93
|
+
# Builds the HTTP request
|
94
|
+
#
|
95
|
+
# @param [String] http_method HTTP method/verb (e.g. POST)
|
96
|
+
# @param [String] path URL path (e.g. /account/new)
|
97
|
+
# @option opts [Hash] :header_params Header parameters
|
98
|
+
# @option opts [Hash] :query_params Query parameters
|
99
|
+
# @option opts [Hash] :form_params Query parameters
|
100
|
+
# @option opts [Object] :body HTTP body (JSON/XML)
|
101
|
+
# @return [Faraday::Request] A Faraday Request
|
102
|
+
def build_request(http_method, path, request, opts = {})
|
103
|
+
url = build_request_url(path, opts)
|
104
|
+
http_method = http_method.to_sym.downcase
|
105
|
+
|
106
|
+
header_params = @default_headers.merge(opts[:header_params] || {})
|
107
|
+
query_params = opts[:query_params] || {}
|
108
|
+
form_params = opts[:form_params] || {}
|
109
|
+
|
110
|
+
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
111
|
+
|
112
|
+
if [:post, :patch, :put, :delete].include?(http_method)
|
113
|
+
req_body = build_request_body(header_params, form_params, opts[:body])
|
114
|
+
if config.debugging
|
115
|
+
config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
request.headers = header_params
|
119
|
+
request.body = req_body
|
120
|
+
|
121
|
+
# Overload default options only if provided
|
122
|
+
request.options.params_encoder = config.params_encoder if config.params_encoder
|
123
|
+
request.options.timeout = config.timeout if config.timeout
|
124
|
+
|
125
|
+
request.url url
|
126
|
+
request.params = query_params
|
127
|
+
request
|
128
|
+
end
|
129
|
+
|
130
|
+
# Builds the HTTP request body
|
131
|
+
#
|
132
|
+
# @param [Hash] header_params Header parameters
|
133
|
+
# @param [Hash] form_params Query parameters
|
134
|
+
# @param [Object] body HTTP body (JSON/XML)
|
135
|
+
# @return [String] HTTP body data in the form of string
|
136
|
+
def build_request_body(header_params, form_params, body)
|
137
|
+
# http form
|
138
|
+
if header_params['Content-Type'] == 'application/x-www-form-urlencoded'
|
139
|
+
data = URI.encode_www_form(form_params)
|
140
|
+
elsif header_params['Content-Type'] == 'multipart/form-data'
|
141
|
+
data = {}
|
142
|
+
form_params.each do |key, value|
|
143
|
+
case value
|
144
|
+
when ::File, ::Tempfile
|
145
|
+
data[key] = Faraday::FilePart.new(value.path, Marcel::MimeType.for(Pathname.new(value.path)))
|
146
|
+
when ::Array, nil
|
147
|
+
# let Faraday handle Array and nil parameters
|
148
|
+
data[key] = value
|
149
|
+
else
|
150
|
+
data[key] = value.to_s
|
151
|
+
end
|
152
|
+
end
|
153
|
+
elsif body
|
154
|
+
data = body.is_a?(String) ? body : body.to_json
|
155
|
+
else
|
156
|
+
data = nil
|
157
|
+
end
|
158
|
+
data
|
159
|
+
end
|
160
|
+
|
161
|
+
def download_file(request)
|
162
|
+
stream = []
|
163
|
+
|
164
|
+
# handle streaming Responses
|
165
|
+
request.options.on_data = Proc.new do |chunk, overall_received_bytes|
|
166
|
+
stream << chunk
|
167
|
+
end
|
168
|
+
stream
|
169
|
+
end
|
170
|
+
|
171
|
+
def deserialize_file(response, stream)
|
172
|
+
body = response.body
|
173
|
+
if @config.return_binary_data == true
|
174
|
+
# return byte stream
|
175
|
+
encoding = body.encoding
|
176
|
+
stream.join.force_encoding(encoding)
|
177
|
+
else
|
178
|
+
# return file instead of binary data
|
179
|
+
content_disposition = response.headers['Content-Disposition']
|
180
|
+
if content_disposition && content_disposition =~ /filename=/i
|
181
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
182
|
+
prefix = sanitize_filename(filename)
|
183
|
+
else
|
184
|
+
prefix = 'download-'
|
185
|
+
end
|
186
|
+
prefix = prefix + '-' unless prefix.end_with?('-')
|
187
|
+
encoding = body.encoding
|
188
|
+
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
189
|
+
tempfile.write(stream.join.force_encoding(encoding))
|
190
|
+
tempfile.close
|
191
|
+
config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
192
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
193
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
194
|
+
"explicitly with `tempfile.delete`"
|
195
|
+
tempfile
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def connection(opts)
|
200
|
+
opts[:header_params]['Content-Type'] == 'multipart/form-data' ? connection_multipart : connection_regular
|
201
|
+
end
|
202
|
+
|
203
|
+
def connection_multipart
|
204
|
+
@connection_multipart ||= build_connection do |conn|
|
205
|
+
conn.request :multipart
|
206
|
+
conn.request :url_encoded
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def connection_regular
|
211
|
+
@connection_regular ||= build_connection
|
212
|
+
end
|
213
|
+
|
214
|
+
def build_connection
|
215
|
+
Faraday.new(url: config.base_url, ssl: ssl_options, proxy: config.proxy) do |conn|
|
216
|
+
basic_auth(conn)
|
217
|
+
config.configure_middleware(conn)
|
218
|
+
yield(conn) if block_given?
|
219
|
+
conn.adapter(Faraday.default_adapter)
|
220
|
+
config.configure_connection(conn)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
def ssl_options
|
225
|
+
{
|
226
|
+
ca_file: config.ssl_ca_file,
|
227
|
+
verify: config.ssl_verify,
|
228
|
+
verify_mode: config.ssl_verify_mode,
|
229
|
+
client_cert: config.ssl_client_cert,
|
230
|
+
client_key: config.ssl_client_key
|
231
|
+
}
|
232
|
+
end
|
233
|
+
|
234
|
+
def basic_auth(conn)
|
235
|
+
if config.username && config.password
|
236
|
+
if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
|
237
|
+
conn.request(:authorization, :basic, config.username, config.password)
|
238
|
+
else
|
239
|
+
conn.request(:basic_auth, config.username, config.password)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
# Check if the given MIME is a JSON MIME.
|
245
|
+
# JSON MIME examples:
|
246
|
+
# application/json
|
247
|
+
# application/json; charset=UTF8
|
248
|
+
# APPLICATION/JSON
|
249
|
+
# */*
|
250
|
+
# @param [String] mime MIME
|
251
|
+
# @return [Boolean] True if the MIME is application/json
|
252
|
+
def json_mime?(mime)
|
253
|
+
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
|
254
|
+
end
|
255
|
+
|
256
|
+
# Deserialize the response to the given return type.
|
257
|
+
#
|
258
|
+
# @param [Response] response HTTP response
|
259
|
+
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
|
260
|
+
def deserialize(response, return_type)
|
261
|
+
body = response.body
|
262
|
+
return nil if body.nil? || body.empty?
|
263
|
+
|
264
|
+
# return response body directly for String return type
|
265
|
+
return body.to_s if return_type == 'String'
|
266
|
+
|
267
|
+
# ensuring a default content type
|
268
|
+
content_type = response.headers['Content-Type'] || 'application/json'
|
269
|
+
|
270
|
+
fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
|
271
|
+
|
272
|
+
begin
|
273
|
+
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
|
274
|
+
rescue JSON::ParserError => e
|
275
|
+
if %w(String Date Time).include?(return_type)
|
276
|
+
data = body
|
277
|
+
else
|
278
|
+
raise e
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
convert_to_type data, return_type
|
283
|
+
end
|
284
|
+
|
285
|
+
# Convert data to the given return type.
|
286
|
+
# @param [Object] data Data to be converted
|
287
|
+
# @param [String] return_type Return type
|
288
|
+
# @return [Mixed] Data in a particular type
|
289
|
+
def convert_to_type(data, return_type)
|
290
|
+
return nil if data.nil?
|
291
|
+
case return_type
|
292
|
+
when 'String'
|
293
|
+
data.to_s
|
294
|
+
when 'Integer'
|
295
|
+
data.to_i
|
296
|
+
when 'Float'
|
297
|
+
data.to_f
|
298
|
+
when 'Boolean'
|
299
|
+
data == true
|
300
|
+
when 'Time'
|
301
|
+
# parse date time (expecting ISO 8601 format)
|
302
|
+
Time.parse data
|
303
|
+
when 'Date'
|
304
|
+
# parse date time (expecting ISO 8601 format)
|
305
|
+
Date.parse data
|
306
|
+
when 'Object'
|
307
|
+
# generic object (usually a Hash), return directly
|
308
|
+
data
|
309
|
+
when /\AArray<(.+)>\z/
|
310
|
+
# e.g. Array<Pet>
|
311
|
+
sub_type = $1
|
312
|
+
data.map { |item| convert_to_type(item, sub_type) }
|
313
|
+
when /\AHash\<String, (.+)\>\z/
|
314
|
+
# e.g. Hash<String, Integer>
|
315
|
+
sub_type = $1
|
316
|
+
{}.tap do |hash|
|
317
|
+
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
|
318
|
+
end
|
319
|
+
else
|
320
|
+
# models (e.g. Pet) or oneOf
|
321
|
+
klass = DigitalFemsa.const_get(return_type)
|
322
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
# Sanitize filename by removing path.
|
327
|
+
# e.g. ../../sun.gif becomes sun.gif
|
328
|
+
#
|
329
|
+
# @param [String] filename the filename to be sanitized
|
330
|
+
# @return [String] the sanitized filename
|
331
|
+
def sanitize_filename(filename)
|
332
|
+
filename.gsub(/.*[\/\\]/, '')
|
333
|
+
end
|
334
|
+
|
335
|
+
def build_request_url(path, opts = {})
|
336
|
+
# Add leading and trailing slashes to path
|
337
|
+
path = "/#{path}".gsub(/\/+/, '/')
|
338
|
+
@config.base_url(opts[:operation]) + path
|
339
|
+
end
|
340
|
+
|
341
|
+
# Update header and query params based on authentication settings.
|
342
|
+
#
|
343
|
+
# @param [Hash] header_params Header parameters
|
344
|
+
# @param [Hash] query_params Query parameters
|
345
|
+
# @param [String] auth_names Authentication scheme name
|
346
|
+
def update_params_for_auth!(header_params, query_params, auth_names)
|
347
|
+
Array(auth_names).each do |auth_name|
|
348
|
+
auth_setting = @config.auth_settings[auth_name]
|
349
|
+
next unless auth_setting
|
350
|
+
case auth_setting[:in]
|
351
|
+
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
|
352
|
+
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
|
353
|
+
else fail ArgumentError, 'Authentication token must be in `query` or `header`'
|
354
|
+
end
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
# Sets user agent in HTTP header
|
359
|
+
#
|
360
|
+
# @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
|
361
|
+
def user_agent=(user_agent)
|
362
|
+
@user_agent = user_agent
|
363
|
+
@default_headers['User-Agent'] = @user_agent
|
364
|
+
end
|
365
|
+
|
366
|
+
# Return Accept header based on an array of accepts provided.
|
367
|
+
# @param [Array] accepts array for Accept
|
368
|
+
# @return [String] the Accept header (e.g. application/json)
|
369
|
+
def select_header_accept(accepts)
|
370
|
+
return nil if accepts.nil? || accepts.empty?
|
371
|
+
# use JSON when present, otherwise use all of the provided
|
372
|
+
json_accept = accepts.find { |s| json_mime?(s) }
|
373
|
+
json_accept || accepts.join(',')
|
374
|
+
end
|
375
|
+
|
376
|
+
# Return Content-Type header based on an array of content types provided.
|
377
|
+
# @param [Array] content_types array for Content-Type
|
378
|
+
# @return [String] the Content-Type header (e.g. application/json)
|
379
|
+
def select_header_content_type(content_types)
|
380
|
+
# return nil by default
|
381
|
+
return if content_types.nil? || content_types.empty?
|
382
|
+
# use JSON when present, otherwise use the first one
|
383
|
+
json_content_type = content_types.find { |s| json_mime?(s) }
|
384
|
+
json_content_type || content_types.first
|
385
|
+
end
|
386
|
+
|
387
|
+
# Convert object (array, hash, object, etc) to JSON string.
|
388
|
+
# @param [Object] model object to be converted into JSON string
|
389
|
+
# @return [String] JSON string representation of the object
|
390
|
+
def object_to_http_body(model)
|
391
|
+
return model if model.nil? || model.is_a?(String)
|
392
|
+
local_body = nil
|
393
|
+
if model.is_a?(Array)
|
394
|
+
local_body = model.map { |m| object_to_hash(m) }
|
395
|
+
else
|
396
|
+
local_body = object_to_hash(model)
|
397
|
+
end
|
398
|
+
local_body.to_json
|
399
|
+
end
|
400
|
+
|
401
|
+
# Convert object(non-array) to hash.
|
402
|
+
# @param [Object] obj object to be converted into JSON string
|
403
|
+
# @return [String] JSON string representation of the object
|
404
|
+
def object_to_hash(obj)
|
405
|
+
if obj.respond_to?(:to_hash)
|
406
|
+
obj.to_hash
|
407
|
+
else
|
408
|
+
obj
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
412
|
+
# Build parameter value according to the given collection format.
|
413
|
+
# @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
|
414
|
+
def build_collection_param(param, collection_format)
|
415
|
+
case collection_format
|
416
|
+
when :csv
|
417
|
+
param.join(',')
|
418
|
+
when :ssv
|
419
|
+
param.join(' ')
|
420
|
+
when :tsv
|
421
|
+
param.join("\t")
|
422
|
+
when :pipes
|
423
|
+
param.join('|')
|
424
|
+
when :multi
|
425
|
+
# return the array directly as typhoeus will handle it as expected
|
426
|
+
param
|
427
|
+
else
|
428
|
+
fail "unknown collection format: #{collection_format.inspect}"
|
429
|
+
end
|
430
|
+
end
|
431
|
+
def digitalfemsa_headers
|
432
|
+
params = {
|
433
|
+
bindings_version: DigitalFemsa::VERSION,
|
434
|
+
lang: 'ruby',
|
435
|
+
lang_version: RUBY_VERSION,
|
436
|
+
publisher: 'digitalfemsa'
|
437
|
+
}
|
438
|
+
|
439
|
+
@digitalfemsa_headers ||= params
|
440
|
+
end
|
441
|
+
end
|
442
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
=begin
|
2
|
+
#Femsa API
|
3
|
+
|
4
|
+
#Femsa sdk
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2.1.0
|
7
|
+
Contact: engineering@femsa.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
Generator version: 7.5.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
module DigitalFemsa
|
14
|
+
class ApiError < StandardError
|
15
|
+
attr_reader :code, :response_headers, :response_body
|
16
|
+
|
17
|
+
# Usage examples:
|
18
|
+
# ApiError.new
|
19
|
+
# ApiError.new("message")
|
20
|
+
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
|
21
|
+
# ApiError.new(:code => 404, :message => "Not Found")
|
22
|
+
def initialize(arg = nil)
|
23
|
+
if arg.is_a? Hash
|
24
|
+
if arg.key?(:message) || arg.key?('message')
|
25
|
+
super(arg[:message] || arg['message'])
|
26
|
+
else
|
27
|
+
super arg
|
28
|
+
end
|
29
|
+
|
30
|
+
arg.each do |k, v|
|
31
|
+
instance_variable_set "@#{k}", v
|
32
|
+
end
|
33
|
+
else
|
34
|
+
super arg
|
35
|
+
@message = arg
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Override to_s to display a friendly error message
|
40
|
+
def to_s
|
41
|
+
message
|
42
|
+
end
|
43
|
+
|
44
|
+
def message
|
45
|
+
if @message.nil?
|
46
|
+
msg = "Error message: the server returns an error"
|
47
|
+
else
|
48
|
+
msg = @message
|
49
|
+
end
|
50
|
+
|
51
|
+
msg += "\nHTTP status code: #{code}" if code
|
52
|
+
msg += "\nResponse headers: #{response_headers}" if response_headers
|
53
|
+
msg += "\nResponse body: #{response_body}" if response_body
|
54
|
+
|
55
|
+
msg
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|