pixi_client 0.0.5

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 (76) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +34 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +4 -0
  5. data/Guardfile +45 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +171 -0
  8. data/Rakefile +8 -0
  9. data/lib/pixi_client/configuration.rb +5 -0
  10. data/lib/pixi_client/requests/add_comment_to_order.rb +20 -0
  11. data/lib/pixi_client/requests/base.rb +25 -0
  12. data/lib/pixi_client/requests/cancel_order.rb +19 -0
  13. data/lib/pixi_client/requests/cancel_order_line.rb +19 -0
  14. data/lib/pixi_client/requests/get_changed_item_stock.rb +27 -0
  15. data/lib/pixi_client/requests/get_changed_items.rb +19 -0
  16. data/lib/pixi_client/requests/get_invoice.rb +19 -0
  17. data/lib/pixi_client/requests/get_item_info.rb +19 -0
  18. data/lib/pixi_client/requests/get_item_stock_bins.rb +18 -0
  19. data/lib/pixi_client/requests/get_items_info.rb +34 -0
  20. data/lib/pixi_client/requests/get_items_on_stock_bin.rb +19 -0
  21. data/lib/pixi_client/requests/get_items_stock_history.rb +18 -0
  22. data/lib/pixi_client/requests/get_order_comments.rb +19 -0
  23. data/lib/pixi_client/requests/get_order_header.rb +19 -0
  24. data/lib/pixi_client/requests/get_order_line_history.rb +22 -0
  25. data/lib/pixi_client/requests/get_order_lines.rb +21 -0
  26. data/lib/pixi_client/requests/get_order_nr_external_by_box_nr.rb +19 -0
  27. data/lib/pixi_client/requests/get_stock.rb +19 -0
  28. data/lib/pixi_client/requests/get_stock_by_bin.rb +19 -0
  29. data/lib/pixi_client/requests/get_unshippable_orders.rb +19 -0
  30. data/lib/pixi_client/requests/itemable.rb +24 -0
  31. data/lib/pixi_client/requests/read_items.rb +23 -0
  32. data/lib/pixi_client/requests/read_orderlines.rb +18 -0
  33. data/lib/pixi_client/requests/set_stock_multiple.rb +19 -0
  34. data/lib/pixi_client/requests/shipping_get_picklist_details.rb +19 -0
  35. data/lib/pixi_client/requests/shipping_get_picklist_headers.rb +19 -0
  36. data/lib/pixi_client/requests.rb +27 -0
  37. data/lib/pixi_client/response.rb +12 -0
  38. data/lib/pixi_client/response_parser.rb +137 -0
  39. data/lib/pixi_client/version.rb +3 -0
  40. data/lib/pixi_client.rb +17 -0
  41. data/pixi_client.gemspec +32 -0
  42. data/spec/fixtures/get_order_nr_external_by_box_nr.xml +51 -0
  43. data/spec/fixtures/pixi_get_changed_item_stock.xml +140 -0
  44. data/spec/integration/pixi_get_changed_item_stock_spec.rb +85 -0
  45. data/spec/lib/pixi_client/configuration_spec.rb +47 -0
  46. data/spec/lib/pixi_client/requests/add_comment_to_order_spec.rb +48 -0
  47. data/spec/lib/pixi_client/requests/cancel_order_line_spec.rb +47 -0
  48. data/spec/lib/pixi_client/requests/cancel_order_spec.rb +47 -0
  49. data/spec/lib/pixi_client/requests/get_changed_item_stock_spec.rb +61 -0
  50. data/spec/lib/pixi_client/requests/get_changed_items_spec.rb +54 -0
  51. data/spec/lib/pixi_client/requests/get_invoice_spec.rb +46 -0
  52. data/spec/lib/pixi_client/requests/get_item_info_spec.rb +48 -0
  53. data/spec/lib/pixi_client/requests/get_item_stock_bins_spec.rb +48 -0
  54. data/spec/lib/pixi_client/requests/get_items_info_spec.rb +60 -0
  55. data/spec/lib/pixi_client/requests/get_items_on_stock_bin_spec.rb +47 -0
  56. data/spec/lib/pixi_client/requests/get_items_stock_history_spec.rb +47 -0
  57. data/spec/lib/pixi_client/requests/get_order_comments_spec.rb +46 -0
  58. data/spec/lib/pixi_client/requests/get_order_header_spec.rb +47 -0
  59. data/spec/lib/pixi_client/requests/get_order_line_history_spec.rb +47 -0
  60. data/spec/lib/pixi_client/requests/get_order_lines_spec.rb +47 -0
  61. data/spec/lib/pixi_client/requests/get_order_nr_external_by_box_nr_spec.rb +51 -0
  62. data/spec/lib/pixi_client/requests/get_stock_by_bin_spec.rb +47 -0
  63. data/spec/lib/pixi_client/requests/get_stock_spec.rb +47 -0
  64. data/spec/lib/pixi_client/requests/get_unshippable_orders_spec.rb +47 -0
  65. data/spec/lib/pixi_client/requests/itemable_shared_examples.rb +52 -0
  66. data/spec/lib/pixi_client/requests/read_items_spec.rb +56 -0
  67. data/spec/lib/pixi_client/requests/read_orderlines_spec.rb +47 -0
  68. data/spec/lib/pixi_client/requests/set_stock_multiple_spec.rb +53 -0
  69. data/spec/lib/pixi_client/requests/shipping_get_picklist_details_spec.rb +47 -0
  70. data/spec/lib/pixi_client/requests/shipping_get_picklist_headers_spec.rb +47 -0
  71. data/spec/lib/pixi_client/response_parser_spec.rb +96 -0
  72. data/spec/lib/pixi_client/soap_request_spec.rb +30 -0
  73. data/spec/lib/pixi_client_spec.rb +19 -0
  74. data/spec/spec_helper.rb +11 -0
  75. data/spec/support/test_helpers.rb +136 -0
  76. metadata +306 -0
