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,51 +13,73 @@ Generator version: 7.5.0
13
13
  require 'spec_helper'
14
14
  require 'json'
15
15
 
16
- # Unit tests for DigitalFemsa::CompaniesApi
17
- # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
- # Please update as you see appropriate
19
- describe 'CompaniesApi' do
20
- before do
21
- # run before each test
22
- @api_instance = DigitalFemsa::CompaniesApi.new
23
- end
16
+ RSpec.describe DigitalFemsa::CompaniesApi 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 CompaniesApi' do
30
- it 'should create an instance of CompaniesApi' do
31
- expect(@api_instance).to be_instance_of(DigitalFemsa::CompaniesApi)
27
+ it 'creates an instance of CompaniesApi' do
28
+ expect(api_instance).to be_instance_of(DigitalFemsa::CompaniesApi)
32
29
  end
33
30
  end
34
31
 
35
- # unit tests for get_companies
36
- # Get List of Companies
37
- # Consume the list of child companies. This is used for holding companies with several child entities.
38
- # @param [Hash] opts the optional parameters
39
- # @option opts [String] :accept_language Use for knowing which language to use
40
- # @option opts [Integer] :limit The numbers of items to return, the maximum value is 250
41
- # @option opts [String] :search General order search, e.g. by mail, reference etc.
42
- # @option opts [String] :_next next page
43
- # @option opts [String] :previous previous page
44
- # @return [GetCompaniesResponse]
45
- describe 'get_companies test' do
46
- it 'should work' do
47
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
32
+ describe '#get_companies_with_http_info' do
33
+ it 'raises for limit higher than 250' do
34
+ expect do
35
+ api_instance.get_companies_with_http_info(limit: 251)
36
+ end.to raise_error(ArgumentError, /must be smaller than or equal to 250/)
48
37
  end
49
- end
50
38
 
51
- # unit tests for get_company
52
- # Get Company
53
- # @param id Identifier of the resource
54
- # @param [Hash] opts the optional parameters
55
- # @option opts [String] :accept_language Use for knowing which language to use
56
- # @return [CompanyResponse]
57
- describe 'get_company test' do
58
- it 'should work' do
59
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
39
+ it 'raises for limit lower than 1' do
40
+ expect do
41
+ api_instance.get_companies_with_http_info(limit: 0)
42
+ end.to raise_error(ArgumentError, /must be greater than or equal to 1/)
43
+ end
44
+
45
+ it 'maps pagination and search into query params' do
46
+ expect(api_client).to receive(:call_api).with(:GET, '/companies', hash_including(
47
+ operation: :'CompaniesApi.get_companies',
48
+ query_params: {
49
+ limit: 25,
50
+ search: 'subsidiary',
51
+ next: 'next_token',
52
+ previous: 'prev_token'
53
+ },
54
+ return_type: 'GetCompaniesResponse'
55
+ )).and_return([:companies, 200, {}])
56
+
57
+ data = api_instance.get_companies(
58
+ limit: 25,
59
+ search: 'subsidiary',
60
+ _next: 'next_token',
61
+ previous: 'prev_token'
62
+ )
63
+
64
+ expect(data).to eq(:companies)
60
65
  end
61
66
  end
62
67
 
68
+ describe '#get_company_with_http_info' do
69
+ it 'raises when id is missing' do
70
+ expect do
71
+ api_instance.get_company_with_http_info(nil)
72
+ end.to raise_error(ArgumentError, /Missing the required parameter 'id'/)
73
+ end
74
+
75
+ it 'sends GET request with escaped company id path' do
76
+ expect(api_client).to receive(:call_api).with(:GET, '/companies/com%2F123', hash_including(
77
+ operation: :'CompaniesApi.get_company',
78
+ return_type: 'CompanyResponse'
79
+ )).and_return([:company, 200, {}])
80
+
81
+ data = api_instance.get_company('com/123')
82
+ expect(data).to eq(:company)
83
+ end
84
+ end
63
85
  end
@@ -13,128 +13,144 @@ Generator version: 7.5.0
13
13
  require 'spec_helper'
14
14
  require 'json'
15
15
 
