peddler 0.3.1 → 0.4.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.
- data/LICENSE +3 -3
- data/README.md +42 -105
- data/lib/peddler/feeds.rb +4 -184
- data/lib/peddler/fulfillment_inbound_shipment.rb +11 -0
- data/lib/peddler/fulfillment_inventory.rb +10 -0
- data/lib/peddler/fulfillment_outbound_shipment.rb +10 -0
- data/lib/peddler/orders.rb +10 -0
- data/lib/peddler/products.rb +11 -0
- data/lib/peddler/reports.rb +4 -94
- data/lib/peddler/sellers.rb +9 -0
- data/lib/peddler/service.rb +106 -0
- data/lib/peddler/version.rb +1 -1
- data/lib/peddler.rb +5 -17
- metadata +61 -175
- data/.gitignore +0 -5
- data/.rspec +0 -1
- data/.rvmrc +0 -2
- data/Gemfile +0 -4
- data/Gemfile.lock +0 -47
- data/Rakefile +0 -12
- data/lib/peddler/client.rb +0 -229
- data/lib/peddler/handlers.rb +0 -38
- data/lib/peddler/inventory.rb +0 -140
- data/lib/peddler/legacy_reports.rb +0 -109
- data/lib/peddler/refunds.rb +0 -52
- data/lib/peddler/transport.rb +0 -135
- data/mussels.jpg +0 -0
- data/peddler.gemspec +0 -28
- data/spec/peddler/client_spec.rb +0 -45
- data/spec/peddler/feeds_spec.rb +0 -88
- data/spec/peddler/handlers_spec.rb +0 -12
- data/spec/peddler/inventory_spec.rb +0 -74
- data/spec/peddler/legacy_reports_spec.rb +0 -89
- data/spec/peddler/refunds_spec.rb +0 -42
- data/spec/peddler/reports_spec.rb +0 -26
- data/spec/peddler/transport_spec.rb +0 -65
- data/spec/spec_helper.rb +0 -7
- data/spec/support/amazon.yml.example +0 -2
- data/spec/support/amazon_credentials.rb +0 -3
- data/spec/support/vcr.rb +0 -13
- data/spec_rubies +0 -2
@@ -1,89 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Peddler
|
4
|
-
describe LegacyReports do
|
5
|
-
let(:transport) do
|
6
|
-
transport = Peddler::Transport.new
|
7
|
-
transport.legacize_request
|
8
|
-
transport
|
9
|
-
end
|
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)
|
14
|
-
res.should be_an_instance_of(Peddler::LegacyReports::Report)
|
15
|
-
end
|
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]
|
20
|
-
report_status.starts_at.should == '12-26-2009:19-00-02'
|
21
|
-
report_status.id.should == '2893717072'
|
22
|
-
end
|
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]
|
27
|
-
upload.id.should == '2586376232'
|
28
|
-
upload.status.should == 'Done'
|
29
|
-
upload.datetime.should == '08/07/2009 01:48:23 PDT'
|
30
|
-
upload.activated_items.should == '1020'
|
31
|
-
upload.number_of_warnings.should == '0'
|
32
|
-
upload.items_not_activated.should == '0'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
module LegacyReports
|
37
|
-
describe Report do
|
38
|
-
let(:transport) do
|
39
|
-
transport = Peddler::Transport.new
|
40
|
-
transport.legacize_request
|
41
|
-
transport
|
42
|
-
end
|
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'
|
51
|
-
end
|
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/
|
58
|
-
end
|
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)
|
65
|
-
res.size.should == 1
|
66
|
-
res[0].order_id.should == '001-1234567-1234567'
|
67
|
-
res[0].buyer_name.should == 'JOHN DOE'
|
68
|
-
end
|
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)
|
74
|
-
res.size.should == 1
|
75
|
-
res[0].order_id.should == '001-1234567-1234567'
|
76
|
-
res[0].buyer_name.should == 'JOHN DOE'
|
77
|
-
end
|
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)
|
84
|
-
res.size.should == 1
|
85
|
-
res[0].seller_sku.should == 'SKU-FOO'
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Peddler
|
4
|
-
module Refunds
|
5
|
-
describe Batch do
|
6
|
-
let(:transport) do
|
7
|
-
transport = Peddler::Transport.new
|
8
|
-
transport.legacize_request
|
9
|
-
transport
|
10
|
-
end
|
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
|
28
|
-
end
|
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"
|
33
|
-
end
|
34
|
-
|
35
|
-
it "uploads batch" do
|
36
|
-
transport.stub!(:execute_request).and_return("<Success>SUCCESS</Success>")
|
37
|
-
refunds << refund
|
38
|
-
refunds.upload.should == true
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Peddler
|
4
|
-
module Reports
|
5
|
-
describe UnshippedOrdersReport do
|
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
|
-
end
|
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_'
|
18
|
-
end
|
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_'
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Peddler
|
4
|
-
describe Transport do
|
5
|
-
let(:transport) do
|
6
|
-
transport = Peddler::Transport.new
|
7
|
-
transport.username = 'user'
|
8
|
-
transport.password = 'secret'
|
9
|
-
transport.region = :us
|
10
|
-
transport
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'switches regions' do
|
14
|
-
transport.legacize_request
|
15
|
-
transport.region = :uk
|
16
|
-
transport.url.host.should == 'secure.amazon.co.uk'
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'raises error when region is invalid' do
|
20
|
-
lambda { transport.region = 'foo' }.should raise_error(PeddlerError)
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'adds path to legacy URL' do
|
24
|
-
transport.legacize_request
|
25
|
-
transport.path << 'foo'
|
26
|
-
transport.url.to_s.should == 'https://secure.amazon.com/exec/panama/seller-admin/foo'
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'adds path to modern URL' do
|
30
|
-
transport.modernize_request
|
31
|
-
transport.path << 'foo'
|
32
|
-
transport.url.to_s.should == 'https://secure.amazon.com/query/foo?Service=MerchantQueryService'
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'adds query parameters to the modern URL' do
|
36
|
-
transport.modernize_request
|
37
|
-
transport.query_params['key1'] = 'val1'
|
38
|
-
transport.query_params['key2'] = 'val2'
|
39
|
-
uri = URI.parse(transport.url.to_s)
|
40
|
-
keys = uri.query.split('&').map{ |param| param.match(/(.*)=/)[1] }
|
41
|
-
keys.should include('key1')
|
42
|
-
keys.should include('key2')
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'authenticates request' do
|
46
|
-
transport.legacize_request
|
47
|
-
req = transport.request
|
48
|
-
req['authorization'].should_not be(nil)
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'posts if there is a body' do
|
52
|
-
transport.body = 'foo'
|
53
|
-
transport.send(:request_method).should == Net::HTTP::Post
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'posts if there is a query parameter' do
|
57
|
-
transport.query_params = { :foo => 'bar' }
|
58
|
-
transport.send(:request_method).should == Net::HTTP::Post
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'gets if there is no body or query parameter' do
|
62
|
-
transport.send(:request_method).should == Net::HTTP::Get
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
data/spec/spec_helper.rb
DELETED
data/spec/support/vcr.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'vcr'
|
2
|
-
|
3
|
-
VCR.config do |c|
|
4
|
-
c.cassette_library_dir = File.dirname(__FILE__) + '/../fixtures/cassette_library'
|
5
|
-
c.http_stubbing_library = :webmock
|
6
|
-
c.default_cassette_options = {
|
7
|
-
:record => :new_episodes
|
8
|
-
}
|
9
|
-
end
|
10
|
-
|
11
|
-
RSpec.configure do |config|
|
12
|
-
config.extend VCR::RSpec::Macros
|
13
|
-
end
|
data/spec_rubies
DELETED