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,54 +13,73 @@ Generator version: 7.5.0
13
13
  require 'spec_helper'
14
14
  require 'json'
15
15
 
16
- # Unit tests for DigitalFemsa::LogsApi
17
- # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
- # Please update as you see appropriate
19
- describe 'LogsApi' do
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
- 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 LogsApi' do
30
- it 'should create an instance of LogsApi' do
31
- expect(@api_instance).to be_instance_of(DigitalFemsa::LogsApi)
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
- # unit tests for get_log_by_id
36
- # Get Log
37
- # Get the details of a specific log
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 [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
- # unit tests for get_logs
50
- # Get List Of Logs
51
- # Get log 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 [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
@@ -13,141 +13,167 @@ Generator version: 7.5.0
13
13
  require 'spec_helper'
14
14
  require 'json'
15
15
 
16
- # Unit tests for DigitalFemsa::OrdersApi
17
- # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
- # Please update as you see appropriate
19
- describe 'OrdersApi' do
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
- 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 OrdersApi' do
30
- it 'should create an instance of OrdersApi' do
31
- expect(@api_instance).to be_instance_of(DigitalFemsa::OrdersApi)
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
- # unit tests for cancel_order
36
- # Cancel Order
37
- # Cancel an order that has been previously created.
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 [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
- # unit tests for create_order
50
- # Create order
51
- # Create a new order.
52
- # @param order_request requested field for order
53
- # @param [Hash] opts the optional parameters
54
- # @option opts [String] :accept_language Use for knowing which language to use
55
- # @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.
56
- # @return [OrderResponse]
57
- describe 'create_order test' do
58
- it 'should work' do
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
- # unit tests for get_order_by_id
64
- # Get Order
65
- # Info for a specific order
66
- # @param id Identifier of the resource
67
- # @param [Hash] opts the optional parameters
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
- # unit tests for get_orders
78
- # Get a list of Orders
79
- # Get order details in the form of a list
80
- # @param [Hash] opts the optional parameters
81
- # @option opts [String] :accept_language Use for knowing which language to use
82
- # @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.
83
- # @option opts [Integer] :limit The numbers of items to return, the maximum value is 250
84
- # @option opts [String] :search General order search, e.g. by mail, reference etc.
85
- # @option opts [String] :_next next page
86
- # @option opts [String] :previous previous page
87
- # @return [GetOrdersResponse]
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
- # unit tests for order_cancel_refund
95
- # Cancel Refund
96
- # A refunded order describes the items, amount, and reason an order is being refunded.
97
- # @param id Identifier of the resource
98
- # @param refund_id refund identifier
99
- # @param [Hash] opts the optional parameters
100
- # @option opts [String] :accept_language Use for knowing which language to use
101
- # @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.
102
- # @return [OrderResponse]
103
- describe 'order_cancel_refund test' do
104
- it 'should work' do
105
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
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
- # unit tests for order_refund
110
- # Refund Order
111
- # A refunded order describes the items, amount, and reason an order is being refunded.
112
- # @param id Identifier of the resource
113
- # @param order_refund_request requested field for a refund
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 [OrderResponse]
118
- describe 'order_refund test' do
119
- it 'should work' do
120
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
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
- # unit tests for orders_create_capture
125
- # Capture Order
126
- # Processes an order that has been previously authorized.
127
- # @param id Identifier of the resource
128
- # @param [Hash] opts the optional parameters
129
- # @option opts [String] :accept_language Use for knowing which language to use
130
- # @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.
131
- # @option opts [OrderCaptureRequest] :order_capture_request requested fields for capture order
132
- # @return [OrderResponse]
133
- describe 'orders_create_capture test' do
134
- it 'should work' do
135
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
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
- # unit tests for update_order
140
- # Update Order
141
- # Update an existing Order.
142
- # @param id Identifier of the resource
143
- # @param order_update_request requested field for an order
144
- # @param [Hash] opts the optional parameters
145
- # @option opts [String] :accept_language Use for knowing which language to use
146
- # @return [OrderResponse]
147
- describe 'update_order test' do
148
- it 'should work' do
149
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
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
- # Unit tests for DigitalFemsa::PaymentLinkApi
17
- # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
- # Please update as you see appropriate
19
- describe 'PaymentLinkApi' do
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
- 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 PaymentLinkApi' do
30
- it 'should create an instance of PaymentLinkApi' do
31
- expect(@api_instance).to be_instance_of(DigitalFemsa::PaymentLinkApi)
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
- # unit tests for cancel_checkout
36
- # Cancel Payment Link
37
- # @param id Identifier of the resource
38
- # @param [Hash] opts the optional parameters
39
- # @option opts [String] :accept_language Use for knowing which language to use
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
- # unit tests for create_checkout
49
- # Create Unique Payment Link
50
- # @param checkout requested field for checkout
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
- # @return [CheckoutResponse]
55
- describe 'create_checkout test' do
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
- # unit tests for email_checkout
62
- # Send an email
63
- # @param id Identifier of the resource
64
- # @param email_checkout_request requested field for sms checkout
65
- # @param [Hash] opts the optional parameters
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
- # unit tests for get_checkout
76
- # Get a payment link by ID
77
- # @param id Identifier of the resource
78
- # @param [Hash] opts the optional parameters
79
- # @option opts [String] :accept_language Use for knowing which language to use
80
- # @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.
81
- # @return [CheckoutResponse]
82
- describe 'get_checkout test' do
83
- it 'should work' do
84
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
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
- # unit tests for get_checkouts
89
- # Get a list of payment links
90
- # Returns a list of links generated by the merchant
91
- # @param [Hash] opts the optional parameters
92
- # @option opts [String] :accept_language Use for knowing which language to use
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
- # unit tests for sms_checkout
106
- # Send an sms
107
- # @param id Identifier of the resource
108
- # @param sms_checkout_request requested field for sms checkout
109
- # @param [Hash] opts the optional parameters
110
- # @option opts [String] :accept_language Use for knowing which language to use
111
- # @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.
112
- # @return [CheckoutResponse]
113
- describe 'sms_checkout test' do
114
- it 'should work' do
115
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
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