digital_femsa 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +104 -0
- data/Makefile +14 -0
- data/README.md +28 -33
- data/VERSION +1 -1
- data/config-ruby.json +1 -1
- data/digital_femsa.gemspec +1 -1
- data/docs/ApiKeyCreateResponse.md +1 -1
- data/docs/ApiKeyRequest.md +2 -2
- data/docs/ApiKeyResponseOnDelete.md +2 -2
- data/docs/ApiKeysApi.md +10 -10
- data/docs/BalanceResponse.md +8 -8
- data/docs/BalancesApi.md +1 -1
- data/docs/ChargeOrderResponse.md +1 -1
- data/docs/ChargeOrderResponseChannel.md +24 -0
- data/docs/ChargeRequest.md +1 -1
- data/docs/ChargeRequestPaymentMethod.md +3 -3
- data/docs/ChargeResponse.md +9 -7
- data/docs/ChargeResponseChannel.md +3 -3
- data/docs/ChargeResponseRefundsData.md +5 -1
- data/docs/ChargesApi.md +16 -12
- data/docs/ChargesDataResponse.md +9 -7
- data/docs/Checkout.md +17 -15
- data/docs/CheckoutOrderTemplate.md +3 -3
- data/docs/CheckoutResponse.md +1 -1
- data/docs/CreateCustomerFiscalEntitiesResponse.md +2 -2
- data/docs/Customer.md +13 -19
- data/docs/CustomerAddress.md +2 -2
- data/docs/CustomerFiscalEntitiesDataResponse.md +2 -2
- data/docs/CustomerFiscalEntitiesRequest.md +3 -3
- data/docs/CustomerInfo.md +4 -4
- data/docs/CustomerPaymentMethodRequest.md +1 -1
- data/docs/CustomerResponse.md +17 -21
- data/docs/CustomerShippingContactsResponse.md +5 -5
- data/docs/CustomersApi.md +15 -15
- data/docs/CustomersResponse.md +1 -1
- data/docs/DeleteApiKeysResponse.md +1 -1
- data/docs/DiscountsApi.md +9 -9
- data/docs/EventsApi.md +2 -2
- data/docs/EventsResendResponse.md +1 -1
- data/docs/GetChargesResponse.md +4 -4
- data/docs/GetTransactionsResponse.md +1 -1
- data/docs/LogsApi.md +1 -1
- data/docs/OrderFiscalEntityRequest.md +4 -4
- data/docs/OrderRefundRequest.md +7 -5
- data/docs/OrderRequest.md +17 -19
- data/docs/OrderResponse.md +37 -35
- data/docs/OrderResponseChannel.md +24 -0
- data/docs/OrderResponseShippingContact.md +4 -4
- data/docs/OrderUpdateFiscalEntityRequest.md +1 -1
- data/docs/OrderUpdateRequest.md +19 -15
- data/docs/OrdersApi.md +16 -16
- data/docs/PaymentLinkApi.md +12 -82
- data/docs/PaymentMethodCash.md +4 -4
- data/docs/PaymentMethodCashRequest.md +2 -2
- data/docs/PaymentMethodsApi.md +5 -5
- data/docs/Product.md +10 -12
- data/docs/ProductDataResponse.md +9 -11
- data/docs/ProductOrderResponse.md +9 -11
- data/docs/ProductsApi.md +7 -7
- data/docs/ShippingContactsApi.md +9 -9
- data/docs/ShippingOrderResponse.md +5 -3
- data/docs/ShippingRequest.md +2 -0
- data/docs/ShippingsApi.md +7 -7
- data/docs/TaxesApi.md +7 -7
- data/docs/TransactionResponse.md +20 -14
- data/docs/TransactionsApi.md +6 -6
- data/docs/TransfersApi.md +10 -10
- data/docs/UpdateCustomer.md +17 -21
- data/docs/UpdateCustomerFiscalEntitiesResponse.md +2 -2
- data/docs/UpdateOrderTaxRequest.md +2 -2
- data/docs/UpdateProduct.md +7 -9
- data/docs/WebhookKeysApi.md +18 -14
- data/docs/WebhooksApi.md +28 -22
- data/lib/digital_femsa/api/api_keys_api.rb +8 -8
- data/lib/digital_femsa/api/balances_api.rb +2 -2
- data/lib/digital_femsa/api/charges_api.rb +13 -9
- data/lib/digital_femsa/api/customers_api.rb +12 -12
- data/lib/digital_femsa/api/discounts_api.rb +12 -12
- data/lib/digital_femsa/api/events_api.rb +4 -4
- data/lib/digital_femsa/api/logs_api.rb +2 -2
- data/lib/digital_femsa/api/orders_api.rb +20 -20
- data/lib/digital_femsa/api/payment_link_api.rb +10 -86
- data/lib/digital_femsa/api/payment_methods_api.rb +8 -8
- data/lib/digital_femsa/api/products_api.rb +10 -10
- data/lib/digital_femsa/api/shipping_contacts_api.rb +8 -8
- data/lib/digital_femsa/api/shippings_api.rb +10 -10
- data/lib/digital_femsa/api/taxes_api.rb +10 -10
- data/lib/digital_femsa/api/transactions_api.rb +6 -6
- data/lib/digital_femsa/api/transfers_api.rb +8 -8
- data/lib/digital_femsa/api/webhook_keys_api.rb +14 -10
- data/lib/digital_femsa/api/webhooks_api.rb +23 -16
- data/lib/digital_femsa/api_client.rb +9 -5
- data/lib/digital_femsa/models/api_key_create_response.rb +1 -1
- data/lib/digital_femsa/models/api_key_request.rb +36 -1
- data/lib/digital_femsa/models/balance_response.rb +9 -9
- data/lib/digital_femsa/models/charge_order_response.rb +1 -1
- data/lib/digital_femsa/models/{order_next_action_response.rb → charge_order_response_channel.rb} +34 -18
- data/lib/digital_femsa/models/charge_request_payment_method.rb +3 -2
- data/lib/digital_femsa/models/charge_response.rb +15 -4
- data/lib/digital_femsa/models/charge_response_refunds_data.rb +23 -4
- data/lib/digital_femsa/models/charge_update_request.rb +1 -1
- data/lib/digital_femsa/models/charges_data_response.rb +15 -4
- data/lib/digital_femsa/models/checkout.rb +97 -81
- data/lib/digital_femsa/models/checkout_order_template.rb +4 -4
- data/lib/digital_femsa/models/checkout_order_template_customer_info.rb +1 -1
- data/lib/digital_femsa/models/checkout_request.rb +1 -1
- data/lib/digital_femsa/models/checkout_response.rb +1 -1
- data/lib/digital_femsa/models/create_customer_fiscal_entities_response.rb +10 -10
- data/lib/digital_femsa/models/customer.rb +57 -95
- data/lib/digital_femsa/models/customer_address.rb +7 -0
- data/lib/digital_femsa/models/customer_fiscal_entities_data_response.rb +10 -10
- data/lib/digital_femsa/models/customer_fiscal_entities_request.rb +13 -13
- data/lib/digital_femsa/models/customer_info.rb +13 -20
- data/lib/digital_femsa/models/customer_payment_method_request.rb +2 -2
- data/lib/digital_femsa/models/customer_payment_sources_inner.rb +104 -0
- data/lib/digital_femsa/models/customer_response.rb +122 -113
- data/lib/digital_femsa/models/customer_shipping_contacts_response.rb +2 -0
- data/lib/digital_femsa/models/customers_response.rb +1 -0
- data/lib/digital_femsa/models/events_resend_response.rb +1 -1
- data/lib/digital_femsa/models/get_charges_response.rb +21 -21
- data/lib/digital_femsa/models/get_transactions_response.rb +1 -1
- data/lib/digital_femsa/models/log_response.rb +1 -1
- data/lib/digital_femsa/models/logs_response.rb +1 -1
- data/lib/digital_femsa/models/order_fiscal_entity_response.rb +1 -1
- data/lib/digital_femsa/models/order_refund_request.rb +59 -11
- data/lib/digital_femsa/models/order_request.rb +69 -79
- data/lib/digital_femsa/models/order_response.rb +187 -119
- data/lib/digital_femsa/models/{order_next_action_response_redirect_to_url.rb → order_response_channel.rb} +35 -19
- data/lib/digital_femsa/models/order_response_charges.rb +1 -1
- data/lib/digital_femsa/models/order_response_checkout.rb +1 -0
- data/lib/digital_femsa/models/order_response_customer_info.rb +1 -0
- data/lib/digital_femsa/models/order_response_shipping_contact.rb +3 -0
- data/lib/digital_femsa/models/order_update_fiscal_entity_request.rb +1 -1
- data/lib/digital_femsa/models/order_update_request.rb +106 -65
- data/lib/digital_femsa/models/payment_method_cash.rb +1 -1
- data/lib/digital_femsa/models/payment_method_cash_request.rb +2 -1
- data/lib/digital_femsa/models/product.rb +103 -95
- data/lib/digital_femsa/models/product_data_response.rb +103 -95
- data/lib/digital_femsa/models/product_order_response.rb +103 -95
- data/lib/digital_femsa/models/shipping_order_response.rb +11 -1
- data/lib/digital_femsa/models/shipping_request.rb +12 -1
- data/lib/digital_femsa/models/transaction_response.rb +172 -99
- data/lib/digital_femsa/models/transfers_response.rb +1 -1
- data/lib/digital_femsa/models/transfers_response_destination.rb +312 -0
- data/lib/digital_femsa/models/update_customer.rb +42 -85
- data/lib/digital_femsa/models/update_customer_fiscal_entities_response.rb +10 -10
- data/lib/digital_femsa/models/update_order_discount_lines_request.rb +34 -0
- data/lib/digital_femsa/models/update_order_tax_request.rb +2 -2
- data/lib/digital_femsa/models/update_payment_methods_amount.rb +105 -0
- data/lib/digital_femsa/models/update_payment_methods_expires_at.rb +105 -0
- data/lib/digital_femsa/models/update_product.rb +85 -58
- data/lib/digital_femsa/models/webhook_key_delete_response.rb +1 -1
- data/lib/digital_femsa/models/webhook_key_request.rb +1 -0
- data/lib/digital_femsa/models/webhook_key_response.rb +1 -1
- data/lib/digital_femsa/models/webhook_request.rb +248 -9
- data/lib/digital_femsa/models/webhook_response.rb +1 -1
- data/lib/digital_femsa/models/webhook_update_request.rb +1 -1
- data/lib/digital_femsa/version.rb +1 -1
- data/lib/digital_femsa.rb +2 -6
- data/spec/api/balances_api_spec.rb +24 -22
- data/spec/api/charges_api_spec.rb +92 -49
- data/spec/api/companies_api_spec.rb +57 -35
- data/spec/api/customers_api_spec.rb +115 -99
- data/spec/api/events_api_spec.rb +72 -48
- data/spec/api/generated_apis_coverage_spec.rb +94 -0
- data/spec/api/logs_api_spec.rb +57 -38
- data/spec/api/orders_api_spec.rb +134 -108
- data/spec/api/payment_link_api_spec.rb +91 -81
- data/spec/api/payment_methods_api_spec.rb +102 -65
- data/spec/api/transactions_api_spec.rb +63 -41
- data/spec/api/transfers_api_spec.rb +57 -38
- data/spec/api/webhook_keys_api_spec.rb +87 -68
- data/spec/api/webhooks_api_spec.rb +110 -79
- data/spec/api_client_spec.rb +259 -0
- data/spec/models/generated_models_coverage_spec.rb +152 -0
- data/spec/models/webhook_request_ssrf_protection_spec.rb +275 -0
- data/spec/spec_helper.rb +37 -0
- data/templates/ruby/api_client.mustache +8 -4
- metadata +40 -37
- data/docs/CustomerAntifraudInfo.md +0 -20
- data/docs/CustomerAntifraudInfoResponse.md +0 -20
- data/docs/OrderNextActionResponse.md +0 -20
- data/docs/OrderNextActionResponseRedirectToUrl.md +0 -20
- data/docs/SmsCheckoutRequest.md +0 -18
- data/docs/UpdateCustomerAntifraudInfo.md +0 -20
data/spec/api/logs_api_spec.rb
CHANGED
|
@@ -13,54 +13,73 @@ Generator version: 7.5.0
|
|
|
13
13
|
require 'spec_helper'
|
|
14
14
|
require 'json'
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
before do
|
|
21
|
-
# run before each test
|
|
22
|
-
@api_instance = DigitalFemsa::LogsApi.new
|
|
23
|
-
end
|
|
16
|
+
RSpec.describe DigitalFemsa::LogsApi do
|
|
17
|
+
let(:config) { DigitalFemsa::Configuration.new }
|
|
18
|
+
let(:api_client) { instance_double(DigitalFemsa::ApiClient) }
|
|
19
|
+
let(:api_instance) { described_class.new(api_client) }
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
before do
|
|
22
|
+
allow(api_client).to receive(:config).and_return(config)
|
|
23
|
+
allow(api_client).to receive(:select_header_accept).and_return('application/vnd.app-v2.1.0+json')
|
|
27
24
|
end
|
|
28
25
|
|
|
29
26
|
describe 'test an instance of LogsApi' do
|
|
30
|
-
it '
|
|
31
|
-
expect(
|
|
27
|
+
it 'creates an instance of LogsApi' do
|
|
28
|
+
expect(api_instance).to be_instance_of(DigitalFemsa::LogsApi)
|
|
32
29
|
end
|
|
33
30
|
end
|
|
34
31
|
|
|
35
|
-
#
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
# @option opts [String] :accept_language Use for knowing which language to use
|
|
41
|
-
# @option opts [String] :x_child_company_id In the case of a holding company, the company id of the child company to which will process the request.
|
|
42
|
-
# @return [LogResponse]
|
|
43
|
-
describe 'get_log_by_id test' do
|
|
44
|
-
it 'should work' do
|
|
45
|
-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
|
|
32
|
+
describe '#get_log_by_id_with_http_info' do
|
|
33
|
+
it 'raises when id is missing' do
|
|
34
|
+
expect do
|
|
35
|
+
api_instance.get_log_by_id_with_http_info(nil)
|
|
36
|
+
end.to raise_error(ArgumentError, /Missing the required parameter 'id'/)
|
|
46
37
|
end
|
|
47
|
-
end
|
|
48
38
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
# @option opts [String] :_next next page
|
|
58
|
-
# @option opts [String] :previous previous page
|
|
59
|
-
# @return [LogsResponse]
|
|
60
|
-
describe 'get_logs test' do
|
|
61
|
-
it 'should work' do
|
|
62
|
-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
|
|
39
|
+
it 'sends GET request with escaped id path' do
|
|
40
|
+
expect(api_client).to receive(:call_api).with(:GET, '/logs/log%2F123', hash_including(
|
|
41
|
+
operation: :'LogsApi.get_log_by_id',
|
|
42
|
+
return_type: 'LogResponse'
|
|
43
|
+
)).and_return([:log, 200, {}])
|
|
44
|
+
|
|
45
|
+
data = api_instance.get_log_by_id('log/123')
|
|
46
|
+
expect(data).to eq(:log)
|
|
63
47
|
end
|
|
64
48
|
end
|
|
65
49
|
|
|
50
|
+
describe '#get_logs_with_http_info' do
|
|
51
|
+
it 'raises for limit higher than 250' do
|
|
52
|
+
expect do
|
|
53
|
+
api_instance.get_logs_with_http_info(limit: 251)
|
|
54
|
+
end.to raise_error(ArgumentError, /must be smaller than or equal to 250/)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'raises for limit lower than 1' do
|
|
58
|
+
expect do
|
|
59
|
+
api_instance.get_logs_with_http_info(limit: 0)
|
|
60
|
+
end.to raise_error(ArgumentError, /must be greater than or equal to 1/)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'maps pagination and search query params' do
|
|
64
|
+
expect(api_client).to receive(:call_api).with(:GET, '/logs', hash_including(
|
|
65
|
+
operation: :'LogsApi.get_logs',
|
|
66
|
+
query_params: {
|
|
67
|
+
limit: 15,
|
|
68
|
+
search: 'timeout',
|
|
69
|
+
next: 'next_token',
|
|
70
|
+
previous: 'prev_token'
|
|
71
|
+
},
|
|
72
|
+
return_type: 'LogsResponse'
|
|
73
|
+
)).and_return([:list, 200, {}])
|
|
74
|
+
|
|
75
|
+
data = api_instance.get_logs(
|
|
76
|
+
limit: 15,
|
|
77
|
+
search: 'timeout',
|
|
78
|
+
_next: 'next_token',
|
|
79
|
+
previous: 'prev_token'
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
expect(data).to eq(:list)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
66
85
|
end
|
data/spec/api/orders_api_spec.rb
CHANGED
|
@@ -13,141 +13,167 @@ Generator version: 7.5.0
|
|
|
13
13
|
require 'spec_helper'
|
|
14
14
|
require 'json'
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
before do
|
|
21
|
-
# run before each test
|
|
22
|
-
@api_instance = DigitalFemsa::OrdersApi.new
|
|
23
|
-
end
|
|
16
|
+
RSpec.describe DigitalFemsa::OrdersApi do
|
|
17
|
+
let(:config) { DigitalFemsa::Configuration.new }
|
|
18
|
+
let(:api_client) { instance_double(DigitalFemsa::ApiClient) }
|
|
19
|
+
let(:api_instance) { described_class.new(api_client) }
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
before do
|
|
22
|
+
allow(api_client).to receive(:config).and_return(config)
|
|
23
|
+
allow(api_client).to receive(:select_header_accept).and_return('application/vnd.app-v2.1.0+json')
|
|
24
|
+
allow(api_client).to receive(:select_header_content_type).and_return('application/json')
|
|
25
|
+
allow(api_client).to receive(:object_to_http_body) { |value| value.to_json }
|
|
27
26
|
end
|
|
28
27
|
|
|
29
28
|
describe 'test an instance of OrdersApi' do
|
|
30
|
-
it '
|
|
31
|
-
expect(
|
|
29
|
+
it 'creates an instance of OrdersApi' do
|
|
30
|
+
expect(api_instance).to be_instance_of(DigitalFemsa::OrdersApi)
|
|
32
31
|
end
|
|
33
32
|
end
|
|
34
33
|
|
|
35
|
-
#
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
# @option opts [String] :accept_language Use for knowing which language to use
|
|
41
|
-
# @option opts [String] :x_child_company_id In the case of a holding company, the company id of the child company to which will process the request.
|
|
42
|
-
# @return [OrderResponse]
|
|
43
|
-
describe 'cancel_order test' do
|
|
44
|
-
it 'should work' do
|
|
45
|
-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
|
|
34
|
+
describe '#cancel_order_with_http_info' do
|
|
35
|
+
it 'raises when id is missing' do
|
|
36
|
+
expect do
|
|
37
|
+
api_instance.cancel_order_with_http_info(nil)
|
|
38
|
+
end.to raise_error(ArgumentError, /Missing the required parameter 'id'/)
|
|
46
39
|
end
|
|
47
|
-
end
|
|
48
40
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
|
|
41
|
+
it 'builds escaped path and sends POST request' do
|
|
42
|
+
expect(api_client).to receive(:call_api).with(:POST, '/orders/order%2F123/cancel', hash_including(
|
|
43
|
+
operation: :'OrdersApi.cancel_order',
|
|
44
|
+
return_type: 'OrderResponse',
|
|
45
|
+
auth_names: ['bearerAuth']
|
|
46
|
+
)).and_return([:ok, 200, {}])
|
|
47
|
+
|
|
48
|
+
data, status, _headers = api_instance.cancel_order_with_http_info('order/123')
|
|
49
|
+
expect(data).to eq(:ok)
|
|
50
|
+
expect(status).to eq(200)
|
|
60
51
|
end
|
|
61
52
|
end
|
|
62
53
|
|
|
63
|
-
#
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
# @option opts [String] :accept_language Use for knowing which language to use
|
|
69
|
-
# @option opts [String] :x_child_company_id In the case of a holding company, the company id of the child company to which will process the request.
|
|
70
|
-
# @return [OrderResponse]
|
|
71
|
-
describe 'get_order_by_id test' do
|
|
72
|
-
it 'should work' do
|
|
73
|
-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
|
|
54
|
+
describe '#create_order_with_http_info' do
|
|
55
|
+
it 'raises when order_request is missing' do
|
|
56
|
+
expect do
|
|
57
|
+
api_instance.create_order_with_http_info(nil)
|
|
58
|
+
end.to raise_error(ArgumentError, /Missing the required parameter 'order_request'/)
|
|
74
59
|
end
|
|
75
|
-
end
|
|
76
60
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
describe 'get_orders test' do
|
|
89
|
-
it 'should work' do
|
|
90
|
-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
|
|
61
|
+
it 'sends serialized body and headers' do
|
|
62
|
+
payload = { amount: 1000, currency: 'MXN' }
|
|
63
|
+
|
|
64
|
+
expect(api_client).to receive(:call_api).with(:POST, '/orders', hash_including(
|
|
65
|
+
operation: :'OrdersApi.create_order',
|
|
66
|
+
body: payload.to_json,
|
|
67
|
+
return_type: 'OrderResponse'
|
|
68
|
+
)).and_return([:created, 201, {}])
|
|
69
|
+
|
|
70
|
+
data = api_instance.create_order(payload, accept_language: 'es', x_child_company_id: 'company_1')
|
|
71
|
+
expect(data).to eq(:created)
|
|
91
72
|
end
|
|
92
73
|
end
|
|
93
74
|
|
|
94
|
-
#
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
75
|
+
describe '#get_orders_with_http_info' do
|
|
76
|
+
it 'raises for limit higher than 250' do
|
|
77
|
+
expect do
|
|
78
|
+
api_instance.get_orders_with_http_info(limit: 251)
|
|
79
|
+
end.to raise_error(ArgumentError, /must be smaller than or equal to 250/)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it 'raises for limit lower than 1' do
|
|
83
|
+
expect do
|
|
84
|
+
api_instance.get_orders_with_http_info(limit: 0)
|
|
85
|
+
end.to raise_error(ArgumentError, /must be greater than or equal to 1/)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it 'maps pagination and search into query params' do
|
|
89
|
+
expect(api_client).to receive(:call_api).with(:GET, '/orders', hash_including(
|
|
90
|
+
operation: :'OrdersApi.get_orders',
|
|
91
|
+
query_params: {
|
|
92
|
+
limit: 10,
|
|
93
|
+
search: 'john',
|
|
94
|
+
next: 'next_token',
|
|
95
|
+
previous: 'prev_token'
|
|
96
|
+
},
|
|
97
|
+
return_type: 'GetOrdersResponse'
|
|
98
|
+
)).and_return([:list, 200, {}])
|
|
99
|
+
|
|
100
|
+
data = api_instance.get_orders(
|
|
101
|
+
limit: 10,
|
|
102
|
+
search: 'john',
|
|
103
|
+
_next: 'next_token',
|
|
104
|
+
previous: 'prev_token'
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
expect(data).to eq(:list)
|
|
106
108
|
end
|
|
107
109
|
end
|
|
108
110
|
|
|
109
|
-
#
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
111
|
+
describe '#order_cancel_refund_with_http_info' do
|
|
112
|
+
it 'raises when refund_id is missing' do
|
|
113
|
+
expect do
|
|
114
|
+
api_instance.order_cancel_refund_with_http_info('ord_123', nil)
|
|
115
|
+
end.to raise_error(ArgumentError, /Missing the required parameter 'refund_id'/)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it 'sends DELETE request with expected path' do
|
|
119
|
+
expect(api_client).to receive(:call_api).with(:DELETE, '/orders/ord_123/refunds/ref_123', hash_including(
|
|
120
|
+
operation: :'OrdersApi.order_cancel_refund',
|
|
121
|
+
return_type: 'OrderResponse'
|
|
122
|
+
)).and_return([:deleted, 200, {}])
|
|
123
|
+
|
|
124
|
+
data = api_instance.order_cancel_refund('ord_123', 'ref_123')
|
|
125
|
+
expect(data).to eq(:deleted)
|
|
121
126
|
end
|
|
122
127
|
end
|
|
123
128
|
|
|
124
|
-
#
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
129
|
+
describe '#order_refund_with_http_info' do
|
|
130
|
+
it 'sends refund payload in POST body' do
|
|
131
|
+
payload = { reason: 'requested_by_customer', amount: 500 }
|
|
132
|
+
|
|
133
|
+
expect(api_client).to receive(:call_api).with(:POST, '/orders/ord_123/refunds', hash_including(
|
|
134
|
+
operation: :'OrdersApi.order_refund',
|
|
135
|
+
body: payload.to_json,
|
|
136
|
+
return_type: 'OrderResponse'
|
|
137
|
+
)).and_return([:refunded, 200, {}])
|
|
138
|
+
|
|
139
|
+
data = api_instance.order_refund('ord_123', payload)
|
|
140
|
+
expect(data).to eq(:refunded)
|
|
136
141
|
end
|
|
137
142
|
end
|
|
138
143
|
|
|
139
|
-
#
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
144
|
+
describe '#orders_create_capture_with_http_info' do
|
|
145
|
+
it 'sends capture payload in POST body' do
|
|
146
|
+
payload = { amount: 300 }
|
|
147
|
+
|
|
148
|
+
expect(api_client).to receive(:call_api).with(:POST, '/orders/ord_123/capture', hash_including(
|
|
149
|
+
operation: :'OrdersApi.orders_create_capture',
|
|
150
|
+
body: payload.to_json,
|
|
151
|
+
return_type: 'OrderResponse'
|
|
152
|
+
)).and_return([:captured, 200, {}])
|
|
153
|
+
|
|
154
|
+
data = api_instance.orders_create_capture('ord_123', order_capture_request: payload)
|
|
155
|
+
expect(data).to eq(:captured)
|
|
150
156
|
end
|
|
151
157
|
end
|
|
152
158
|
|
|
159
|
+
describe '#update_order_with_http_info' do
|
|
160
|
+
it 'raises when order_update_request is missing' do
|
|
161
|
+
expect do
|
|
162
|
+
api_instance.update_order_with_http_info('ord_123', nil)
|
|
163
|
+
end.to raise_error(ArgumentError, /Missing the required parameter 'order_update_request'/)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
it 'sends PUT request with serialized body' do
|
|
167
|
+
payload = { metadata: { source: 'tests' } }
|
|
168
|
+
|
|
169
|
+
expect(api_client).to receive(:call_api).with(:PUT, '/orders/ord_123', hash_including(
|
|
170
|
+
operation: :'OrdersApi.update_order',
|
|
171
|
+
body: payload.to_json,
|
|
172
|
+
return_type: 'OrderResponse'
|
|
173
|
+
)).and_return([:updated, 200, {}])
|
|
174
|
+
|
|
175
|
+
data = api_instance.update_order('ord_123', payload, accept_language: 'en')
|
|
176
|
+
expect(data).to eq(:updated)
|
|
177
|
+
end
|
|
178
|
+
end
|
|
153
179
|
end
|
|
@@ -13,107 +13,117 @@ Generator version: 7.5.0
|
|
|
13
13
|
require 'spec_helper'
|
|
14
14
|
require 'json'
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
before do
|
|
21
|
-
# run before each test
|
|
22
|
-
@api_instance = DigitalFemsa::PaymentLinkApi.new
|
|
23
|
-
end
|
|
16
|
+
RSpec.describe DigitalFemsa::PaymentLinkApi do
|
|
17
|
+
let(:config) { DigitalFemsa::Configuration.new }
|
|
18
|
+
let(:api_client) { instance_double(DigitalFemsa::ApiClient) }
|
|
19
|
+
let(:api_instance) { described_class.new(api_client) }
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
before do
|
|
22
|
+
allow(api_client).to receive(:config).and_return(config)
|
|
23
|
+
allow(api_client).to receive(:select_header_accept).and_return('application/vnd.app-v2.1.0+json')
|
|
24
|
+
allow(api_client).to receive(:select_header_content_type).and_return('application/json')
|
|
25
|
+
allow(api_client).to receive(:object_to_http_body) { |value| value.to_json }
|
|
27
26
|
end
|
|
28
27
|
|
|
29
28
|
describe 'test an instance of PaymentLinkApi' do
|
|
30
|
-
it '
|
|
31
|
-
expect(
|
|
29
|
+
it 'creates an instance of PaymentLinkApi' do
|
|
30
|
+
expect(api_instance).to be_instance_of(DigitalFemsa::PaymentLinkApi)
|
|
32
31
|
end
|
|
33
32
|
end
|
|
34
33
|
|
|
35
|
-
#
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
# @option opts [String] :x_child_company_id In the case of a holding company, the company id of the child company to which will process the request.
|
|
41
|
-
# @return [CheckoutResponse]
|
|
42
|
-
describe 'cancel_checkout test' do
|
|
43
|
-
it 'should work' do
|
|
44
|
-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
|
|
34
|
+
describe '#cancel_checkout_with_http_info' do
|
|
35
|
+
it 'raises when id is missing' do
|
|
36
|
+
expect do
|
|
37
|
+
api_instance.cancel_checkout_with_http_info(nil)
|
|
38
|
+
end.to raise_error(ArgumentError, /Missing the required parameter 'id'/)
|
|
45
39
|
end
|
|
46
|
-
end
|
|
47
40
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
it 'should work' do
|
|
57
|
-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
|
|
41
|
+
it 'sends PUT request with escaped path' do
|
|
42
|
+
expect(api_client).to receive(:call_api).with(:PUT, '/checkouts/cko%2F123/cancel', hash_including(
|
|
43
|
+
operation: :'PaymentLinkApi.cancel_checkout',
|
|
44
|
+
return_type: 'CheckoutResponse'
|
|
45
|
+
)).and_return([:cancelled, 200, {}])
|
|
46
|
+
|
|
47
|
+
data = api_instance.cancel_checkout('cko/123')
|
|
48
|
+
expect(data).to eq(:cancelled)
|
|
58
49
|
end
|
|
59
50
|
end
|
|
60
51
|
|
|
61
|
-
#
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
# @option opts [String] :accept_language Use for knowing which language to use
|
|
67
|
-
# @option opts [String] :x_child_company_id In the case of a holding company, the company id of the child company to which will process the request.
|
|
68
|
-
# @return [CheckoutResponse]
|
|
69
|
-
describe 'email_checkout test' do
|
|
70
|
-
it 'should work' do
|
|
71
|
-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
|
|
52
|
+
describe '#create_checkout_with_http_info' do
|
|
53
|
+
it 'raises when checkout payload is missing' do
|
|
54
|
+
expect do
|
|
55
|
+
api_instance.create_checkout_with_http_info(nil)
|
|
56
|
+
end.to raise_error(ArgumentError, /Missing the required parameter 'checkout'/)
|
|
72
57
|
end
|
|
73
|
-
end
|
|
74
58
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
59
|
+
it 'sends POST request with serialized body' do
|
|
60
|
+
payload = { name: 'Checkout Link', recurrent: false }
|
|
61
|
+
|
|
62
|
+
expect(api_client).to receive(:call_api).with(:POST, '/checkouts', hash_including(
|
|
63
|
+
operation: :'PaymentLinkApi.create_checkout',
|
|
64
|
+
body: payload.to_json,
|
|
65
|
+
return_type: 'CheckoutResponse'
|
|
66
|
+
)).and_return([:created, 201, {}])
|
|
67
|
+
|
|
68
|
+
data = api_instance.create_checkout(payload)
|
|
69
|
+
expect(data).to eq(:created)
|
|
85
70
|
end
|
|
86
71
|
end
|
|
87
72
|
|
|
88
|
-
#
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
# @option opts [String] :x_child_company_id In the case of a holding company, the company id of the child company to which will process the request.
|
|
94
|
-
# @option opts [Integer] :limit The numbers of items to return, the maximum value is 250
|
|
95
|
-
# @option opts [String] :search General order search, e.g. by mail, reference etc.
|
|
96
|
-
# @option opts [String] :_next next page
|
|
97
|
-
# @option opts [String] :previous previous page
|
|
98
|
-
# @return [CheckoutsResponse]
|
|
99
|
-
describe 'get_checkouts test' do
|
|
100
|
-
it 'should work' do
|
|
101
|
-
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
|
|
73
|
+
describe '#email_checkout_with_http_info' do
|
|
74
|
+
it 'raises when email payload is missing' do
|
|
75
|
+
expect do
|
|
76
|
+
api_instance.email_checkout_with_http_info('cko_123', nil)
|
|
77
|
+
end.to raise_error(ArgumentError, /Missing the required parameter 'email_checkout_request'/)
|
|
102
78
|
end
|
|
103
|
-
end
|
|
104
79
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
80
|
+
it 'sends POST request to email endpoint' do
|
|
81
|
+
payload = { email: 'buyer@example.com' }
|
|
82
|
+
|
|
83
|
+
expect(api_client).to receive(:call_api).with(:POST, '/checkouts/cko_123/email', hash_including(
|
|
84
|
+
operation: :'PaymentLinkApi.email_checkout',
|
|
85
|
+
body: payload.to_json,
|
|
86
|
+
return_type: 'CheckoutResponse'
|
|
87
|
+
)).and_return([:sent, 200, {}])
|
|
88
|
+
|
|
89
|
+
data = api_instance.email_checkout('cko_123', payload)
|
|
90
|
+
expect(data).to eq(:sent)
|
|
116
91
|
end
|
|
117
92
|
end
|
|
118
93
|
|
|
94
|
+
describe '#get_checkouts_with_http_info' do
|
|
95
|
+
it 'raises for limit higher than 250' do
|
|
96
|
+
expect do
|
|
97
|
+
api_instance.get_checkouts_with_http_info(limit: 251)
|
|
98
|
+
end.to raise_error(ArgumentError, /must be smaller than or equal to 250/)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it 'raises for limit lower than 1' do
|
|
102
|
+
expect do
|
|
103
|
+
api_instance.get_checkouts_with_http_info(limit: 0)
|
|
104
|
+
end.to raise_error(ArgumentError, /must be greater than or equal to 1/)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it 'maps pagination and search into query params' do
|
|
108
|
+
expect(api_client).to receive(:call_api).with(:GET, '/checkouts', hash_including(
|
|
109
|
+
operation: :'PaymentLinkApi.get_checkouts',
|
|
110
|
+
query_params: {
|
|
111
|
+
limit: 30,
|
|
112
|
+
search: 'order_123',
|
|
113
|
+
next: 'next_token',
|
|
114
|
+
previous: 'prev_token'
|
|
115
|
+
},
|
|
116
|
+
return_type: 'CheckoutsResponse'
|
|
117
|
+
)).and_return([:list, 200, {}])
|
|
118
|
+
|
|
119
|
+
data = api_instance.get_checkouts(
|
|
120
|
+
limit: 30,
|
|
121
|
+
search: 'order_123',
|
|
122
|
+
_next: 'next_token',
|
|
123
|
+
previous: 'prev_token'
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
expect(data).to eq(:list)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
119
129
|
end
|