@@ -0,0 +1,85 @@
1
+ require 'spec_helper'
2
+ require 'savon'
3
+ require 'savon/mock/spec_helper'
4
+
5
+ describe 'pixiGetChangedItemStock' do
6
+ include Savon::SpecHelper
7
+
8
+ before(:all) do
9
+ set_default_config
10
+ savon.mock!
11
+ end
12
+
13
+ after(:all) { savon.unmock! }
14
+
15
+ let(:christmas_time) { Time.parse('2014-12-25 00:00:00') }
16
+ let(:request) { PixiClient::Requests::GetChangedItemStock.new(since: christmas_time) }
17
+
18
+ context 'when the response is not empty' do
19
+ before do
20
+ savon.
21
+ expects(:pixi_get_changed_item_stock).
22
+ with(message: { 'Since' => christmas_time.strftime('%Y-%m-%dT%H:%M:%S.%3N') }).
23
+ returns(File.read('spec/fixtures/pixi_get_changed_item_stock.xml')) # See file for data details
24
+ end
25
+
26
+ let(:response) { request.call }
27
+
28
+ it 'responds with the expected 3 rows' do
29
+
30
+ expected_rows = [
31
+ OpenStruct.new(item_key: 92664,
32
+ item_nr_int: '117843-102-8',
33
+ eanupc: '0117843102089',
34
+ item_nr_suppl: '6017 1550',
35
+ physical_stock: 9,
36
+ available_stock: 8,
37
+ stock_change: 9,
38
+ estimated_delivery: '',
39
+ min_stock_qty: 0,
40
+ enabled: true,
41
+ open_supplier_order_qty: 0,
42
+ update_date: Time.parse('2014-12-23T13:25:02 +00:00'),
43
+ original_update_date: Time.parse('2014-12-23T13:25:02 +00:00'),
44
+ bundle_item: false,
45
+ row_nr: 1),
46
+
47
+ OpenStruct.new(item_key: 2071,
48
+ item_nr_int: '112852-704-1',
49
+ eanupc: '0112852704019',
50
+ item_nr_suppl: '857819996210',
51
+ physical_stock: 17,
52
+ available_stock: 17,
53
+ stock_change: 17,
54
+ estimated_delivery: '',
55
+ min_stock_qty: 0,
56
+ enabled: true,
57
+ open_supplier_order_qty: 0,
58
+ update_date: Time.parse('2014-12-23T15:00:01 +00:00'),
59
+ original_update_date: Time.parse('2014-12-23T15:00:01 +00:00'),
60
+ bundle_item: false,
61
+ row_nr: 2),
62
+
63
+ OpenStruct.new(item_key: 102032,
64
+ item_nr_int: '207904-504-1',
65
+ eanupc: '0207904504010',
66
+ item_nr_suppl: 'W8538Q',
67
+ physical_stock: 1,
68
+ available_stock: 1,
69
+ stock_change: 1,
70
+ estimated_delivery: '',
71
+ min_stock_qty: 0,
72
+ enabled: true,
73
+ open_supplier_order_qty: 0,
74
+ update_date: Time.parse('2014-12-23T17:51:02 +00:00'),
75
+ original_update_date: Time.parse('2014-12-23T17:51:02 +00:00'),
76
+ bundle_item: false,
77
+ row_nr: 3)
78
+ ]
79
+
80
+ expect(response.rows).to eq expected_rows
81
+ end
82
+
83
+
84
+ end
85
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe PixiClient::Configuration do
4
+
5
+ subject { PixiClient::Configuration.new }
6
+
7
+ describe 'default values' do
8
+ describe '#endpoint' do
9
+ it 'should be nil' do
10
+ expect(subject.endpoint).to be_nil
11
+ end
12
+ end
13
+
14
+ describe '#username' do
15
+ it 'should be nil' do
16
+ expect(subject.username).to be_nil
17
+ end
18
+ end
19
+
20
+ describe '#password' do
21
+ it 'should be nil' do
22
+ expect(subject.password).to be_nil
23
+ end
24
+ end
25
+ end
26
+
27
+ describe '#endpoint=' do
28
+ it 'sets the endpoint' do
29
+ subject.endpoint = 'endpoint_url'
30
+ expect(subject.endpoint).to eq 'endpoint_url'
31
+ end
32
+ end
33
+
34
+ describe '#username=' do
35
+ it 'sets the username' do
36
+ subject.username = 'username'
37
+ expect(subject.username).to eq 'username'
38
+ end
39
+ end
40
+
41
+ describe '#password=' do
42
+ it 'sets the password' do
43
+ subject.password = 'random-password'
44
+ expect(subject.password).to eq 'random-password'
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe PixiClient::Requests::AddCommentToOrder do
4
+ let(:order_nr) { 1 }
5
+ let(:comment) { 'Life is too short to learn german' }
6
+ subject { PixiClient::Requests::AddCommentToOrder.new(order_nr, comment) }
7
+
8
+ before do
9
+ set_default_config
10
+ end
11
+
12
+ it { is_expected.to be_a_kind_of(PixiClient::Requests::Base) }
13
+
14
+ describe '#api_method' do
15
+ it 'should return :pixi_add_order_comment' do
16
+ expect(subject.api_method).to eq :pixi_add_order_comment
17
+ end
18
+ end
19
+
20
+ describe 'call behaviour' do
21
+ let(:expected_response) { double(body: { pixi_add_order_comment_response: { pixi_add_order_comment_result: sql_row_set_response_mock } }) }
22
+ let(:double_client) { double }
23
+
24
+ before do
25
+ allow(subject).to receive(:client).and_return(double_client)
26
+ end
27
+
28
+ it 'should call the client with the appropriate parameters' do
29
+ expect(double_client).to receive(:call)
30
+ .with(:pixi_add_order_comment, attributes: { xmlns: PixiClient.configuration.endpoint }, message: { 'OrderNr' => order_nr, 'Comment' => comment })
31
+ .and_return(expected_response)
32
+
33
+ subject.call
34
+ end
35
+
36
+ it 'should instanciate an instance of Response with the response body' do
37
+ expect(double_client).to receive(:call).and_return(expected_response)
38
+ expect(PixiClient::Response).to receive(:new).with(:pixi_add_order_comment, expected_response.body)
39
+ subject.call
40
+ end
41
+
42
+ it 'should return an instance of Response' do
43
+ expect(double_client).to receive(:call).and_return(expected_response)
44
+ expect(subject.call).to be_an_instance_of(PixiClient::Response)
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe PixiClient::Requests::CancelOrderLine do
4
+ let(:order_line_key) { 1 }
5
+ subject { PixiClient::Requests::CancelOrderLine.new(order_line_key) }
6
+
7
+ before do
8
+ set_default_config
9
+ end
10
+
11
+ it { is_expected.to be_a_kind_of(PixiClient::Requests::Base) }
12
+
13
+ describe '#api_method' do
14
+ it 'should return :pixi_cancel_orderline' do
15
+ expect(subject.api_method).to eq :pixi_cancel_orderline
16
+ end
17
+ end
18
+
19
+ describe 'call behaviour' do
20
+ let(:expected_response) { double(body: { pixi_cancel_orderline_response: { pixi_cancel_orderline_result: {} } }) }
21
+ let(:double_client) { double }
22
+
23
+ before do
24
+ allow(subject).to receive(:client).and_return(double_client)
25
+ end
26
+
27
+ it 'should call the client with the appropriate parameters' do
28
+ expect(double_client).to receive(:call).
29
+ with(:pixi_cancel_orderline, attributes: { xmlns: PixiClient.configuration.endpoint }, message: { 'OrderlineKey' => order_line_key }).
30
+ and_return(expected_response)
31
+
32
+ subject.call
33
+ end
34
+
35
+ it 'should instanciate an instance of Response with the response body' do
36
+ expect(double_client).to receive(:call).and_return(expected_response)
37
+ expect(PixiClient::Response).to receive(:new).with(:pixi_cancel_orderline, expected_response.body)
38
+ subject.call
39
+ end
40
+
41
+ it 'should return an instance of Response' do
42
+ expect(double_client).to receive(:call).and_return(expected_response)
43
+ expect(subject.call).to be_an_instance_of(PixiClient::Response)
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe PixiClient::Requests::CancelOrder do
4
+ let(:order_nr) { 1 }
5
+ subject { PixiClient::Requests::CancelOrder.new(order_nr) }
6
+
7
+ before do
8
+ set_default_config
9
+ end
10
+
11
+ it { is_expected.to be_a_kind_of(PixiClient::Requests::Base) }
12
+
13
+ describe '#api_method' do
14
+ it 'should return :pixi_cancel_order' do
15
+ expect(subject.api_method).to eq :pixi_cancel_order
16
+ end
17
+ end
18
+
19
+ describe 'call behaviour' do
20
+ let(:expected_response) { double(body: { pixi_cancel_order_response: { pixi_cancel_order_result: sql_row_set_response_mock } }) }
21
+ let(:double_client) { double }
22
+
23
+ before do
24
+ allow(subject).to receive(:client).and_return(double_client)
25
+ end
26
+
27
+ it 'should call the client with the appropriate parameters' do
28
+ expect(double_client).to receive(:call)
29
+ .with(:pixi_cancel_order, attributes: { xmlns: PixiClient.configuration.endpoint }, message: { 'OrderNr' => order_nr })
30
+ .and_return(expected_response)
31
+
32
+ subject.call
33
+ end
34
+
35
+ it 'should instanciate an instance of Response with the response body' do
36
+ expect(double_client).to receive(:call).and_return(expected_response)
37
+ expect(PixiClient::Response).to receive(:new).with(:pixi_cancel_order, expected_response.body)
38
+ subject.call
39
+ end
40
+
41
+ it 'should return an instance of Response' do
42
+ expect(double_client).to receive(:call).and_return(expected_response)
43
+ expect(subject.call).to be_an_instance_of(PixiClient::Response)
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe PixiClient::Requests::GetChangedItemStock do
4
+ let(:ts) { Time.parse('2014-12-25 00:00:00') }
5
+ subject { PixiClient::Requests::GetChangedItemStock.new(since: ts) }
6
+
7
+ before do
8
+ set_default_config
9
+ end
10
+
11
+ it { is_expected.to be_a_kind_of(PixiClient::Requests::Base) }
12
+
13
+ describe '#api_method' do
14
+ it 'should return :get_changed_item_stock' do
15
+ expect(subject.api_method).to eq :pixi_get_changed_item_stock
16
+ end
17
+ end
18
+
19
+ describe '#message' do
20
+ context 'without row count' do
21
+ it 'should return a hash in the form {\'Since\' => <timestamp>}' do
22
+ expect(subject.message).to eq({ 'Since' => ts.strftime('%Y-%m-%dT%H:%M:%S.%3N') })
23
+ end
24
+ end
25
+
26
+ context 'with row count' do
27
+ it 'should return a hash in the form {\'Since\' => <timestamp>, \'RowCount\' => <count>}' do
28
+ subject.row_count = 100
29
+ expect(subject.message).to eq({ 'Since' => ts.strftime('%Y-%m-%dT%H:%M:%S.%3N'), 'RowCount' => 100})
30
+ end
31
+ end
32
+ end
33
+
34
+ describe 'call behaviour' do
35
+ let(:expected_response) { double(body: { pixi_get_changed_item_stock_response: { pixi_get_changed_item_stock_result: sql_row_set_response_mock } }) }
36
+ let(:double_client) { double }
37
+
38
+ before do
39
+ allow(subject).to receive(:client).and_return(double_client)
40
+ end
41
+
42
+ it 'should call the client with the appropriate parameters' do
43
+ expect(double_client).to receive(:call)
44
+ .with(:pixi_get_changed_item_stock, attributes: { xmlns: PixiClient.configuration.endpoint }, message: { 'Since' => ts.strftime('%Y-%m-%dT%H:%M:%S.%3N') })
45
+ .and_return(expected_response)
46
+
47
+ subject.call
48
+ end
49
+
50
+ it 'should instanciate an instance of Response with the response body' do
51
+ expect(double_client).to receive(:call).and_return(expected_response)
52
+ expect(PixiClient::Response).to receive(:new).with(:pixi_get_changed_item_stock, expected_response.body)
53
+ subject.call
54
+ end
55
+
56
+ it 'should return an instance of Response' do
57
+ expect(double_client).to receive(:call).and_return(expected_response)
58
+ expect(subject.call).to be_an_instance_of(PixiClient::Response)
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ describe PixiClient::Requests::GetChangedItems do
4
+ let(:ts) { Time.parse('2014-12-25') }
5
+ subject { PixiClient::Requests::GetChangedItems.new(since: ts) }
6
+
7
+ before do
8
+ set_default_config
9
+ end
10
+
11
+ it { is_expected.to be_a_kind_of(PixiClient::Requests::Base) }
12
+
13
+ describe '#api_method' do
14
+ it 'should return :get_changed_item_stock' do
15
+ expect(subject.api_method).to eq :pixi_get_changed_items
16
+ end
17
+ end
18
+
19
+ describe '#message' do
20
+ context 'without row count' do
21
+ it 'should return a hash in the form {\'Since\' => <timestamp>}' do
22
+ expect(subject.message).to eq({ 'Since' => ts.strftime('%Y-%m-%dT%H:%M:%S.%3N') })
23
+ end
24
+ end
25
+ end
26
+
27
+ describe 'call behaviour' do
28
+ let(:expected_response) { double(body: { pixi_get_changed_items_response: { pixi_get_changed_items_result: sql_row_set_response_mock } }) }
29
+ let(:double_client) { double }
30
+
31
+ before do
32
+ allow(subject).to receive(:client).and_return(double_client)
33
+ end
34
+
35
+ it 'should call the client with the appropriate parameters' do
36
+ expect(double_client).to receive(:call)
37
+ .with(:pixi_get_changed_items, attributes: { xmlns: PixiClient.configuration.endpoint }, message: { 'Since' => ts.strftime('%Y-%m-%dT%H:%M:%S.%3N') })
38
+ .and_return(expected_response)
39
+
40
+ subject.call
41
+ end
42
+
43
+ it 'should instanciate an instance of Response with the response body' do
44
+ expect(double_client).to receive(:call).and_return(expected_response)
45
+ expect(PixiClient::Response).to receive(:new).with(:pixi_get_changed_items, expected_response.body)
46
+ subject.call
47
+ end
48
+
49
+ it 'should return an instance of Response' do
50
+ expect(double_client).to receive(:call).and_return(expected_response)
51
+ expect(subject.call).to be_an_instance_of(PixiClient::Response)
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ describe PixiClient::Requests::GetInvoice do
4
+ subject { PixiClient::Requests::GetInvoice.new('ABC123456') }
5
+
6
+ before do
7
+ set_default_config
8
+ end
9
+
10
+ it { is_expected.to be_a_kind_of(PixiClient::Requests::Base) }
11
+
12
+ describe '#api_method' do
13
+ it 'should return :get_changed_item_stock' do
14
+ expect(subject.api_method).to eq :pixi_get_invoice
15
+ end
16
+ end
17
+
18
+ describe 'call behaviour' do
19
+ let(:expected_response) { double(body: { pixi_get_invoice_response: { pixi_get_invoice_result: sql_row_set_response_mock } }) }
20
+ let(:double_client) { double }
21
+
22
+ before do
23
+ allow(subject).to receive(:client).and_return(double_client)
24
+ end
25
+
26
+ it 'should call the client with the appropriate parameters' do
27
+ expect(double_client).to receive(:call)
28
+ .with(:pixi_get_invoice, attributes: { xmlns: PixiClient.configuration.endpoint }, message: { 'InvoiceNr' => 'ABC123456' })
29
+ .and_return(expected_response)
30
+
31
+ subject.call
32
+ end
33
+
34
+ it 'should instanciate an instance of GetChangedItemStockResponse with the response body' do
35
+ expect(double_client).to receive(:call).and_return(expected_response)
36
+ expect(PixiClient::Response).to receive(:new).with(:pixi_get_invoice, expected_response.body)
37
+ subject.call
38
+ end
39
+
40
+ it 'should return an instance of Response' do
41
+ expect(double_client).to receive(:call).and_return(expected_response)
42
+ expect(subject.call).to be_an_instance_of(PixiClient::Response)
43
+ end
44
+ end
45
+
46
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe PixiClient::Requests::GetItemInfo do
4
+ subject { PixiClient::Requests::GetItemInfo.new(:ean, '1234567890123') }
5
+
6
+ before do
7
+ set_default_config
8
+ end
9
+
10
+ it_behaves_like 'itemable'
11
+
12
+ it { is_expected.to be_a_kind_of(PixiClient::Requests::Base) }
13
+
14
+ describe '#api_method' do
15
+ it 'should return :get_changed_item_stock' do
16
+ expect(subject.api_method).to eq :pixi_get_item_info
17
+ end
18
+ end
19
+
20
+ describe 'call behaviour' do
21
+ let(:expected_response) { double(body: { pixi_get_item_info_response: { pixi_get_item_info_result: sql_row_set_response_mock } }) }
22
+ let(:double_client) { double }
23
+
24
+ before do
25
+ allow(subject).to receive(:client).and_return(double_client)
26
+ end
27
+
28
+ it 'should call the client with the appropriate parameters' do
29
+ expect(double_client).to receive(:call)
30
+ .with(:pixi_get_item_info, attributes: { xmlns: PixiClient.configuration.endpoint }, message: { 'EAN' => '1234567890123' })
31
+ .and_return(expected_response)
32
+
33
+ subject.call
34
+ end
35
+
36
+ it 'should instanciate an instance of GetChangedItemStockResponse with the response body' do
37
+ expect(double_client).to receive(:call).and_return(expected_response)
38
+ expect(PixiClient::Response).to receive(:new).with(:pixi_get_item_info, expected_response.body)
39
+ subject.call
40
+ end
41
+
42
+ it 'should return an instance of Response' do
43
+ expect(double_client).to receive(:call).and_return(expected_response)
44
+ expect(subject.call).to be_an_instance_of(PixiClient::Response)
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe PixiClient::Requests::GetItemStockBins do
4
+ subject { PixiClient::Requests::GetItemStockBins.new(:ean, '1234567890123') }
5
+
6
+ before do
7
+ set_default_config
8
+ end
9
+
10
+ it_behaves_like 'itemable'
11
+
12
+ it { is_expected.to be_a_kind_of(PixiClient::Requests::Base) }
13
+
14
+ describe '#api_method' do
15
+ it 'should return :get_changed_item_stock' do
16
+ expect(subject.api_method).to eq :pixi_get_item_stock_bins
17
+ end
18
+ end
19
+
20
+ describe 'call behaviour' do
21
+ let(:expected_response) { double(body: { pixi_get_item_stock_bins_response: { pixi_get_item_stock_bins_result: sql_row_set_response_mock } }) }
22
+ let(:double_client) { double }
23
+
24
+ before do
25
+ allow(subject).to receive(:client).and_return(double_client)
26
+ end
27
+
28
+ it 'should call the client with the appropriate parameters' do
29
+ expect(double_client).to receive(:call)
30
+ .with(:pixi_get_item_stock_bins, attributes: { xmlns: PixiClient.configuration.endpoint }, message: { 'EAN' => '1234567890123' })
31
+ .and_return(expected_response)
32
+
33
+ subject.call
34
+ end
35
+
36
+ it 'should instanciate an instance of Response with the response body' do
37
+ expect(double_client).to receive(:call).and_return(expected_response)
38
+ expect(PixiClient::Response).to receive(:new).with(:pixi_get_item_stock_bins, expected_response.body)
39
+ subject.call
40
+ end
41
+
42
+ it 'should return an instance of Response' do
43
+ expect(double_client).to receive(:call).and_return(expected_response)
44
+ expect(subject.call).to be_an_instance_of(PixiClient::Response)
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+
3
+ describe PixiClient::Requests::GetItemsInfo do
4
+ let(:ean_codes) { [1,2,3] }
5
+ let(:location_id) { '001' }
6
+ subject { PixiClient::Requests::GetItemsInfo.new(ean_codes, location_id) }
7
+
8
+ before do
9
+ set_default_config
10
+ end
11
+
12
+ it { is_expected.to be_a_kind_of(PixiClient::Requests::Base) }
13
+
14
+ describe '#api_method' do
15
+ it 'should return :pixi_get_item_info' do
16
+ expect(subject.api_method).to eq :pixi_get_item_info
17
+ end
18
+ end
19
+
20
+ describe 'call behaviour' do
21
+ let(:expected_response) { double(body: { pixi_get_item_info_response: { pixi_get_item_info_result: sql_row_set_response_mock } }) }
22
+ let(:double_client) { double }
23
+
24
+ before do
25
+ allow(subject).to receive(:client).and_return(double_client)
26
+ end
27
+
28
+ it 'should call the client with the appropriate parameters' do
29
+ builder = Builder::XmlMarkup.new
30
+
31
+ builder.ITEMS do
32
+ ean_codes.each do |code|
33
+ builder.ITEM do
34
+ builder.EAN code
35
+ end
36
+ end
37
+ end
38
+
39
+ expected_xml_message = builder.target!
40
+
41
+ expect(double_client).to receive(:call)
42
+ .with(:pixi_get_item_info, attributes: { xmlns: PixiClient.configuration.endpoint }, message: { 'LocID' => location_id, 'ItemXML' => expected_xml_message })
43
+ .and_return(expected_response)
44
+
45
+ subject.call
46
+ end
47
+
48
+ it 'should instanciate an instance of Response with the response body' do
49
+ expect(double_client).to receive(:call).and_return(expected_response)
50
+ expect(PixiClient::Response).to receive(:new).with(:pixi_get_item_info, expected_response.body)
51
+ subject.call
52
+ end
53
+
54
+ it 'should return an instance of Response' do
55
+ expect(double_client).to receive(:call).and_return(expected_response)
56
+ expect(subject.call).to be_an_instance_of(PixiClient::Response)
57
+ end
58
+ end
59
+
60
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe PixiClient::Requests::GetItemsOnStockBin do
4
+ let(:bin_name) { 'macondo' }
5
+ subject { PixiClient::Requests::GetItemsOnStockBin.new(bin_name) }
6
+
7
+ before do
8
+ set_default_config
9
+ end
10
+
11
+ it { is_expected.to be_a_kind_of(PixiClient::Requests::Base) }
12
+
13
+ describe '#api_method' do
14
+ it 'should return :pixi_get_items_on_stock_bin' do
15
+ expect(subject.api_method).to eq :pixi_get_items_on_stock_bin
16
+ end
17
+ end
18
+
19
+ describe 'call behaviour' do
20
+ let(:expected_response) { double(body: { pixi_get_items_on_stock_bin_response: { pixi_get_items_on_stock_bin_result: sql_row_set_response_mock } }) }
21
+ let(:double_client) { double }
22
+
23
+ before do
24
+ allow(subject).to receive(:client).and_return(double_client)
25
+ end
26
+
27
+ it 'should call the client with the appropriate parameters' do
28
+ expect(double_client).to receive(:call)
29
+ .with(:pixi_get_items_on_stock_bin, attributes: { xmlns: PixiClient.configuration.endpoint }, message: { 'BinName' => bin_name })
30
+ .and_return(expected_response)
31
+
32
+ subject.call
33
+ end
34
+
35
+ it 'should instanciate an instance of Response with the response body' do
36
+ expect(double_client).to receive(:call).and_return(expected_response)
37
+ expect(PixiClient::Response).to receive(:new).with(:pixi_get_items_on_stock_bin, expected_response.body)
38
+ subject.call
39
+ end
40
+
41
+ it 'should return an instance of Response' do
42
+ expect(double_client).to receive(:call).and_return(expected_response)
43
+ expect(subject.call).to be_an_instance_of(PixiClient::Response)
44
+ end
45
+ end
46
+
47
+ end