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.
Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +104 -0
  4. data/Makefile +14 -0
  5. data/README.md +28 -33
  6. data/VERSION +1 -1
  7. data/config-ruby.json +1 -1
  8. data/digital_femsa.gemspec +1 -1
  9. data/docs/ApiKeyCreateResponse.md +1 -1
  10. data/docs/ApiKeyRequest.md +2 -2
  11. data/docs/ApiKeyResponseOnDelete.md +2 -2
  12. data/docs/ApiKeysApi.md +10 -10
  13. data/docs/BalanceResponse.md +8 -8
  14. data/docs/BalancesApi.md +1 -1
  15. data/docs/ChargeOrderResponse.md +1 -1
  16. data/docs/ChargeOrderResponseChannel.md +24 -0
  17. data/docs/ChargeRequest.md +1 -1
  18. data/docs/ChargeRequestPaymentMethod.md +3 -3
  19. data/docs/ChargeResponse.md +9 -7
  20. data/docs/ChargeResponseChannel.md +3 -3
  21. data/docs/ChargeResponseRefundsData.md +5 -1
  22. data/docs/ChargesApi.md +16 -12
  23. data/docs/ChargesDataResponse.md +9 -7
  24. data/docs/Checkout.md +17 -15
  25. data/docs/CheckoutOrderTemplate.md +3 -3
  26. data/docs/CheckoutResponse.md +1 -1
  27. data/docs/CreateCustomerFiscalEntitiesResponse.md +2 -2
  28. data/docs/Customer.md +13 -19
  29. data/docs/CustomerAddress.md +2 -2
  30. data/docs/CustomerFiscalEntitiesDataResponse.md +2 -2
  31. data/docs/CustomerFiscalEntitiesRequest.md +3 -3
  32. data/docs/CustomerInfo.md +4 -4
  33. data/docs/CustomerPaymentMethodRequest.md +1 -1
  34. data/docs/CustomerResponse.md +17 -21
  35. data/docs/CustomerShippingContactsResponse.md +5 -5
  36. data/docs/CustomersApi.md +15 -15
  37. data/docs/CustomersResponse.md +1 -1
  38. data/docs/DeleteApiKeysResponse.md +1 -1
  39. data/docs/DiscountsApi.md +9 -9
  40. data/docs/EventsApi.md +2 -2
  41. data/docs/EventsResendResponse.md +1 -1
  42. data/docs/GetChargesResponse.md +4 -4
  43. data/docs/GetTransactionsResponse.md +1 -1
  44. data/docs/LogsApi.md +1 -1
  45. data/docs/OrderFiscalEntityRequest.md +4 -4
  46. data/docs/OrderRefundRequest.md +7 -5
  47. data/docs/OrderRequest.md +17 -19
  48. data/docs/OrderResponse.md +37 -35
  49. data/docs/OrderResponseChannel.md +24 -0
  50. data/docs/OrderResponseShippingContact.md +4 -4
  51. data/docs/OrderUpdateFiscalEntityRequest.md +1 -1
  52. data/docs/OrderUpdateRequest.md +19 -15
  53. data/docs/OrdersApi.md +16 -16
  54. data/docs/PaymentLinkApi.md +12 -82
  55. data/docs/PaymentMethodCash.md +4 -4
  56. data/docs/PaymentMethodCashRequest.md +2 -2
  57. data/docs/PaymentMethodsApi.md +5 -5
  58. data/docs/Product.md +10 -12
  59. data/docs/ProductDataResponse.md +9 -11
  60. data/docs/ProductOrderResponse.md +9 -11
  61. data/docs/ProductsApi.md +7 -7
  62. data/docs/ShippingContactsApi.md +9 -9
  63. data/docs/ShippingOrderResponse.md +5 -3
  64. data/docs/ShippingRequest.md +2 -0
  65. data/docs/ShippingsApi.md +7 -7
  66. data/docs/TaxesApi.md +7 -7
  67. data/docs/TransactionResponse.md +20 -14
  68. data/docs/TransactionsApi.md +6 -6
  69. data/docs/TransfersApi.md +10 -10
  70. data/docs/UpdateCustomer.md +17 -21
  71. data/docs/UpdateCustomerFiscalEntitiesResponse.md +2 -2
  72. data/docs/UpdateOrderTaxRequest.md +2 -2
  73. data/docs/UpdateProduct.md +7 -9
  74. data/docs/WebhookKeysApi.md +18 -14
  75. data/docs/WebhooksApi.md +28 -22
  76. data/lib/digital_femsa/api/api_keys_api.rb +8 -8
  77. data/lib/digital_femsa/api/balances_api.rb +2 -2
  78. data/lib/digital_femsa/api/charges_api.rb +13 -9
  79. data/lib/digital_femsa/api/customers_api.rb +12 -12
  80. data/lib/digital_femsa/api/discounts_api.rb +12 -12
  81. data/lib/digital_femsa/api/events_api.rb +4 -4
  82. data/lib/digital_femsa/api/logs_api.rb +2 -2
  83. data/lib/digital_femsa/api/orders_api.rb +20 -20
  84. data/lib/digital_femsa/api/payment_link_api.rb +10 -86
  85. data/lib/digital_femsa/api/payment_methods_api.rb +8 -8
  86. data/lib/digital_femsa/api/products_api.rb +10 -10
  87. data/lib/digital_femsa/api/shipping_contacts_api.rb +8 -8
  88. data/lib/digital_femsa/api/shippings_api.rb +10 -10
  89. data/lib/digital_femsa/api/taxes_api.rb +10 -10
  90. data/lib/digital_femsa/api/transactions_api.rb +6 -6
  91. data/lib/digital_femsa/api/transfers_api.rb +8 -8
  92. data/lib/digital_femsa/api/webhook_keys_api.rb +14 -10
  93. data/lib/digital_femsa/api/webhooks_api.rb +23 -16
  94. data/lib/digital_femsa/api_client.rb +9 -5
  95. data/lib/digital_femsa/models/api_key_create_response.rb +1 -1
  96. data/lib/digital_femsa/models/api_key_request.rb +36 -1
  97. data/lib/digital_femsa/models/balance_response.rb +9 -9
  98. data/lib/digital_femsa/models/charge_order_response.rb +1 -1
  99. data/lib/digital_femsa/models/{order_next_action_response.rb → charge_order_response_channel.rb} +34 -18
  100. data/lib/digital_femsa/models/charge_request_payment_method.rb +3 -2
  101. data/lib/digital_femsa/models/charge_response.rb +15 -4
  102. data/lib/digital_femsa/models/charge_response_refunds_data.rb +23 -4
  103. data/lib/digital_femsa/models/charge_update_request.rb +1 -1
  104. data/lib/digital_femsa/models/charges_data_response.rb +15 -4
  105. data/lib/digital_femsa/models/checkout.rb +97 -81
  106. data/lib/digital_femsa/models/checkout_order_template.rb +4 -4
  107. data/lib/digital_femsa/models/checkout_order_template_customer_info.rb +1 -1
  108. data/lib/digital_femsa/models/checkout_request.rb +1 -1
  109. data/lib/digital_femsa/models/checkout_response.rb +1 -1
  110. data/lib/digital_femsa/models/create_customer_fiscal_entities_response.rb +10 -10
  111. data/lib/digital_femsa/models/customer.rb +57 -95
  112. data/lib/digital_femsa/models/customer_address.rb +7 -0
  113. data/lib/digital_femsa/models/customer_fiscal_entities_data_response.rb +10 -10
  114. data/lib/digital_femsa/models/customer_fiscal_entities_request.rb +13 -13
  115. data/lib/digital_femsa/models/customer_info.rb +13 -20
  116. data/lib/digital_femsa/models/customer_payment_method_request.rb +2 -2
  117. data/lib/digital_femsa/models/customer_payment_sources_inner.rb +104 -0
  118. data/lib/digital_femsa/models/customer_response.rb +122 -113
  119. data/lib/digital_femsa/models/customer_shipping_contacts_response.rb +2 -0
  120. data/lib/digital_femsa/models/customers_response.rb +1 -0
  121. data/lib/digital_femsa/models/events_resend_response.rb +1 -1
  122. data/lib/digital_femsa/models/get_charges_response.rb +21 -21
  123. data/lib/digital_femsa/models/get_transactions_response.rb +1 -1
  124. data/lib/digital_femsa/models/log_response.rb +1 -1
  125. data/lib/digital_femsa/models/logs_response.rb +1 -1
  126. data/lib/digital_femsa/models/order_fiscal_entity_response.rb +1 -1
  127. data/lib/digital_femsa/models/order_refund_request.rb +59 -11
  128. data/lib/digital_femsa/models/order_request.rb +69 -79
  129. data/lib/digital_femsa/models/order_response.rb +187 -119
  130. data/lib/digital_femsa/models/{order_next_action_response_redirect_to_url.rb → order_response_channel.rb} +35 -19
  131. data/lib/digital_femsa/models/order_response_charges.rb +1 -1
  132. data/lib/digital_femsa/models/order_response_checkout.rb +1 -0
  133. data/lib/digital_femsa/models/order_response_customer_info.rb +1 -0
  134. data/lib/digital_femsa/models/order_response_shipping_contact.rb +3 -0
  135. data/lib/digital_femsa/models/order_update_fiscal_entity_request.rb +1 -1
  136. data/lib/digital_femsa/models/order_update_request.rb +106 -65
  137. data/lib/digital_femsa/models/payment_method_cash.rb +1 -1
  138. data/lib/digital_femsa/models/payment_method_cash_request.rb +2 -1
  139. data/lib/digital_femsa/models/product.rb +103 -95
  140. data/lib/digital_femsa/models/product_data_response.rb +103 -95
  141. data/lib/digital_femsa/models/product_order_response.rb +103 -95
  142. data/lib/digital_femsa/models/shipping_order_response.rb +11 -1
  143. data/lib/digital_femsa/models/shipping_request.rb +12 -1
  144. data/lib/digital_femsa/models/transaction_response.rb +172 -99
  145. data/lib/digital_femsa/models/transfers_response.rb +1 -1
  146. data/lib/digital_femsa/models/transfers_response_destination.rb +312 -0
  147. data/lib/digital_femsa/models/update_customer.rb +42 -85
  148. data/lib/digital_femsa/models/update_customer_fiscal_entities_response.rb +10 -10
  149. data/lib/digital_femsa/models/update_order_discount_lines_request.rb +34 -0
  150. data/lib/digital_femsa/models/update_order_tax_request.rb +2 -2
  151. data/lib/digital_femsa/models/update_payment_methods_amount.rb +105 -0
  152. data/lib/digital_femsa/models/update_payment_methods_expires_at.rb +105 -0
  153. data/lib/digital_femsa/models/update_product.rb +85 -58
  154. data/lib/digital_femsa/models/webhook_key_delete_response.rb +1 -1
  155. data/lib/digital_femsa/models/webhook_key_request.rb +1 -0
  156. data/lib/digital_femsa/models/webhook_key_response.rb +1 -1
  157. data/lib/digital_femsa/models/webhook_request.rb +248 -9
  158. data/lib/digital_femsa/models/webhook_response.rb +1 -1
  159. data/lib/digital_femsa/models/webhook_update_request.rb +1 -1
  160. data/lib/digital_femsa/version.rb +1 -1
  161. data/lib/digital_femsa.rb +2 -6
  162. data/spec/api/balances_api_spec.rb +24 -22
  163. data/spec/api/charges_api_spec.rb +92 -49
  164. data/spec/api/companies_api_spec.rb +57 -35
  165. data/spec/api/customers_api_spec.rb +115 -99
  166. data/spec/api/events_api_spec.rb +72 -48
  167. data/spec/api/generated_apis_coverage_spec.rb +94 -0
  168. data/spec/api/logs_api_spec.rb +57 -38
  169. data/spec/api/orders_api_spec.rb +134 -108
  170. data/spec/api/payment_link_api_spec.rb +91 -81
  171. data/spec/api/payment_methods_api_spec.rb +102 -65
  172. data/spec/api/transactions_api_spec.rb +63 -41
  173. data/spec/api/transfers_api_spec.rb +57 -38
  174. data/spec/api/webhook_keys_api_spec.rb +87 -68
  175. data/spec/api/webhooks_api_spec.rb +110 -79
  176. data/spec/api_client_spec.rb +259 -0
  177. data/spec/models/generated_models_coverage_spec.rb +152 -0
  178. data/spec/models/webhook_request_ssrf_protection_spec.rb +275 -0
  179. data/spec/spec_helper.rb +37 -0
  180. data/templates/ruby/api_client.mustache +8 -4
  181. metadata +40 -37
  182. data/docs/CustomerAntifraudInfo.md +0 -20
  183. data/docs/CustomerAntifraudInfoResponse.md +0 -20
  184. data/docs/OrderNextActionResponse.md +0 -20
  185. data/docs/OrderNextActionResponseRedirectToUrl.md +0 -20
  186. data/docs/SmsCheckoutRequest.md +0 -18
  187. data/docs/UpdateCustomerAntifraudInfo.md +0 -20