16
- # Unit tests for DigitalFemsa::CustomersApi
17
- # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
- # Please update as you see appropriate
19
- describe 'CustomersApi' do
20
- before do
21
- # run before each test
22
- @api_instance = DigitalFemsa::CustomersApi.new
23
- end
16
+ RSpec.describe DigitalFemsa::CustomersApi 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 CustomersApi' do
30
- it 'should create an instance of CustomersApi' do
31
- expect(@api_instance).to be_instance_of(DigitalFemsa::CustomersApi)
29
+ it 'creates an instance of CustomersApi' do
30
+ expect(api_instance).to be_instance_of(DigitalFemsa::CustomersApi)
32
31
  end
33
32
  end
34
33
 
35
- # unit tests for create_customer
36
- # Create customer
37
- # The purpose of business is to create and keep a customer, you will learn what elements you need to create a customer.
38
- # @param customer requested field for customer
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 [CustomerResponse]
43
- describe 'create_customer test' do
44
- it 'should work' do
45
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
34
+ describe '#create_customer_with_http_info' do
35
+ it 'raises when customer is missing' do
36
+ expect do
37
+ api_instance.create_customer_with_http_info(nil)
38
+ end.to raise_error(ArgumentError, /Missing the required parameter 'customer'/)
46
39
  end
47
- end
48
40
 
49
- # unit tests for create_customer_fiscal_entities
50
- # Create Fiscal Entity
51
- # Create Fiscal entity resource that corresponds to a customer ID.
52
- # @param id Identifier of the resource
53
- # @param customer_fiscal_entities_request requested field for customer fiscal entities
54
- # @param [Hash] opts the optional parameters
55
- # @option opts [String] :accept_language Use for knowing which language to use
56
- # @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.
57
- # @return [CreateCustomerFiscalEntitiesResponse]
58
- describe 'create_customer_fiscal_entities test' do
59
- it 'should work' do
60
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
41
+ it 'sends POST request with serialized customer body' do
42
+ payload = { name: 'Vicente', email: 'vicente@example.com' }
43
+
44
+ expect(api_client).to receive(:call_api).with(:POST, '/customers', hash_including(
45
+ operation: :'CustomersApi.create_customer',
46
+ body: payload.to_json,
47
+ return_type: 'CustomerResponse'
48
+ )).and_return([:created, 201, {}])
49
+
50
+ data = api_instance.create_customer(payload)
51
+ expect(data).to eq(:created)
61
52
  end
62
53
  end
63
54
 
64
- # unit tests for delete_customer_by_id
65
- # Delete Customer
66
- # Deleted a customer resource that corresponds to a customer ID.
67
- # @param id Identifier of the resource
68
- # @param [Hash] opts the optional parameters
69
- # @option opts [String] :accept_language Use for knowing which language to use
70
- # @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.
71
- # @return [CustomerResponse]
72
- describe 'delete_customer_by_id test' do
73
- it 'should work' do
74
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
55
+ describe '#create_customer_fiscal_entities_with_http_info' do
56
+ it 'raises when id is missing' do
57
+ expect do
58
+ api_instance.create_customer_fiscal_entities_with_http_info(nil, { rfc: 'XAXX010101000' })
59
+ end.to raise_error(ArgumentError, /Missing the required parameter 'id'/)
75
60
  end
76
- end
77
61
 
78
- # unit tests for get_customer_by_id
79
- # Get Customer
80
- # Gets a customer resource that corresponds to a customer ID.
81
- # @param id Identifier of the resource
82
- # @param [Hash] opts the optional parameters
83
- # @option opts [String] :accept_language Use for knowing which language to use
84
- # @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.
85
- # @return [CustomerResponse]
86
- describe 'get_customer_by_id test' do
87
- it 'should work' do
88
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
62
+ it 'raises when fiscal entity payload is missing' do
63
+ expect do
64
+ api_instance.create_customer_fiscal_entities_with_http_info('cus_123', nil)
65
+ end.to raise_error(ArgumentError, /Missing the required parameter 'customer_fiscal_entities_request'/)
89
66
  end
90
- end
91
67
 
