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,68 +13,111 @@ Generator version: 7.5.0
13
13
  require 'spec_helper'
14
14
  require 'json'
15
15
 
16
- # Unit tests for DigitalFemsa::ChargesApi
17
- # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
- # Please update as you see appropriate
19
- describe 'ChargesApi' do
20
- before do
21
- # run before each test
22
- @api_instance = DigitalFemsa::ChargesApi.new
23
- end
16
+ RSpec.describe DigitalFemsa::ChargesApi 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 ChargesApi' do
30
- it 'should create an instance of ChargesApi' do
31
- expect(@api_instance).to be_instance_of(DigitalFemsa::ChargesApi)
29
+ it 'creates an instance of ChargesApi' do
30
+ expect(api_instance).to be_instance_of(DigitalFemsa::ChargesApi)
32
31
  end
33
32
  end
34
33
 
35
- # unit tests for get_charges
36
- # Get A List of Charges
37
- # @param [Hash] opts the optional parameters
38
- # @option opts [String] :accept_language Use for knowing which language to use
39
- # @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.
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 [GetChargesResponse]
45
- describe 'get_charges test' do
46
- it 'should work' do
47
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
34
+ describe '#get_charges_with_http_info' do
35
+ it 'raises for limit higher than 250' do
36
+ expect do
37
+ api_instance.get_charges_with_http_info(limit: 251)
38
+ end.to raise_error(ArgumentError, /must be smaller than or equal to 250/)
48
39
  end
49
- end
50
40
 
51
- # unit tests for orders_create_charge
52
- # Create charge
53
- # Create charge for an existing orden
54
- # @param id Identifier of the resource
55
- # @param charge_request requested field for a charge
56
- # @param [Hash] opts the optional parameters
57
- # @option opts [String] :accept_language Use for knowing which language to use
58
- # @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.
59
- # @return [ChargeOrderResponse]
60
- describe 'orders_create_charge test' do
61
- it 'should work' do
62
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
41
+ it 'raises for limit lower than 1' do
42
+ expect do
43
+ api_instance.get_charges_with_http_info(limit: 0)
44
+ end.to raise_error(ArgumentError, /must be greater than or equal to 1/)
45
+ end
46
+
47
+ it 'maps list filters into query params' do
48
+ expect(api_client).to receive(:call_api).with(:GET, '/charges', hash_including(
49
+ operation: :'ChargesApi.get_charges',
50
+ query_params: {
51
+ limit: 10,
52
+ next: 'next_token',
53
+ previous: 'prev_token',
54
+ search: 'ord_123'
55
+ },
56
+ return_type: 'GetChargesResponse'
57
+ )).and_return([:list, 200, {}])
58
+
59
+ data = api_instance.get_charges(
60
+ limit: 10,
61
+ _next: 'next_token',
62
+ previous: 'prev_token',
63
+ search: 'ord_123'
64
+ )
65
+
66
+ expect(data).to eq(:list)
63
67
  end
64
68
  end
65
69
 
66
- # unit tests for update_charge
67
- # Update a charge
68
- # @param id Identifier of the resource
69
- # @param charge_update_request requested field for update a charge
70
- # @param [Hash] opts the optional parameters
71
- # @option opts [String] :accept_language Use for knowing which language to use
72
- # @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.
73
- # @return [ChargeResponse]
74
- describe 'update_charge test' do
75
- it 'should work' do
76
- # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
70
+ describe '#orders_create_charge_with_http_info' do
71
+ it 'raises when id is missing' do
72
+ expect do
73
+ api_instance.orders_create_charge_with_http_info(nil, { amount: 1000 })
74
+ end.to raise_error(ArgumentError, /Missing the required parameter 'id'/)
75
+ end
76
+
77
+ it 'raises when charge_request is missing' do
78
+ expect do
79
+ api_instance.orders_create_charge_with_http_info('ord_123', nil)
80
+ end.to raise_error(ArgumentError, /Missing the required parameter 'charge_request'/)
81
+ end
82
+
83
+ it 'builds escaped path and sends charge payload' do
84
+ payload = { amount: 1500, currency: 'MXN' }
85
+
86
+ expect(api_client).to receive(:call_api).with(:POST, '/orders/ord%2F123/charges', hash_including(
87
+ operation: :'ChargesApi.orders_create_charge',
88
+ body: payload.to_json,
89
+ return_type: 'ChargeOrderResponse'
90
+ )).and_return([:created, 201, {}])
91
+
92
+ data = api_instance.orders_create_charge('ord/123', payload)
93
+ expect(data).to eq(:created)
77
94
  end
78
95
  end
79
96
 
97
+ describe '#update_charge_with_http_info' do
98
+ it 'raises when id is missing' do
99
+ expect do
100
+ api_instance.update_charge_with_http_info(nil, { reference_id: 'ref_1' })
101
+ end.to raise_error(ArgumentError, /Missing the required parameter 'id'/)
102
+ end
103
+
104
+ it 'raises when charge_update_request is missing' do
105
+ expect do
106
+ api_instance.update_charge_with_http_info('chg_123', nil)
107
+ end.to raise_error(ArgumentError, /Missing the required parameter 'charge_update_request'/)
108
+ end
109
+
110
+ it 'sends PUT request with serialized payload' do
111
+ payload = { reference_id: 'new_reference' }
112
+
113
+ expect(api_client).to receive(:call_api).with(:PUT, '/charges/chg_123', hash_including(
114
+ operation: :'ChargesApi.update_charge',
115
+ body: payload.to_json,
116
+ return_type: 'ChargeResponse'
117
+ )).and_return([:updated, 200, {}])
118
+
119
+ data = api_instance.update_charge('chg_123', payload)
120
+ expect(data).to eq(:updated)
121
+ end
122
+ end
80
123
  end
@@ -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