@@ -13,87 +13,124 @@ Generator version: 7.5.0
13
13
  require 'spec_helper'
14
14
  require 'json'
15
15
 
16
- # Unit tests for DigitalFemsa::PaymentMethodsApi
17
- # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
- # Please update as you see appropriate
19
- describe 'PaymentMethodsApi' do
20
- before do
21
- # run before each test
22
- @api_instance = DigitalFemsa::PaymentMethodsApi.new
23
- end
16
+ RSpec.describe DigitalFemsa::PaymentMethodsApi 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
- after do
26
- # run after each test
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 PaymentMethodsApi' do
30
- it 'should create an instance of PaymentMethodsApi' do
31
- expect(@api_instance).to be_instance_of(DigitalFemsa::PaymentMethodsApi)
29
+ it 'creates an instance of PaymentMethodsApi' do
30
+ expect(api_instance).to be_instance_of(DigitalFemsa::PaymentMethodsApi)
32
31
  end
33
32
  end
34
33
 
35
- # unit tests for create_customer_payment_methods
36
- # Create Payment Method
37
- # Create a payment method for a customer.
38
- # @param id Identifier of the resource
39
- # @param create_customer_payment_methods_request requested field for customer payment methods
40
- # @param [Hash] opts the optional parameters
41
- # @option opts [String] :accept_language Use for knowing which language to use
42
- # @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.
43
- # @return [CreateCustomerPaymentMethodsResponse]
44
- describe 'create_customer_payment_methods test' do
45
- it 'should work' do
46
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
34
+ describe '#create_customer_payment_methods_with_http_info' do
35
+ it 'raises when customer id is missing' do
36
+ expect do
37
+ api_instance.create_customer_payment_methods_with_http_info(nil, { type: 'oxxo' })
38
+ end.to raise_error(ArgumentError, /Missing the required parameter 'id'/)
39
+ end
40
+
41
+ it 'raises when payment method payload is missing' do
42
+ expect do
43
+ api_instance.create_customer_payment_methods_with_http_info('cus_123', nil)
44
+ end.to raise_error(ArgumentError, /Missing the required parameter 'create_customer_payment_methods_request'/)
47
45
  end