92
- # unit tests for get_customers
93
- # Get a list of customers
94
- # The purpose of business is to create and maintain a client, you will learn what elements you need to obtain a list of clients, which can be paged.
95
- # @param [Hash] opts the optional parameters
96
- # @option opts [String] :accept_language Use for knowing which language to use
97
- # @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.
98
- # @option opts [Integer] :limit The numbers of items to return, the maximum value is 250
99
- # @option opts [String] :search General order search, e.g. by mail, reference etc.
100
- # @option opts [String] :_next next page
101
- # @option opts [String] :previous previous page
102
- # @return [CustomersResponse]
103
- describe 'get_customers test' do
104
- it 'should work' do
105
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
68
+ it 'builds escaped path and sends POST request' do
69
+ payload = { rfc: 'XAXX010101000' }
70
+
71
+ expect(api_client).to receive(:call_api).with(:POST, '/customers/cus%2F123/fiscal_entities', hash_including(
72
+ operation: :'CustomersApi.create_customer_fiscal_entities',
73
+ body: payload.to_json,
74
+ return_type: 'CreateCustomerFiscalEntitiesResponse'
75
+ )).and_return([:created, 201, {}])
76
+
77
+ data = api_instance.create_customer_fiscal_entities('cus/123', payload)
78
+ expect(data).to eq(:created)
106
79
  end
107
80
  end
108
81
 
109
- # unit tests for update_customer
110
- # Update customer
111
- # You can update customer-related data
112
- # @param id Identifier of the resource
113
- # @param update_customer requested field for customer
114
- # @param [Hash] opts the optional parameters
115
- # @option opts [String] :accept_language Use for knowing which language to use
116
- # @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.
117
- # @return [CustomerResponse]
118
- describe 'update_customer test' do
119
- it 'should work' do
120
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
82
+ describe '#delete_customer_by_id_with_http_info' do
83
+ it 'raises when id is missing' do
84
+ expect do
85
+ api_instance.delete_customer_by_id_with_http_info(nil)
86
+ end.to raise_error(ArgumentError, /Missing the required parameter 'id'/)
87
+ end
88
+
89
+ it 'sends DELETE request to customer resource' do
90
+ expect(api_client).to receive(:call_api).with(:DELETE, '/customers/cus_123', hash_including(
91
+ operation: :'CustomersApi.delete_customer_by_id',
92
+ return_type: 'CustomerResponse'
93
+ )).and_return([:deleted, 200, {}])
94
+
95
+ data = api_instance.delete_customer_by_id('cus_123')
96
+ expect(data).to eq(:deleted)
121
97
  end
122
98
  end
123
99
 
124
- # unit tests for update_customer_fiscal_entities
125
- # Update Fiscal Entity
126
- # Update Fiscal Entity resource that corresponds to a customer ID.
127
- # @param id Identifier of the resource
128
- # @param fiscal_entities_id identifier
129
- # @param customer_update_fiscal_entities_request requested field for customer update fiscal entities
130
- # @param [Hash] opts the optional parameters
131
- # @option opts [String] :accept_language Use for knowing which language to use
132
- # @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.
133
- # @return [UpdateCustomerFiscalEntitiesResponse]
134
- describe 'update_customer_fiscal_entities test' do
135
- it 'should work' do
136
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
100
+ describe '#get_customers_with_http_info' do
101
+ it 'raises for limit higher than 250' do
102
+ expect do
103
+ api_instance.get_customers_with_http_info(limit: 251)
104
+ end.to raise_error(ArgumentError, /must be smaller than or equal to 250/)
105
+ end
106
+
107
+ it 'raises for limit lower than 1' do
108
+ expect do
109
+ api_instance.get_customers_with_http_info(limit: 0)
110
+ end.to raise_error(ArgumentError, /must be greater than or equal to 1/)
111
+ end
112
+
113
+ it 'maps pagination and search filters to query params' do
114
+ expect(api_client).to receive(:call_api).with(:GET, '/customers', hash_including(
115
+ operation: :'CustomersApi.get_customers',
116
+ query_params: {
117
+ limit: 20,
118
+ search: 'vicente',
119
+ next: 'next_token',
120
+ previous: 'prev_token'
121
+ },
122
+ return_type: 'CustomersResponse'
123
+ )).and_return([:list, 200, {}])
124
+
125
+ data = api_instance.get_customers(
126
+ limit: 20,
127
+ search: 'vicente',
128
+ _next: 'next_token',
129
+ previous: 'prev_token'
130
+ )
131
+
132
+ expect(data).to eq(:list)
137
133
  end
138
134
  end
139
135
 
