digital_femsa 1.1.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.
@@ -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
@@ -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