48
- end
49
46
 
50
- # unit tests for delete_customer_payment_methods
51
- # Delete Payment Method
52
- # Delete an existing payment method
53
- # @param id Identifier of the resource
54
- # @param payment_method_id Identifier of the payment method
55
- # @param [Hash] opts the optional parameters
56
- # @option opts [String] :accept_language Use for knowing which language to use
57
- # @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.
58
- # @return [UpdateCustomerPaymentMethodsResponse]
59
- describe 'delete_customer_payment_methods test' do
60
- it 'should work' do
61
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
47
+ it 'sends POST request with escaped customer path and serialized body' do
48
+ payload = { type: 'card', token_id: 'tok_123' }
49
+
50
+ expect(api_client).to receive(:call_api).with(:POST, '/customers/cus%2F123/payment_sources', hash_including(
51
+ operation: :'PaymentMethodsApi.create_customer_payment_methods',
52
+ body: payload.to_json,
53
+ return_type: 'CreateCustomerPaymentMethodsResponse'
54
+ )).and_return([:created, 201, {}])
55
+
56
+ data = api_instance.create_customer_payment_methods('cus/123', payload)
57
+ expect(data).to eq(:created)
62
58
  end
63
59
  end
64
60
 
65
- # unit tests for get_customer_payment_methods
66
- # Get Payment Methods
67
- # Get a list of Payment Methods
68
- # @param id Identifier of the resource
69
- # @param [Hash] opts the optional parameters
70
- # @option opts [String] :accept_language Use for knowing which language to use
71
- # @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.
72
- # @option opts [Integer] :limit The numbers of items to return, the maximum value is 250
73
- # @option opts [String] :_next next page
74
- # @option opts [String] :previous previous page
75
- # @option opts [String] :search General order search, e.g. by mail, reference etc.
76
- # @return [GetPaymentMethodResponse]
77
- describe 'get_customer_payment_methods test' do
78
- it 'should work' do
79
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
61
+ describe '#delete_customer_payment_methods_with_http_info' do
62
+ it 'raises when payment_method_id is missing' do
63
+ expect do
64
+ api_instance.delete_customer_payment_methods_with_http_info('cus_123', nil)
65
+ end.to raise_error(ArgumentError, /Missing the required parameter 'payment_method_id'/)
66
+ end
67
+
68
+ it 'sends DELETE request with escaped path components' do
69
+ expect(api_client).to receive(:call_api).with(:DELETE, '/customers/cus%2F123/payment_sources/pm%2F123', hash_including(
70
+ operation: :'PaymentMethodsApi.delete_customer_payment_methods',
71
+ return_type: 'UpdateCustomerPaymentMethodsResponse'
72
+ )).and_return([:deleted, 200, {}])
73
+
74
+ data = api_instance.delete_customer_payment_methods('cus/123', 'pm/123')
75
+ expect(data).to eq(:deleted)
80
76
  end