136
+ describe '#update_customer_fiscal_entities_with_http_info' do
137
+ it 'raises when fiscal_entities_id is missing' do
138
+ expect do
139
+ api_instance.update_customer_fiscal_entities_with_http_info('cus_123', nil, { business_name: 'Test SA' })
140
+ end.to raise_error(ArgumentError, /Missing the required parameter 'fiscal_entities_id'/)
141
+ end
142
+
143
+ it 'sends PUT request with expected path and body' do
144
+ payload = { business_name: 'Test SA' }
145
+
146
+ expect(api_client).to receive(:call_api).with(:PUT, '/customers/cus_123/fiscal_entities/fis_123', hash_including(
147
+ operation: :'CustomersApi.update_customer_fiscal_entities',
148
+ body: payload.to_json,
149
+ return_type: 'UpdateCustomerFiscalEntitiesResponse'
150
+ )).and_return([:updated, 200, {}])
151
+
152
+ data = api_instance.update_customer_fiscal_entities('cus_123', 'fis_123', payload)
153
+ expect(data).to eq(:updated)
154
+ end
155
+ end
140
156
  end
@@ -13,67 +13,91 @@ Generator version: 7.5.0
13
13
  require 'spec_helper'
14
14
  require 'json'
15
15
 
16
- # Unit tests for DigitalFemsa::EventsApi
17
- # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
- # Please update as you see appropriate
19
- describe 'EventsApi' do
20
- before do
21
- # run before each test
22
- @api_instance = DigitalFemsa::EventsApi.new
23
- end
16
+ RSpec.describe DigitalFemsa::EventsApi 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 EventsApi' do
30
- it 'should create an instance of EventsApi' do
31
- expect(@api_instance).to be_instance_of(DigitalFemsa::EventsApi)
27
+ it 'creates an instance of EventsApi' do
28
+ expect(api_instance).to be_instance_of(DigitalFemsa::EventsApi)
32
29
  end
33
30
  end
34
31
 
35
- # unit tests for get_event
36
- # Get Event
37
- # Returns a single event
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 [EventResponse]
43
- describe 'get_event 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_event_with_http_info' do
33
+ it 'raises when id is missing' do
34
+ expect do
35
+ api_instance.get_event_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_events
50
- # Get list of Events
51
- # @param [Hash] opts the optional parameters
52
- # @option opts [String] :accept_language Use for knowing which language to use
53
- # @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.
54
- # @option opts [Integer] :limit The numbers of items to return, the maximum value is 250
55
- # @option opts [String] :search General order search, e.g. by mail, reference etc.
56
- # @option opts [String] :_next next page
57
- # @option opts [String] :previous previous page
58
- # @return [GetEventsResponse]
59
- describe 'get_events test' do
60
- it 'should work' do
61
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
39
+ it 'sends GET request with escaped event path' do
40
+ expect(api_client).to receive(:call_api).with(:GET, '/events/evt%2F123', hash_including(
41
+ operation: :'EventsApi.get_event',
42
+ return_type: 'EventResponse'
43
+ )).and_return([:event, 200, {}])
44
+
45
+ data = api_instance.get_event('evt/123')
46
+ expect(data).to eq(:event)
62
47
  end
63
48
  end
64
49
 
65
- # unit tests for resend_event
66
- # Resend Event
67
- # Try to send an event
68
- # @param event_id event identifier
69
- # @param webhook_log_id webhook log identifier
70
- # @param [Hash] opts the optional parameters
71
- # @option opts [String] :accept_language Use for knowing which language to use
72
- # @return [EventsResendResponse]
73
- describe 'resend_event test' do
74
- it 'should work' do
75
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
50
+ describe '#get_events_with_http_info' do
51
+ it 'raises for limit higher than 250' do
52
+ expect do
53
+ api_instance.get_events_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_events_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 into query params' do
64
+ expect(api_client).to receive(:call_api).with(:GET, '/events', hash_including(
65
+ operation: :'EventsApi.get_events',
66
+ query_params: {
67
+ limit: 30,
68
+ search: 'charge.paid',
69
+ next: 'next_token',
70
+ previous: 'prev_token'
71
+ },
72
+ return_type: 'GetEventsResponse'
73
+ )).and_return([:list, 200, {}])
74
+
75
+ data = api_instance.get_events(
76
+ limit: 30,
77
+ search: 'charge.paid',
78
+ _next: 'next_token',
79
+ previous: 'prev_token'
80
+ )
81
+
82
+ expect(data).to eq(:list)
76
83
  end
