peddler 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -3
- data/.rspec +1 -0
- data/.rvmrc +2 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +47 -0
- data/LICENSE +6 -6
- data/README.md +128 -0
- data/Rakefile +12 -18
- data/lib/peddler/client.rb +18 -18
- data/lib/peddler/feeds.rb +26 -26
- data/lib/peddler/handlers.rb +5 -5
- data/lib/peddler/inventory.rb +16 -16
- data/lib/peddler/legacy_reports.rb +12 -12
- data/lib/peddler/refunds.rb +11 -13
- data/lib/peddler/reports.rb +12 -12
- data/lib/peddler/transport.rb +18 -18
- data/lib/peddler/version.rb +3 -0
- data/lib/peddler.rb +10 -11
- data/mussels.jpg +0 -0
- data/peddler.gemspec +28 -0
- data/spec/peddler/client_spec.rb +31 -33
- data/spec/peddler/feeds_spec.rb +65 -57
- data/spec/peddler/handlers_spec.rb +2 -2
- data/spec/peddler/inventory_spec.rb +45 -47
- data/spec/peddler/legacy_reports_spec.rb +54 -51
- data/spec/peddler/refunds_spec.rb +31 -24
- data/spec/peddler/reports_spec.rb +16 -14
- data/spec/peddler/transport_spec.rb +50 -50
- data/spec/spec_helper.rb +7 -3
- data/spec/support/amazon.yml.example +2 -0
- data/spec/support/amazon_credentials.rb +3 -0
- data/spec/support/vcr.rb +13 -0
- data/spec_rubies +2 -0
- metadata +102 -26
- data/History.txt +0 -17
- data/README.rdoc +0 -118
- data/VERSION.yml +0 -5
data/spec/peddler/feeds_spec.rb
CHANGED
@@ -1,78 +1,86 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
module Peddler
|
4
4
|
module Feeds
|
5
5
|
module OrderFulfillment
|
6
6
|
describe Batch do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
@fulfilled_order = Peddler::Feeds::OrderFulfillment::Item.new :order_id => '123-1234567-1234567',
|
12
|
-
:ship_date => Date.parse('2009-08-11').to_s
|
7
|
+
let(:transport) do
|
8
|
+
transport = Peddler::Transport.new
|
9
|
+
transport.modernize_request
|
10
|
+
transport
|
13
11
|
end
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
|
13
|
+
let(:feed) { Peddler::Feeds::OrderFulfillment::Batch.new(transport) }
|
14
|
+
|
15
|
+
let(:fulfilled_order) do
|
16
|
+
Peddler::Feeds::OrderFulfillment::Item.new(
|
17
|
+
:order_id => '123-1234567-1234567',
|
18
|
+
:ship_date => Date.parse('2009-08-11').to_s
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'adds items to batch' do
|
23
|
+
feed.batch.size.should == 0
|
24
|
+
feed << fulfilled_order
|
25
|
+
feed.batch.size.should == 1
|
19
26
|
end
|
20
|
-
|
21
|
-
it '
|
22
|
-
|
23
|
-
|
27
|
+
|
28
|
+
it 'creates content for upload' do
|
29
|
+
feed << fulfilled_order
|
30
|
+
feed.file_content.should == "order-id\torder-item-id\tquantity\tship-date\tcarrier-code\tcarrier-name\ttracking-number\tship-method\r\n123-1234567-1234567\t\t\t2009-08-11\t\t\t\t\r\n"
|
24
31
|
end
|
25
|
-
|
26
|
-
it '
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
+
|
33
|
+
it 'uploads' do
|
34
|
+
feed.id.should == nil
|
35
|
+
transport.stub!(:execute_request).and_return('<?xml version="1.0" encoding="UTF-8"?><Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://merchant-query.amazon.com/query/schema/MerchantQueryResponses.xsd"><Upload> <UploadId>130895733</UploadId><UploadType>_POST_FLAT_FILE_FULFILLMENT_DATA_</UploadType><UploadStatus>_SUBMITTED_</UploadStatus><SubmittedDate>2007-04-05T00:34:00+0000</SubmittedDate></Upload></Response>')
|
36
|
+
feed.upload
|
37
|
+
feed.id.should == '130895733'
|
38
|
+
feed.status.should == '_SUBMITTED_'
|
32
39
|
end
|
33
|
-
|
34
|
-
it '
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
|
41
|
+
it 'refreshes status' do
|
42
|
+
transport.stub!(:execute_request).and_return('<?xml version="1.0" encoding="UTF-8"?><Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://merchant-query.amazon.com/query/schema/MerchantQueryResponses.xsd"><Upload> <UploadId>130895733</UploadId><UploadType>_POST_FLAT_FILE_FULFILLMENT_DATA_</UploadType><UploadStatus>_SUBMITTED_</UploadStatus><SubmittedDate>2007-04-05T00:34:00+0000</SubmittedDate></Upload></Response>')
|
43
|
+
feed.upload
|
44
|
+
transport.stub!(:execute_request).and_return('<?xml version="1.0" encoding="UTF-8"?><Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://merchant-query.amazon.com/query/schema/MerchantQueryResponses.xsd"><UploadsStatusList><Upload><UploadId>130895733</UploadId><UploadType>_POST_FLAT_FILE_FULFILLMENT_DATA_</UploadType><UploadStatus>_IN_PROGRESS_</UploadStatus><SubmittedDate>2007-04-05T00:34:00+0000</SubmittedDate><StartedProcessingDate>2007-04-05T00:39:00+0000</StartedProcessingDate></Upload></UploadsStatusList></Response>')
|
45
|
+
feed.status.should == '_SUBMITTED_'
|
46
|
+
feed.status!.should == '_IN_PROGRESS_'
|
47
|
+
transport.stub!(:execute_request).and_return('<?xml version="1.0" encoding="UTF-8"?><Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://merchant-query.amazon.com/query/schema/MerchantQueryResponses.xsd"><UploadsStatusList><Upload><UploadId>130895733</UploadId><UploadType>_POST_FLAT_FILE_FULFILLMENT_DATA_</UploadType><UploadStatus>_DONE_</UploadStatus><SubmittedDate>2007-04-05T00:34:00+0000</SubmittedDate><StartedProcessingDate>2007-04-05T00:39:00+0000</StartedProcessingDate><CompletedProcessingDate>2007-04-05T01:02:00+0000</CompletedProcessingDate><MessagesProcessed>2</MessagesProcessed><MessagesSuccessful>2</MessagesSuccessful><MessagesWithErrors>0</MessagesWithErrors><MessagesWithWarnings>0</MessagesWithWarnings><RelatedDownloadsList><Download><DownloadId>3404021</DownloadId><DownloadType>FeedSummaryReport</DownloadType><RelatedReferenceId>4307285844</RelatedReferenceId><AvailableDate>2009-04-24T23:47:24+00:00</AvailableDate><Acknowledged>FALSE</Acknowledged></Download></RelatedDownloadsList></Upload></UploadsStatusList></Response>')
|
48
|
+
feed.status!.should == '_DONE_'
|
49
|
+
feed.download.id.should == '3404021'
|
50
|
+
feed.download.available_at.should == '2009-04-24T23:47:24+00:00'
|
44
51
|
end
|
45
52
|
end
|
46
53
|
end
|
47
|
-
|
54
|
+
|
48
55
|
module OrderCancellation
|
49
56
|
describe Batch do
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
@cancelled_order = Peddler::Feeds::OrderCancellation::Item.new :order_id => '123-1234567-1234567'
|
57
|
+
let(:transport) do
|
58
|
+
transport = Peddler::Transport.new
|
59
|
+
transport.modernize_request
|
60
|
+
transport
|
55
61
|
end
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
62
|
+
let(:feed) { Peddler::Feeds::OrderCancellation::Batch.new(transport) }
|
63
|
+
let(:cancelled_order) { Peddler::Feeds::OrderCancellation::Item.new(:order_id => '123-1234567-1234567') }
|
64
|
+
|
65
|
+
it 'adds items to batch' do
|
66
|
+
feed.batch.size.should == 0
|
67
|
+
feed << cancelled_order
|
68
|
+
feed.batch.size.should == 1
|
61
69
|
end
|
62
|
-
|
63
|
-
it '
|
64
|
-
|
65
|
-
|
70
|
+
|
71
|
+
it 'creates content for upload' do
|
72
|
+
feed << cancelled_order
|
73
|
+
feed.file_content.should == "TemplateType=OrderCancellation Version=1.0/1.0.3 This row for Amazon.com use only. Do not modify or delete.\r\norder-id\tcancellation-reason-code\tamazon-order-item-code\r\n123-1234567-1234567\t\t\r\n"
|
66
74
|
end
|
67
|
-
|
68
|
-
it '
|
69
|
-
|
70
|
-
lambda {
|
75
|
+
|
76
|
+
it 'raises error if cancellation reason code is given but Amazon order item code is missing' do
|
77
|
+
cancelled_order.cancellation_reason_code = 'BuyerCanceled'
|
78
|
+
lambda { cancelled_order.to_s }.should raise_error(PeddlerError)
|
71
79
|
end
|
72
|
-
|
73
|
-
it '
|
74
|
-
|
75
|
-
lambda {
|
80
|
+
|
81
|
+
it 'raises error if Amazon order item code is given but cancellation reason code is missing' do
|
82
|
+
cancelled_order.amazon_order_item_code = '111111111111'
|
83
|
+
lambda { cancelled_order.to_s }.should raise_error(PeddlerError)
|
76
84
|
end
|
77
85
|
end
|
78
86
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
module Peddler
|
4
4
|
module Handlers
|
5
5
|
describe TabDelimitedHandler do
|
6
|
-
it "
|
6
|
+
it "parses tab-delimited text" do
|
7
7
|
text = Peddler::Handlers::TabDelimitedHandler.decode_response("title\tautor\nA Thousand Plateaus\tGilles Deleuze\n")
|
8
8
|
text[0].title.should == 'A Thousand Plateaus'
|
9
9
|
end
|
@@ -1,50 +1,51 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
module Peddler
|
4
|
-
|
5
4
|
module Inventory
|
6
|
-
|
7
5
|
describe Queue do
|
8
|
-
|
9
|
-
it 'should show queue count' do
|
6
|
+
it 'shows queue count' do
|
10
7
|
transport = Peddler::Transport.new
|
11
8
|
transport.legacize_request
|
12
9
|
transport.stub!(:execute_request).and_return('<PendingUploadsCount>1</PendingUploadsCount>')
|
13
10
|
Peddler::Inventory::Queue.count(transport).should == 1
|
14
11
|
end
|
15
|
-
|
16
12
|
end
|
17
|
-
|
13
|
+
|
18
14
|
describe Batch do
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
15
|
+
let(:transport) do
|
16
|
+
transport = Peddler::Transport.new
|
17
|
+
transport.legacize_request
|
18
|
+
transport
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:inventory) { Peddler::Inventory::Batch.new(transport) }
|
22
|
+
let(:item) do
|
23
|
+
Peddler::Inventory::Item.new(
|
24
|
+
:product_id => '1234567890',
|
25
|
+
:price => 100.00,
|
26
|
+
:sku => 'FOO-SKU',
|
27
|
+
:quantity => 10
|
28
|
+
)
|
28
29
|
end
|
29
|
-
|
30
|
-
it '
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
|
31
|
+
it 'adds items to batch' do
|
32
|
+
inventory.batch.size.should == 0
|
33
|
+
inventory << item
|
34
|
+
inventory.batch.size.should == 1
|
34
35
|
end
|
35
|
-
|
36
|
-
it '
|
37
|
-
|
38
|
-
|
36
|
+
|
37
|
+
it 'generates an upload file' do
|
38
|
+
inventory << item
|
39
|
+
inventory.file_content.should == "product-id\tproduct-id-type\titem-condition\tprice\tsku\tquantity\tadd-delete\twill-ship-internationally\texpedited-shipping\titem-note\titem-is-marketplace\tfulfillment-center-id\titem-name\titem-description\tcategory1\timage-url\tshipping-fee\tbrowse-path\tstorefront-feature\tboldface\tasin1\tasin2\tasin3\r\n1234567890\t\t\t100.0\tFOO-SKU\t10\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n"
|
39
40
|
end
|
40
|
-
|
41
|
-
it '
|
42
|
-
|
43
|
-
|
41
|
+
|
42
|
+
it 'generates a modify-only upload file' do
|
43
|
+
inventory << item
|
44
|
+
inventory.file_content(:short).should == "sku\tprice\tquantity\r\nFOO-SKU\t100.0\t10\r\n"
|
44
45
|
end
|
45
|
-
|
46
|
-
it '
|
47
|
-
params =
|
46
|
+
|
47
|
+
it 'generates default headers for uploading' do
|
48
|
+
params = inventory.send(:defaultize,
|
48
49
|
:file_format => 'UIEE',
|
49
50
|
:enable_expedited_shipping => 'N'
|
50
51
|
)
|
@@ -55,22 +56,19 @@ module Peddler
|
|
55
56
|
params['enable-expedited-shipping'].should == 'N'
|
56
57
|
params[:enable_expedited_shipping].should be_nil
|
57
58
|
end
|
58
|
-
|
59
|
-
it '
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
|
60
|
+
it 'uploads batch' do
|
61
|
+
transport.stub!(:execute_request).and_return('<BatchID>2585199250</BatchID>')
|
62
|
+
inventory.upload.should == true
|
63
|
+
inventory.id.should == '2585199250'
|
63
64
|
end
|
64
|
-
|
65
|
-
it '
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
lambda {
|
65
|
+
|
66
|
+
it 'raises error if a subsequent upload is attempted' do
|
67
|
+
transport.stub!(:execute_request).and_return('<BatchID>2585199250</BatchID>')
|
68
|
+
inventory.upload.should == true
|
69
|
+
inventory.id.should_not == nil
|
70
|
+
lambda { inventory.upload }.should raise_error(PeddlerError)
|
70
71
|
end
|
71
|
-
|
72
72
|
end
|
73
|
-
|
74
73
|
end
|
75
|
-
|
76
|
-
end
|
74
|
+
end
|
@@ -1,28 +1,29 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
module Peddler
|
4
4
|
describe LegacyReports do
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
let(:transport) do
|
6
|
+
transport = Peddler::Transport.new
|
7
|
+
transport.legacize_request
|
8
|
+
transport
|
8
9
|
end
|
9
|
-
|
10
|
-
it '
|
11
|
-
|
12
|
-
res = Peddler::LegacyReports.generate(
|
10
|
+
|
11
|
+
it 'generates an order report' do
|
12
|
+
transport.stub!(:execute_request).and_return('<Status>SUCCESS</Status>')
|
13
|
+
res = Peddler::LegacyReports.generate(transport, :order, :number_of_days => 30)
|
13
14
|
res.should be_an_instance_of(Peddler::LegacyReports::Report)
|
14
15
|
end
|
15
|
-
|
16
|
-
it '
|
17
|
-
|
18
|
-
report_status = Peddler::LegacyReports.latest(
|
16
|
+
|
17
|
+
it 'shows most recent order reports' do
|
18
|
+
transport.stub!(:execute_request).and_return('<Reports> <Report>reportstarttime=12-26-2009:19-00-02 reportendtime=01-10-2010:19-00-02 reportid=2893717072 </Report><Report>reportstarttime=01-10-2010:14-00-00 reportendtime=01-10-2010:18-00-00 reportid=2893636754 </Report><Report>reportstarttime=12-26-2009:18-00-01 reportendtime=01-10-2010:18-00-01 reportid=2893629784 </Report><Report>reportstarttime=12-26-2009:17-00-07 reportendtime=01-10-2010:17-00-07 reportid=2893548356 </Report><Report>reportstarttime=12-26-2009:16-00-02 reportendtime=01-10-2010:16-00-02 reportid=2893461740 </Report><Report>reportstarttime=12-26-2009:15-00-02 reportendtime=01-10-2010:15-00-02 reportid=2893375352 </Report><Report>reportstarttime=01-10-2010:10-00-00 reportendtime=01-10-2010:14-00-00 reportid=2893291418 </Report><Report>reportstarttime=12-26-2009:14-00-02 reportendtime=01-10-2010:14-00-02 reportid=2893283538 </Report><Report>reportstarttime=12-26-2009:13-00-02 reportendtime=01-10-2010:13-00-02 reportid=2893197830 </Report><Report>reportstarttime=12-26-2009:12-00-02 reportendtime=01-10-2010:12-00-02 reportid=2893112598 </Report></Reports>')
|
19
|
+
report_status = Peddler::LegacyReports.latest(transport, :order, :count => 1)[0]
|
19
20
|
report_status.starts_at.should == '12-26-2009:19-00-02'
|
20
21
|
report_status.id.should == '2893717072'
|
21
22
|
end
|
22
|
-
|
23
|
-
it '
|
24
|
-
|
25
|
-
upload = Peddler::LegacyReports.latest(
|
23
|
+
|
24
|
+
it 'shows most recent uploads' do
|
25
|
+
transport.stub!(:execute_request).and_return('<Batches> <Batch>batchid=2586376232 status=Done dateandtime=08/07/2009 01:48:23 PDT activateditems=1020 numberofwarnings=0 itemsnotacivated=0 </Batch></Batches>')
|
26
|
+
upload = Peddler::LegacyReports.latest(transport, :upload, :count => 1)[0]
|
26
27
|
upload.id.should == '2586376232'
|
27
28
|
upload.status.should == 'Done'
|
28
29
|
upload.datetime.should == '08/07/2009 01:48:23 PDT'
|
@@ -31,56 +32,58 @@ module Peddler
|
|
31
32
|
upload.items_not_activated.should == '0'
|
32
33
|
end
|
33
34
|
end
|
34
|
-
|
35
|
+
|
35
36
|
module LegacyReports
|
36
37
|
describe Report do
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
let(:transport) do
|
39
|
+
transport = Peddler::Transport.new
|
40
|
+
transport.legacize_request
|
41
|
+
transport
|
41
42
|
end
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
43
|
+
|
44
|
+
let(:report) { Peddler::LegacyReports::Report.new(transport) }
|
45
|
+
|
46
|
+
it 'downloads an inventory upload error log' do
|
47
|
+
transport.stub!(:execute_request).and_return("Feed Processing Summary:\n\tNumber of records processed\t\t82\n\tNumber of records successful\t\t81\n\noriginal-record-number\tsku\terror-code\terror-type\terror-message\n27\t1111111111\t8026\tError\tSeller is not authorized to list products in this category. For more details, see http://sellercentral.amazon.com/gp/errorcode/8026\n")
|
48
|
+
|
49
|
+
report.name = :upload
|
50
|
+
report.id = '1234567890'
|
48
51
|
end
|
49
|
-
|
50
|
-
it '
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
|
53
|
+
it 'downloads an inventory upload error log' do
|
54
|
+
transport.stub!(:execute_request).and_return("Feed Processing Summary:\n\tNumber of records processed\t\t82\n\tNumber of records successful\t\t81\n\noriginal-record-number\tsku\terror-code\terror-type\terror-message\n27\t1111111111\t8026\tError\tSeller is not authorized to list products in this category. For more details, see http://sellercentral.amazon.com/gp/errorcode/8026\n")
|
55
|
+
report.name = :upload
|
56
|
+
report.id = '1234567890'
|
57
|
+
report.body.should =~ /Feed Processing Summary/
|
55
58
|
end
|
56
|
-
|
57
|
-
it '
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
res = Peddler::Handlers::TabDelimitedHandler.decode_response(
|
59
|
+
|
60
|
+
it 'retrieves an order report by id' do
|
61
|
+
transport.stub!(:execute_request).and_return("payments-status\torder-id\torder-item-id\tpayments-date\tpayments-transaction-id\titem-name\tlisting-id\tsku\tprice\tshipping-fee\tquantity-purchased\ttotal-price\tpurchase-date\tbatch-id\tbuyer-email\tbuyer-name\trecipient-name\tship-address-1\tship-address-2\tship-city\tship-state\tship-zip\tship-country\tspecial-comments\tupc\tship-method\n\t001-1234567-1234567\t12345678901234\t2009-07-23 08:59:03 PST\t\tFoo Bar\t000000000000\t1234567890\t10.00\t3.99\t1\t13.99\t2009-07-23 08:59:03 PST\t\tfoo@bar.com\tJOHN DOE\tJohn Doe\t1 MAIN ST\t\tNEW YORK\tNY\t10001-1000\tUS\t\t\tstandard\n")
|
62
|
+
report.name = :order
|
63
|
+
report.id = '1234567890'
|
64
|
+
res = Peddler::Handlers::TabDelimitedHandler.decode_response(report.body)
|
62
65
|
res.size.should == 1
|
63
66
|
res[0].order_id.should == '001-1234567-1234567'
|
64
67
|
res[0].buyer_name.should == 'JOHN DOE'
|
65
68
|
end
|
66
|
-
|
67
|
-
it '
|
68
|
-
|
69
|
-
|
70
|
-
res = Peddler::Handlers::TabDelimitedHandler.decode_response(
|
69
|
+
|
70
|
+
it 'retrieves an order report by report name' do
|
71
|
+
transport.stub!(:execute_request).and_return("payments-status\torder-id\torder-item-id\tpayments-date\tpayments-transaction-id\titem-name\tlisting-id\tsku\tprice\tshipping-fee\tquantity-purchased\ttotal-price\tpurchase-date\tbatch-id\tbuyer-email\tbuyer-name\trecipient-name\tship-address-1\tship-address-2\tship-city\tship-state\tship-zip\tship-country\tspecial-comments\tupc\tship-method\n\t001-1234567-1234567\t12345678901234\t2009-07-23 08:59:03 PST\t\tFoo Bar\t000000000000\t1234567890\t10.00\t3.99\t1\t13.99\t2009-07-23 08:59:03 PST\t\tfoo@bar.com\tJOHN DOE\tJohn Doe\t1 MAIN ST\t\tNEW YORK\tNY\t10001-1000\tUS\t\t\tstandard\n")
|
72
|
+
report.name = :order
|
73
|
+
res = Peddler::Handlers::TabDelimitedHandler.decode_response(report.body)
|
71
74
|
res.size.should == 1
|
72
75
|
res[0].order_id.should == '001-1234567-1234567'
|
73
76
|
res[0].buyer_name.should == 'JOHN DOE'
|
74
77
|
end
|
75
|
-
|
76
|
-
it '
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
res = Peddler::Handlers::TabDelimitedHandler.decode_response(
|
78
|
+
|
79
|
+
it 'retrieves an open listings liter report by id' do
|
80
|
+
transport.stub!(:execute_request).and_return("seller-sku\tquantity\nSKU-FOO\t14\n")
|
81
|
+
report.name = :open_listings_liter
|
82
|
+
report.id = '1234567890'
|
83
|
+
res = Peddler::Handlers::TabDelimitedHandler.decode_response(report.body)
|
81
84
|
res.size.should == 1
|
82
85
|
res[0].seller_sku.should == 'SKU-FOO'
|
83
86
|
end
|
84
87
|
end
|
85
88
|
end
|
86
|
-
end
|
89
|
+
end
|
@@ -1,34 +1,41 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
module Peddler
|
4
4
|
module Refunds
|
5
5
|
describe Batch do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
@refund = Peddler::Refunds::Item.new :order_id => "123-1234567-1234567",
|
11
|
-
:payments_transaction_id => "12341234567890",
|
12
|
-
:refund_amount => 10.00,
|
13
|
-
:reason => "CouldNotShip",
|
14
|
-
:message => "With our apologies"
|
6
|
+
let(:transport) do
|
7
|
+
transport = Peddler::Transport.new
|
8
|
+
transport.legacize_request
|
9
|
+
transport
|
15
10
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
11
|
+
|
12
|
+
let(:refunds) { Peddler::Refunds::Batch.new(transport) }
|
13
|
+
|
14
|
+
let(:refund) do
|
15
|
+
Peddler::Refunds::Item.new(
|
16
|
+
:order_id => "123-1234567-1234567",
|
17
|
+
:payments_transaction_id => "12341234567890",
|
18
|
+
:refund_amount => 10.00,
|
19
|
+
:reason => "CouldNotShip",
|
20
|
+
:message => "With our apologies"
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "adds items to batch" do
|
25
|
+
refunds.batch.size.should == 0
|
26
|
+
refunds << refund
|
27
|
+
refunds.batch.size.should == 1
|
21
28
|
end
|
22
|
-
|
23
|
-
it "
|
24
|
-
|
25
|
-
|
29
|
+
|
30
|
+
it "generates an upload file" do
|
31
|
+
refunds << refund
|
32
|
+
refunds.file_content.should == "order-id\tpayments-transaction-id\trefund-amount\treason\tmessage\r\n123-1234567-1234567\t12341234567890\t10.0\tCouldNotShip\tWith our apologies\r\n"
|
26
33
|
end
|
27
|
-
|
28
|
-
it "
|
29
|
-
|
30
|
-
|
31
|
-
|
34
|
+
|
35
|
+
it "uploads batch" do
|
36
|
+
transport.stub!(:execute_request).and_return("<Success>SUCCESS</Success>")
|
37
|
+
refunds << refund
|
38
|
+
refunds.upload.should == true
|
32
39
|
end
|
33
40
|
end
|
34
41
|
end
|
@@ -1,23 +1,25 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
module Peddler
|
4
4
|
module Reports
|
5
5
|
describe UnshippedOrdersReport do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
let(:transport) do
|
7
|
+
transport = Peddler::Transport.new
|
8
|
+
transport.modernize_request
|
9
|
+
transport.stub!(:execute_request).and_return('<?xml version="1.0"?>\n<Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://merchant-query.amazon.com/query/schema/MerchantQueryResponses.xsd"><Report><ReportID>2597613290</ReportID><DownloadType>_GET_FLAT_FILE_ACTIONABLE_ORDER_DATA_</DownloadType><StartDate>2009-08-05T19:54:31+00:00</StartDate><EndDate>2009-08-12T19:54:31+00:00</EndDate><Scheduled>false</Scheduled><ReportStatus>_SUBMITTED_</ReportStatus><SubmittedDate>2009-08-12T19:54:31+00:00</SubmittedDate></Report></Response>')
|
10
|
+
transport
|
11
11
|
end
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
|
13
|
+
let(:report) { Peddler::Reports::UnshippedOrdersReport.new(transport) }
|
14
|
+
|
15
|
+
it 'generates a request' do
|
16
|
+
report.id.should == '2597613290'
|
17
|
+
report.status.should == '_SUBMITTED_'
|
16
18
|
end
|
17
|
-
|
18
|
-
it '
|
19
|
-
|
20
|
-
|
19
|
+
|
20
|
+
it 'updates status' do
|
21
|
+
transport.stub!(:execute_request).and_return('<?xml version="1.0"?>\n<Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://merchant-query.amazon.com/query/schema/MerchantQueryResponses.xsd"><ReportsList><Report><ReportID>2893967048</ReportID><DownloadType>_GET_FLAT_FILE_ACTIONABLE_ORDER_DATA_</DownloadType><StartDate>2010-01-04T00:00:00+00:00</StartDate><EndDate>2010-01-12T00:00:00+00:00</EndDate><Scheduled>false</Scheduled><ReportStatus>_SUBMITTED_</ReportStatus><SubmittedDate>2010-01-11T06:02:40+00:00</SubmittedDate></Report></ReportsList></Response>')
|
22
|
+
report.status!.should == '_SUBMITTED_'
|
21
23
|
end
|
22
24
|
end
|
23
25
|
end
|