81
77
  end
82
78
 
83
- # unit tests for update_customer_payment_methods
84
- # Update Payment Method
85
- # Gets a payment Method that corresponds to a customer ID.
86
- # @param id Identifier of the resource
87
- # @param payment_method_id Identifier of the payment method
88
- # @param update_payment_methods requested field for customer payment methods
89
- # @param [Hash] opts the optional parameters
90
- # @option opts [String] :accept_language Use for knowing which language to use
91
- # @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.
92
- # @return [UpdateCustomerPaymentMethodsResponse]
93
- describe 'update_customer_payment_methods test' do
94
- it 'should work' do
95
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
79
+ describe '#get_customer_payment_methods_with_http_info' do
80
+ it 'raises for limit higher than 250' do
81
+ expect do
82
+ api_instance.get_customer_payment_methods_with_http_info('cus_123', limit: 251)
83
+ end.to raise_error(ArgumentError, /must be smaller than or equal to 250/)
84
+ end
85
+
86
+ it 'raises for limit lower than 1' do
87
+ expect do
88
+ api_instance.get_customer_payment_methods_with_http_info('cus_123', limit: 0)
89
+ end.to raise_error(ArgumentError, /must be greater than or equal to 1/)
90
+ end
91
+
92
+ it 'maps pagination and search filters to query params' do
93
+ expect(api_client).to receive(:call_api).with(:GET, '/customers/cus_123/payment_sources', hash_including(
94
+ operation: :'PaymentMethodsApi.get_customer_payment_methods',
95
+ query_params: {
96
+ limit: 40,
97
+ next: 'next_token',
98
+ previous: 'prev_token',
99
+ search: 'card'
100
+ },
101
+ return_type: 'GetPaymentMethodResponse'
102
+ )).and_return([:list, 200, {}])
103
+
104
+ data = api_instance.get_customer_payment_methods(
105
+ 'cus_123',
106
+ limit: 40,
107
+ _next: 'next_token',
108
+ previous: 'prev_token',
109
+ search: 'card'
110
+ )
111
+
112
+ expect(data).to eq(:list)
96
113
  end