77
84
  end
78
85
 
86
+ describe '#resend_event_with_http_info' do
87
+ it 'raises when webhook_log_id is missing' do
88
+ expect do
89
+ api_instance.resend_event_with_http_info('evt_123', nil)
90
+ end.to raise_error(ArgumentError, /Missing the required parameter 'webhook_log_id'/)
91
+ end
92
+
93
+ it 'sends POST request with escaped event and webhook log ids' do
94
+ expect(api_client).to receive(:call_api).with(:POST, '/events/evt%2F123/webhook_logs/log%2F123/resend', hash_including(
95
+ operation: :'EventsApi.resend_event',
96
+ return_type: 'EventsResendResponse'
97
+ )).and_return([:resent, 200, {}])
98
+
99
+ data = api_instance.resend_event('evt/123', 'log/123')
100
+ expect(data).to eq(:resent)
101
+ end
102
+ end
79
103
  end
@@ -0,0 +1,94 @@
1
+ require 'spec_helper'
2
+ require 'logger'
3
+
4
+ RSpec.describe 'Generated APIs coverage smoke tests' do
5
+ api_classes = DigitalFemsa.constants.filter_map do |const_name|
6
+ constant = DigitalFemsa.const_get(const_name)
7
+ next unless constant.is_a?(Class)
8
+ next unless constant.name.end_with?('Api')
9
+
10
+ constant
11
+ rescue NameError
12
+ nil
13
+ end.sort_by(&:name)
14
+
15
+ required_arg_value = lambda do |name|
16
+ name_str = name.to_s
17
+
18
+ if name_str == 'id' || name_str.end_with?('_id')
19
+ 'id_123'
20
+ elsif name_str.include?('request')
21
+ {}
22
+ elsif name_str.include?('amount')
23
+ 100
24
+ elsif name_str.include?('date')
25
+ '2024-01-01'
26
+ else
27
+ 'value'
28
+ end
29
+ end
30
+
31
+ optional_arg_value = lambda do |name|
32
+ unless name.to_s == 'opts'
33
+ return required_arg_value.call(name)
34
+ end
35
+
36
+ {
37
+ accept_language: 'es',
38
+ x_child_company_id: 'child_company_123',
39
+ limit: 20,
40
+ search: 'test',
41
+ _next: 'next_token',
42
+ previous: 'prev_token'
43
+ }
44
+ end
45
+
46
+ args_for = lambda do |method|
47
+ method.parameters.map do |kind, name|
48
+ kind == :opt ? optional_arg_value.call(name) : required_arg_value.call(name)
49
+ end
50
+ end
51
+
52
+ let(:config) do
53
+ double('Configuration', debugging: false, client_side_validation: true, logger: Logger.new(nil))
54
+ end
55
+
56
+ let(:api_client) do
57
+ double('ApiClient').tap do |client|
58
+ allow(client).to receive(:config).and_return(config)
59
+ allow(client).to receive(:select_header_accept).and_return('application/json')
60
+ allow(client).to receive(:select_header_content_type).and_return('application/json')
61
+ allow(client).to receive(:object_to_http_body) { |body| body }
62
+ allow(client).to receive(:call_api).and_return([{ 'ok' => true }, 200, { 'X-Test' => '1' }])
63
+ end
64
+ end
65
+
66
+ api_classes.each do |klass|
67
+ describe klass.name do
68
+ let(:api_instance) { klass.new(api_client) }
69
+
70
+ it 'creates an instance with injected api_client' do
71
+ expect(api_instance).to be_instance_of(klass)
72
+ expect(api_instance.api_client).to eq(api_client)
73
+ end
74
+
75
+ klass.instance_methods(false).sort.each do |method_name|
76
+ next if method_name == :initialize
77
+ next if %i[api_client api_client=].include?(method_name)
78
+
79
+ it "invokes ##{method_name}" do
80
+ method = klass.instance_method(method_name)
81
+ args = args_for.call(method)
82
+
83
+ result = api_instance.public_send(method_name, *args)
84
+
85
+ if method_name.to_s.end_with?('_with_http_info')
86
+ expect(result).to eq([{ 'ok' => true }, 200, { 'X-Test' => '1' }])
87
+ else
88
+ expect(result).to eq('ok' => true)
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end