pixi_client 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
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,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe PixiClient::Requests::GetItemsStockHistory do
4
+ let(:message) { 'Life is too short to learn german' }
5
+ subject { PixiClient::Requests::GetItemsStockHistory.new(message) }
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_stock_history' do
15
+ expect(subject.api_method).to eq :pixi_get_items_stock_history
16
+ end
17
+ end
18
+
19
+ describe 'call behaviour' do
20
+ let(:expected_response) { double(body: { pixi_get_items_stock_history_response: { pixi_get_items_stock_history_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_stock_history, attributes: { xmlns: PixiClient.configuration.endpoint }, message: 'Life is too short to learn german')
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_stock_history, 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,46 @@
1
+ require 'spec_helper'
2
+
3
+ describe PixiClient::Requests::GetOrderComments do
4
+ subject { PixiClient::Requests::GetOrderComments.new('12345') }
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 :pixi_get_order_comments' do
14
+ expect(subject.api_method).to eq :pixi_get_order_comments
15
+ end
16
+ end
17
+
18
+ describe 'call behaviour' do
19
+ let(:expected_response) { double(body: { pixi_get_order_comments_response: { pixi_get_order_comments_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_order_comments, attributes: { xmlns: PixiClient.configuration.endpoint }, message: { 'OrderNr' => '12345' })
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_order_comments, 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,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe PixiClient::Requests::GetOrderHeader do
4
+ let(:external_shop_order_id) { 1 }
5
+ subject { PixiClient::Requests::GetOrderHeader.new(external_shop_order_id) }
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_order_header' do
15
+ expect(subject.api_method).to eq :pixi_get_order_header
16
+ end
17
+ end
18
+
19
+ describe 'call behaviour' do
20
+ let(:expected_response) { double(body: { pixi_get_order_header_response: { pixi_get_order_header_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_order_header, attributes: { xmlns: PixiClient.configuration.endpoint }, message: { 'OrderNrExternal' => external_shop_order_id })
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_order_header, 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::GetOrderLineHistory do
4
+ let(:order_line_key) { 1 }
5
+ subject { PixiClient::Requests::GetOrderLineHistory.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_get_orderline_history' do
15
+ expect(subject.api_method).to eq :pixi_get_orderline_history
16
+ end
17
+ end
18
+
19
+ describe 'call behaviour' do
20
+ let(:expected_response) { double(body: { pixi_get_orderline_history_response: { pixi_get_orderline_history_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_orderline_history, 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_get_orderline_history, 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::GetOrderLines do
4
+ let(:pixi_order_number) { 1 }
5
+ subject { PixiClient::Requests::GetOrderLines.new(pixi_order_number) }
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_orderline' do
15
+ expect(subject.api_method).to eq :pixi_get_orderline
16
+ end
17
+ end
18
+
19
+ describe 'call behaviour' do
20
+ let(:expected_response) { double(body: { pixi_get_orderline_response: { pixi_get_orderline_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_orderline, attributes: { xmlns: PixiClient.configuration.endpoint }, message: { 'OrderNR' => pixi_order_number})
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_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,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe PixiClient::Requests::GetOrderNrExternalByBoxNr do
4
+ include Savon::SpecHelper
5
+
6
+ let(:box_nr) { '12345' }
7
+ subject { PixiClient::Requests::GetOrderNrExternalByBoxNr.new(box_nr: box_nr) }
8
+
9
+ before(:all) do
10
+ set_default_config
11
+ savon.mock!
12
+ end
13
+
14
+ after(:all) { savon.unmock! }
15
+
16
+ before do
17
+ set_default_config
18
+ end
19
+
20
+ it { is_expected.to be_a_kind_of(PixiClient::Requests::Base) }
21
+
22
+ describe '#api_method' do
23
+ it 'should return :pixi_get_order_nr_external_by_box_nr' do
24
+ expect(subject.api_method).to eq :pixi_get_order_nr_external_by_box_nr
25
+ end
26
+ end
27
+
28
+ describe '#message' do
29
+ it 'should return a hash in the form {\'BoxNr\' => <box_nr>}' do
30
+ expect(subject.message).to eq('BoxNr' => box_nr)
31
+ end
32
+ end
33
+
34
+ describe 'call behaviour' do
35
+ before do
36
+ savon.
37
+ expects(:pixi_get_order_nr_external_by_box_nr).
38
+ with(message: { 'BoxNr' => box_nr }).
39
+ returns(File.read('spec/fixtures/get_order_nr_external_by_box_nr.xml')) # See file for data details
40
+ end
41
+
42
+ context 'when the box_nr exists', skip: true do
43
+ it 'returns one row with the box_nr and the external order number' do
44
+ result = subject.call
45
+ expect(result.rows.size).to eq 1
46
+ expect(result.rows.first.order_nr).to eq 10000
47
+ expect(result.rows.first.order_nr_external).to eq '193498' # expected external number
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe PixiClient::Requests::GetStockByBin do
4
+ let(:loc_id) { '001' }
5
+ subject { PixiClient::Requests::GetStockByBin.new(loc_id) }
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_stock_bins' do
15
+ expect(subject.api_method).to eq :pixi_get_stock_bins
16
+ end
17
+ end
18
+
19
+ describe 'call behaviour' do
20
+ let(:expected_response) { double(body: { pixi_get_stock_bins_response: { pixi_get_stock_bins_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_stock_bins, attributes: { xmlns: PixiClient.configuration.endpoint }, message: { 'LocID' => loc_id})
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_stock_bins, 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::GetStock do
4
+ let(:exclude_zeros) { false }
5
+ subject { PixiClient::Requests::GetStock.new(exclude_zeros) }
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_shop_link_get_items_stock' do
15
+ expect(subject.api_method).to eq :pixi_shop_link_get_items_stock
16
+ end
17
+ end
18
+
19
+ describe 'call behaviour' do
20
+ let(:expected_response) { double(body: { pixi_shop_link_get_items_stock_response: { pixi_shop_link_get_items_stock_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_shop_link_get_items_stock, attributes: { xmlns: PixiClient.configuration.endpoint }, message: { 'ExcludeZeros' => exclude_zeros})
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_shop_link_get_items_stock, 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::GetUnshippableOrders do
4
+ let(:location) { '001' }
5
+ subject { PixiClient::Requests::GetUnshippableOrders.new(location) }
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_add_order_comment' do
15
+ expect(subject.api_method).to eq :pixi_report_get_unshippable_orders
16
+ end
17
+ end
18
+
19
+ describe 'call behaviour' do
20
+ let(:expected_response) { double(body: { pixi_report_get_unshippable_orders_response: { pixi_report_get_unshippable_orders_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_report_get_unshippable_orders, attributes: { xmlns: PixiClient.configuration.endpoint }, message: { 'ViewDetails' => 1, 'IncludeCustLock' => 0, 'LocID' => location })
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_report_get_unshippable_orders, 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,52 @@
1
+ require 'spec_helper'
2
+
3
+ shared_examples 'itemable' do
4
+ before do
5
+ subject.item_id = '12345'
6
+ end
7
+
8
+ describe '#message' do
9
+
10
+ context 'item_id_key is :ean' do
11
+ it 'returns {\'EAN\' => \'12345\'}' do
12
+ subject.item_id_key = :ean
13
+ expect(subject.message).to eq({ 'EAN' => '12345' })
14
+ end
15
+ end
16
+
17
+ context 'item_id_key is :eanupc' do
18
+ it 'returns {\'EANUPC\' => \'12345\'}' do
19
+ subject.item_id_key = :eanupc
20
+ expect(subject.message).to eq({ 'EANUPC' => '12345' })
21
+ end
22
+ end
23
+
24
+ context 'item_id_key is :item_key' do
25
+ it 'returns {\'ItemKey\' => \'12345\'}' do
26
+ subject.item_id_key = :item_key
27
+ expect(subject.message).to eq({ 'ItemKey' => '12345' })
28
+ end
29
+ end
30
+
31
+ context 'item_id_key is :item_nr_int' do
32
+ it 'returns {\'ItemNrInt\' => \'12345\'}' do
33
+ subject.item_id_key = :item_nr_int
34
+ expect(subject.message).to eq({ 'ItemNrInt' => '12345' })
35
+ end
36
+ end
37
+
38
+ context 'item_id_key is :item_nr_suppl' do
39
+ it 'returns {\'ItemNrSuppl\' => \'12345\'}' do
40
+ subject.item_id_key = :item_nr_suppl
41
+ expect(subject.message).to eq({ 'ItemNrSuppl' => '12345' })
42
+ end
43
+ end
44
+
45
+ context 'the item id key is not allowed' do
46
+ it 'raises an exception' do
47
+ subject.item_id_key = :random_key
48
+ expect { subject.message }.to raise_error
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe PixiClient::Requests::ReadItems do
4
+ let(:created_from) { Time.now }
5
+ let(:created_to) { Time.now }
6
+ subject { PixiClient::Requests::ReadItems.new(created_from, created_to) }
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_read_items
17
+ end
18
+ end
19
+
20
+ describe 'call behaviour' do
21
+ let(:expected_response) { double(body: { pixi_read_items_response: { pixi_read_items_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
+
30
+ expected_from_string = created_from.strftime('%Y-%m-%dT%H:%M:%S.%3N')
31
+ expected_to_string = created_to.strftime('%Y-%m-%dT%H:%M:%S.%3N')
32
+ expected_message = {
33
+ 'CreateDateFrom' => expected_from_string,
34
+ 'CreateDateTo' => expected_to_string
35
+ }
36
+
37
+ expect(double_client).to receive(:call)
38
+ .with(:pixi_read_items, attributes: { xmlns: PixiClient.configuration.endpoint }, message: expected_message)
39
+ .and_return(expected_response)
40
+
41
+ subject.call
42
+ end
43
+
44
+ it 'should instanciate an instance of Response with the response body' do
45
+ expect(double_client).to receive(:call).and_return(expected_response)
46
+ expect(PixiClient::Response).to receive(:new).with(:pixi_read_items, expected_response.body)
47
+ subject.call
48
+ end
49
+
50
+ it 'should return an instance of Response' do
51
+ expect(double_client).to receive(:call).and_return(expected_response)
52
+ expect(subject.call).to be_an_instance_of(PixiClient::Response)
53
+ end
54
+ end
55
+
56
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe PixiClient::Requests::ReadOrderlines do
4
+ let(:message) { 'Life is too short to learn german' }
5
+ subject { PixiClient::Requests::ReadOrderlines.new(message) }
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_add_order_comment' do
15
+ expect(subject.api_method).to eq :pixi_read_orderlines
16
+ end
17
+ end
18
+
19
+ describe 'call behaviour' do
20
+ let(:expected_response) { double(body: { pixi_read_orderlines_response: { pixi_read_orderlines_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_read_orderlines, attributes: { xmlns: PixiClient.configuration.endpoint }, message: message)
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_read_orderlines, 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,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe PixiClient::Requests::SetStockMultiple do
4
+ let(:stock_update_xml) { set_stock_multiple_parameter_xml_mock }
5
+ subject { PixiClient::Requests::SetStockMultiple.new(stock_update_xml) }
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_set_stock_multiple
16
+ end
17
+ end
18
+
19
+ describe '#message' do
20
+ it 'should return a hash in the form {\'ParameterXML\' => <xml_string>}' do
21
+ expect(subject.message).to eq({ 'ParameterXML' => stock_update_xml })
22
+ end
23
+ end
24
+
25
+ describe 'call behaviour' do
26
+ let(:expected_response) { double(body: { pixi_set_stock_multiple_response: { pixi_set_stock_multiple_result: sql_row_set_response_mock } }) }
27
+ let(:double_client) { double }
28
+
29
+ before do
30
+ allow(subject).to receive(:client).and_return(double_client)
31
+ end
32
+
33
+ it 'should call the client with the appropriate parameters' do
34
+ expect(double_client).to receive(:call)
35
+ .with(:pixi_set_stock_multiple, attributes: { xmlns: PixiClient.configuration.endpoint }, message: { 'ParameterXML' => stock_update_xml })
36
+ .and_return(expected_response)
37
+
38
+ subject.call
39
+ end
40
+
41
+ it 'should instanciate an instance of Response with the response body' do
42
+ expect(double_client).to receive(:call).and_return(expected_response)
43
+ expect(PixiClient::Response).to receive(:new).with(:pixi_set_stock_multiple, expected_response.body)
44
+ subject.call
45
+ end
46
+
47
+ it 'should return an instance of Response' do
48
+ expect(double_client).to receive(:call).and_return(expected_response)
49
+ expect(subject.call).to be_an_instance_of(PixiClient::Response)
50
+ end
51
+ end
52
+
53
+ end