97
114
  end
98
115
 
116
+ describe '#update_customer_payment_methods_with_http_info' do
117
+ it 'raises when update payload is missing' do
118
+ expect do
119
+ api_instance.update_customer_payment_methods_with_http_info('cus_123', 'pm_123', nil)
120
+ end.to raise_error(ArgumentError, /Missing the required parameter 'update_payment_methods'/)
121
+ end
122
+
123
+ it 'sends PUT request with serialized body' do
124
+ payload = { expires_at: 1_700_000_000 }
125
+
126
+ expect(api_client).to receive(:call_api).with(:PUT, '/customers/cus_123/payment_sources/pm_123', hash_including(
127
+ operation: :'PaymentMethodsApi.update_customer_payment_methods',
128
+ body: payload.to_json,
129
+ return_type: 'UpdateCustomerPaymentMethodsResponse'
130
+ )).and_return([:updated, 200, {}])
131
+
132
+ data = api_instance.update_customer_payment_methods('cus_123', 'pm_123', payload)
133
+ expect(data).to eq(:updated)
134
+ end
135
+ end
99
136
  end
@@ -13,57 +13,79 @@ Generator version: 7.5.0
13
13
  require 'spec_helper'
14
14
  require 'json'
15
15
 
16
- # Unit tests for DigitalFemsa::TransactionsApi
17
- # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
- # Please update as you see appropriate
19
- describe 'TransactionsApi' do
20
- before do
21
- # run before each test
22
- @api_instance = DigitalFemsa::TransactionsApi.new
23
- end
16
+ RSpec.describe DigitalFemsa::TransactionsApi 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
- after do
26
- # run after each test
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 TransactionsApi' do
30
- it 'should create an instance of TransactionsApi' do
31
- expect(@api_instance).to be_instance_of(DigitalFemsa::TransactionsApi)
27
+ it 'creates an instance of TransactionsApi' do
28
+ expect(api_instance).to be_instance_of(DigitalFemsa::TransactionsApi)
32
29
  end
