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.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +104 -0
- data/README.md +4 -4
- data/VERSION +1 -1
- data/config-ruby.json +1 -1
- data/digital_femsa.gemspec +1 -1
- data/lib/digital_femsa/models/webhook_request.rb +247 -8
- data/lib/digital_femsa/version.rb +1 -1
- data/spec/api/balances_api_spec.rb +24 -22
- data/spec/api/charges_api_spec.rb +92 -49
- data/spec/api/companies_api_spec.rb +57 -35
- data/spec/api/customers_api_spec.rb +115 -99
- data/spec/api/events_api_spec.rb +72 -48
- data/spec/api/generated_apis_coverage_spec.rb +94 -0
- data/spec/api/logs_api_spec.rb +57 -38
- data/spec/api/orders_api_spec.rb +134 -108
- data/spec/api/payment_link_api_spec.rb +91 -81
- data/spec/api/payment_methods_api_spec.rb +102 -65
- data/spec/api/transactions_api_spec.rb +63 -41
- data/spec/api/transfers_api_spec.rb +57 -38
- data/spec/api/webhook_keys_api_spec.rb +87 -68
- data/spec/api/webhooks_api_spec.rb +110 -79
- data/spec/api_client_spec.rb +259 -0
- data/spec/models/generated_models_coverage_spec.rb +152 -0
- data/spec/models/webhook_request_ssrf_protection_spec.rb +275 -0
- data/spec/spec_helper.rb +37 -0
- metadata +28 -25
data/spec/api/events_api_spec.rb
CHANGED
|
@@ -13,67 +13,91 @@ Generator version: 7.5.0
|
|
|
13
13
|
require 'spec_helper'
|
|
14
14
|
require 'json'
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
26
|
-
|
|
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 '
|
|
31
|
-
expect(
|
|
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
|
-
#
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
#
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
data/spec/api/logs_api_spec.rb
CHANGED
|
@@ -13,54 +13,73 @@ Generator version: 7.5.0
|
|
|
13
13
|
require 'spec_helper'
|
|
14
14
|
require 'json'
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
26
|
-
|
|
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 '
|
|
31
|
-
expect(
|
|
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
|
-
#
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
data/spec/api/orders_api_spec.rb
CHANGED
|
@@ -13,141 +13,167 @@ Generator version: 7.5.0
|
|
|
13
13
|
require 'spec_helper'
|
|
14
14
|
require 'json'
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
26
|
-
|
|
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 '
|
|
31
|
-
expect(
|
|
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
|
-
#
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
#
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
#
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
#
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
#
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
-
#
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|