33
30
  end
34
31
 
35
- # unit tests for get_transaction
36
- # Get transaction
37
- # Get the details of a transaction
38
- # @param id Identifier of the resource
39
- # @param [Hash] opts the optional parameters
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 [TransactionResponse]
43
- describe 'get_transaction 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_transaction_with_http_info' do
33
+ it 'raises when id is missing' do
34
+ expect do
35
+ api_instance.get_transaction_with_http_info(nil)
36
+ end.to raise_error(ArgumentError, /Missing the required parameter 'id'/)
46
37
  end
47
- end
48
38
 
49
- # unit tests for get_transactions
50
- # Get List transactions
51
- # Get transaction details in the form of a list
52
- # @param [Hash] opts the optional parameters
53
- # @option opts [String] :accept_language Use for knowing which language to use
54
- # @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.
55
- # @option opts [Integer] :limit The numbers of items to return, the maximum value is 250
56
- # @option opts [String] :_next next page
57
- # @option opts [String] :previous previous page
58
- # @option opts [String] :id id of the object to be retrieved
59
- # @option opts [String] :charge_id id of the charge used for filtering
60
- # @option opts [String] :type type of the object to be retrieved
61
- # @option opts [String] :currency currency of the object to be retrieved
62
- # @return [GetTransactionsResponse]
63
- describe 'get_transactions test' do
64
- it 'should work' do
65
- # 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, '/transactions/trx%2F123', hash_including(
41
+ operation: :'TransactionsApi.get_transaction',
42
+ return_type: 'TransactionResponse'
43
+ )).and_return([:transaction, 200, {}])
44
+
45
+ data = api_instance.get_transaction('trx/123')
46
+ expect(data).to eq(:transaction)
66
47
  end
67
48
  end
68
49
 
50
+ describe '#get_transactions_with_http_info' do
51
+ it 'raises for limit higher than 250' do
52
+ expect do
53
+ api_instance.get_transactions_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_transactions_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 filters into query params' do
64
+ expect(api_client).to receive(:call_api).with(:GET, '/transactions', hash_including(
65
+ operation: :'TransactionsApi.get_transactions',
66
+ query_params: {
67
+ limit: 50,
68
+ next: 'next_token',
69
+ previous: 'prev_token',
70
+ id: 'txn_filter',
71
+ charge_id: 'chg_123',
72
+ type: 'debit',
73
+ currency: 'MXN'
74
+ },
75
+ return_type: 'GetTransactionsResponse'
76
+ )).and_return([:list, 200, {}])
77
+
78
+ data = api_instance.get_transactions(
79
+ limit: 50,
80
+ _next: 'next_token',
81
+ previous: 'prev_token',
82
+ id: 'txn_filter',
83
+ charge_id: 'chg_123',
84
+ type: 'debit',
85
+ currency: 'MXN'
86
+ )
87
+
88
+ expect(data).to eq(:list)
89
+ end
90
+ end
69
91
  end
@@ -13,54 +13,73 @@ Generator version: 7.5.0
13
13
  require 'spec_helper'
14
14
  require 'json'
15
15
 
16
- # Unit tests for DigitalFemsa::TransfersApi
17
- # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
- # Please update as you see appropriate
19
- describe 'TransfersApi' do
20
- before do
21
- # run before each test
22
- @api_instance = DigitalFemsa::TransfersApi.new
23
- end
16
+ RSpec.describe DigitalFemsa::TransfersApi 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
- after do
26
- # run after each test
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 TransfersApi' do
30
- it 'should create an instance of TransfersApi' do
31
- expect(@api_instance).to be_instance_of(DigitalFemsa::TransfersApi)
27
+ it 'creates an instance of TransfersApi' do
28
+ expect(api_instance).to be_instance_of(DigitalFemsa::TransfersApi)
32
29
  end
33
30
  end
34
31
 
35
- # unit tests for get_transfer
36
- # Get Transfer
37
- # Get the details of a Transfer
38
- # @param id Identifier of the resource
39
- # @param [Hash] opts the optional parameters
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 [TransferResponse]
43
- describe 'get_transfer 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_transfer_with_http_info' do
33
+ it 'raises when id is missing' do
34
+ expect do
35
+ api_instance.get_transfer_with_http_info(nil)
36
+ end.to raise_error(ArgumentError, /Missing the required parameter 'id'/)
46
37
  end
47
- end
48
38
 
49
- # unit tests for get_transfers
50
- # Get a list of transfers
51
- # Get transfers details in the form of a list
52
- # @param [Hash] opts the optional parameters
53
- # @option opts [String] :accept_language Use for knowing which language to use
54
- # @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.
55
- # @option opts [Integer] :limit The numbers of items to return, the maximum value is 250
56
- # @option opts [String] :search General order search, e.g. by mail, reference etc.
57
- # @option opts [String] :_next next page
58
- # @option opts [String] :previous previous page
59
- # @return [GetTransfersResponse]
60
- describe 'get_transfers 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 transfer id path' do
40
+ expect(api_client).to receive(:call_api).with(:GET, '/transfers/trf%2F123', hash_including(
41
+ operation: :'TransfersApi.get_transfer',
42
+ return_type: 'TransferResponse'
43
+ )).and_return([:transfer, 200, {}])
44
+
45
+ data = api_instance.get_transfer('trf/123')
46
+ expect(data).to eq(:transfer)
63
47
  end
64
48
  end
65
49
 
50
+ describe '#get_transfers_with_http_info' do
51
+ it 'raises for limit higher than 250' do
52
+ expect do
53
+ api_instance.get_transfers_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_transfers_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, '/transfers', hash_including(
65
+ operation: :'TransfersApi.get_transfers',
66
+ query_params: {
67
+ limit: 20,
68
+ search: 'bank',
69
+ next: 'next_token',
70
+ previous: 'prev_token'
71
+ },
72
+ return_type: 'GetTransfersResponse'
73
+ )).and_return([:list, 200, {}])
74
+
75
+ data = api_instance.get_transfers(
76
+ limit: 20,
77
+ search: 'bank',
78
+ _next: 'next_token',
79
+ previous: 'prev_token'
80
+ )
81
+
82
+ expect(data).to eq(:list)
83
+ end
84
+ end
66
85
  end
@@ -13,92 +13,111 @@ Generator version: 7.5.0
13
13
  require 'spec_helper'
14
14
  require 'json'
15
15
 
16
- # Unit tests for DigitalFemsa::WebhookKeysApi
17
- # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
- # Please update as you see appropriate
19
- describe 'WebhookKeysApi' do
20
- before do
21
- # run before each test
22
- @api_instance = DigitalFemsa::WebhookKeysApi.new
23
- end
16
+ RSpec.describe DigitalFemsa::WebhookKeysApi 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
- after do
26
- # run after each test
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 WebhookKeysApi' do
30
- it 'should create an instance of WebhookKeysApi' do
31
- expect(@api_instance).to be_instance_of(DigitalFemsa::WebhookKeysApi)
29
+ it 'creates an instance of WebhookKeysApi' do
30
+ expect(api_instance).to be_instance_of(DigitalFemsa::WebhookKeysApi)
32
31
  end
33
32
  end
34
33
 
35
- # unit tests for create_webhook_key
36
- # Create Webhook Key
37
- # Create a webhook key
38
- # @param [Hash] opts the optional parameters
39
- # @option opts [String] :accept_language Use for knowing which language to use
40
- # @option opts [WebhookKeyRequest] :webhook_key_request
41
- # @return [WebhookKeyCreateResponse]
42
- describe 'create_webhook_key test' do
43
- it 'should work' do
44
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
34
+ describe '#create_webhook_key_with_http_info' do
35
+ it 'sends POST request with serialized payload' do
36
+ payload = { enabled: true }
37
+
38
+ expect(api_client).to receive(:call_api).with(:POST, '/webhook_keys', hash_including(
39
+ operation: :'WebhookKeysApi.create_webhook_key',
40
+ body: payload.to_json,
41
+ return_type: 'WebhookKeyCreateResponse'
42
+ )).and_return([:created, 201, {}])
43
+
44
+ data = api_instance.create_webhook_key(webhook_key_request: payload)
45
+ expect(data).to eq(:created)
45
46
  end
46
47
  end
47
48
 
48
- # unit tests for delete_webhook_key
49
- # Delete Webhook key
50
- # @param id Identifier of the resource
51
- # @param [Hash] opts the optional parameters
52
- # @option opts [String] :accept_language Use for knowing which language to use
53
- # @return [WebhookKeyDeleteResponse]
54
- describe 'delete_webhook_key test' do
55
- it 'should work' do
56
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
49
+ describe '#delete_webhook_key_with_http_info' do
50
+ it 'raises when id is missing' do
51
+ expect do
52
+ api_instance.delete_webhook_key_with_http_info(nil)
53
+ end.to raise_error(ArgumentError, /Missing the required parameter 'id'/)
57
54
  end
58
- end
59
55
 
60
- # unit tests for get_webhook_key
61
- # Get Webhook Key
62
- # @param id Identifier of the resource
63
- # @param [Hash] opts the optional parameters
64
- # @option opts [String] :accept_language Use for knowing which language to use
65
- # @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.
66
- # @return [WebhookKeyResponse]
67
- describe 'get_webhook_key test' do
68
- it 'should work' do
69
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
56
+ it 'sends DELETE request with escaped id path' do
57
+ expect(api_client).to receive(:call_api).with(:DELETE, '/webhook_keys/key%2F123', hash_including(
58
+ operation: :'WebhookKeysApi.delete_webhook_key',
59
+ return_type: 'WebhookKeyDeleteResponse'
60
+ )).and_return([:deleted, 200, {}])
61
+
62
+ data = api_instance.delete_webhook_key('key/123')
63
+ expect(data).to eq(:deleted)
70
64
  end
71
65
  end
72
66
 
73
- # unit tests for get_webhook_keys
74
- # Get List of Webhook Keys
75
- # Consume the list of webhook keys you have
76
- # @param [Hash] opts the optional parameters
77
- # @option opts [String] :accept_language Use for knowing which language to use
78
- # @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.
79
- # @option opts [Integer] :limit The numbers of items to return, the maximum value is 250
80
- # @option opts [String] :search General order search, e.g. by mail, reference etc.
81
- # @option opts [String] :_next next page
82
- # @option opts [String] :previous previous page
83
- # @return [GetWebhookKeysResponse]
84
- describe 'get_webhook_keys test' do
85
- it 'should work' do
86
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
67
+ describe '#get_webhook_keys_with_http_info' do
68
+ it 'raises for limit higher than 250' do
69
+ expect do
70
+ api_instance.get_webhook_keys_with_http_info(limit: 251)
71
+ end.to raise_error(ArgumentError, /must be smaller than or equal to 250/)
87
72
  end
88
- end
89
73
 
90
- # unit tests for update_webhook_key
91
- # Update Webhook Key
92
- # updates an existing webhook key
93
- # @param id Identifier of the resource
94
- # @param [Hash] opts the optional parameters
95
- # @option opts [String] :accept_language Use for knowing which language to use
96
- # @option opts [WebhookKeyUpdateRequest] :webhook_key_update_request
97
- # @return [WebhookKeyResponse]
98
- describe 'update_webhook_key test' do
99
- it 'should work' do
100
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
74
+ it 'raises for limit lower than 1' do
75
+ expect do
76
+ api_instance.get_webhook_keys_with_http_info(limit: 0)
77
+ end.to raise_error(ArgumentError, /must be greater than or equal to 1/)
78
+ end
79
+
80
+ it 'maps pagination and search query params' do
81
+ expect(api_client).to receive(:call_api).with(:GET, '/webhook_keys', hash_including(
82
+ operation: :'WebhookKeysApi.get_webhook_keys',
83
+ query_params: {
84
+ limit: 50,
85
+ search: 'active',
86
+ next: 'next_token',
87
+ previous: 'prev_token'
88
+ },
89
+ return_type: 'GetWebhookKeysResponse'
90
+ )).and_return([:list, 200, {}])
91
+
92
+ data = api_instance.get_webhook_keys(
93
+ limit: 50,
94
+ search: 'active',
95
+ _next: 'next_token',
96
+ previous: 'prev_token'
97
+ )
98
+
99
+ expect(data).to eq(:list)
101
100
  end
102
101
  end
103
102
 
103
+ describe '#update_webhook_key_with_http_info' do
104
+ it 'raises when id is missing' do
105
+ expect do
106
+ api_instance.update_webhook_key_with_http_info(nil)
107
+ end.to raise_error(ArgumentError, /Missing the required parameter 'id'/)
108
+ end
109
+
110
+ it 'sends PUT request with serialized payload' do
111
+ payload = { disabled: true }
112
+
113
+ expect(api_client).to receive(:call_api).with(:PUT, '/webhook_keys/key_123', hash_including(
114
+ operation: :'WebhookKeysApi.update_webhook_key',
115
+ body: payload.to_json,
116
+ return_type: 'WebhookKeyResponse'
117
+ )).and_return([:updated, 200, {}])
118
+
119
+ data = api_instance.update_webhook_key('key_123', webhook_key_update_request: payload)
120
+ expect(data).to eq(:updated)
121
+ end
122
+ end
104
123
  end