peddler 2.1.1 → 2.3.0
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/README.md +43 -41
- data/lib/mws.rb +2 -1
- data/lib/mws/easy_ship.rb +3 -0
- data/lib/mws/easy_ship/client.rb +93 -0
- data/lib/mws/fulfillment_outbound_shipment/client.rb +1 -1
- data/lib/mws/orders/client.rb +6 -6
- data/lib/mws/shipment_invoicing.rb +3 -0
- data/lib/mws/shipment_invoicing/client.rb +74 -0
- data/lib/peddler/client.rb +11 -10
- data/lib/peddler/content.rb +2 -2
- data/lib/peddler/errors/builder.rb +7 -2
- data/lib/peddler/errors/class_generator.rb +1 -1
- data/lib/peddler/errors/error.rb +6 -2
- data/lib/peddler/errors/parser.rb +1 -1
- data/lib/peddler/flat_file_parser.rb +5 -3
- data/lib/peddler/marketplace.rb +23 -19
- data/lib/peddler/mws.rb +2 -2
- data/lib/peddler/operation.rb +17 -11
- data/lib/peddler/parser.rb +1 -1
- data/lib/peddler/structured_list.rb +1 -1
- data/lib/peddler/vcr_matcher.rb +7 -7
- data/lib/peddler/version.rb +1 -1
- data/lib/peddler/xml_parser.rb +1 -1
- data/lib/peddler/xml_response_parser.rb +1 -1
- metadata +11 -146
- data/lib/mws/off_amazon_payments/client.rb +0 -362
- data/test/credentials.rb +0 -23
- data/test/helper.rb +0 -15
- data/test/integration/internals/test_errors.rb +0 -17
- data/test/integration/internals/test_multibyte_queries.rb +0 -17
- data/test/integration/internals/test_mws_headers.rb +0 -21
- data/test/integration/internals/test_string_encodings.rb +0 -38
- data/test/integration/test_feeds.rb +0 -37
- data/test/integration/test_fulfillment_inbound_shipment.rb +0 -35
- data/test/integration/test_fulfillment_inventory.rb +0 -20
- data/test/integration/test_fulfillment_outbound_shipment.rb +0 -13
- data/test/integration/test_merchant_fulfillment.rb +0 -69
- data/test/integration/test_off_amazon_payments.rb +0 -13
- data/test/integration/test_orders.rb +0 -30
- data/test/integration/test_products.rb +0 -97
- data/test/integration/test_recommendations.rb +0 -20
- data/test/integration/test_reports.rb +0 -51
- data/test/integration/test_sellers.rb +0 -13
- data/test/integration/test_subscriptions.rb +0 -27
- data/test/integration_helper.rb +0 -53
- data/test/mws.yml +0 -36
- data/test/mws.yml.example +0 -32
- data/test/null_client.rb +0 -25
- data/test/recorder.rb +0 -39
- data/test/unit/mws/test_feeds_client.rb +0 -103
- data/test/unit/mws/test_finances_client.rb +0 -74
- data/test/unit/mws/test_fulfillment_inbound_shipment_client.rb +0 -426
- data/test/unit/mws/test_fulfillment_inventory_client.rb +0 -48
- data/test/unit/mws/test_fulfillment_outbound_shipment_client.rb +0 -202
- data/test/unit/mws/test_merchant_fulfillment_client.rb +0 -109
- data/test/unit/mws/test_off_amazon_payments_client.rb +0 -286
- data/test/unit/mws/test_orders_client.rb +0 -111
- data/test/unit/mws/test_products_client.rb +0 -248
- data/test/unit/mws/test_recommendations_client.rb +0 -62
- data/test/unit/mws/test_reports_client.rb +0 -209
- data/test/unit/mws/test_sellers_client.rb +0 -47
- data/test/unit/mws/test_subscriptions_client.rb +0 -182
- data/test/unit/peddler/errors/test_builder.rb +0 -65
- data/test/unit/peddler/errors/test_class_generator.rb +0 -18
- data/test/unit/peddler/errors/test_error.rb +0 -33
- data/test/unit/peddler/errors/test_parser.rb +0 -44
- data/test/unit/peddler/test_client.rb +0 -203
- data/test/unit/peddler/test_flat_file_parser.rb +0 -111
- data/test/unit/peddler/test_headers.rb +0 -103
- data/test/unit/peddler/test_marketplace.rb +0 -47
- data/test/unit/peddler/test_operation.rb +0 -87
- data/test/unit/peddler/test_parser.rb +0 -36
- data/test/unit/peddler/test_structured_list.rb +0 -39
- data/test/unit/peddler/test_vcr_matcher.rb +0 -55
- data/test/unit/peddler/test_xml_parser.rb +0 -37
- data/test/unit/peddler/test_xml_response_parser.rb +0 -39
- data/test/unit/test_mws.rb +0 -11
- data/test/vcr_cassettes/CartInformation.yml +0 -433
- data/test/vcr_cassettes/CustomerInformation.yml +0 -433
- data/test/vcr_cassettes/Errors.yml +0 -444
- data/test/vcr_cassettes/Feeds.yml +0 -9957
- data/test/vcr_cassettes/FulfillmentInboundShipment.yml +0 -6166
- data/test/vcr_cassettes/FulfillmentInventory.yml +0 -850
- data/test/vcr_cassettes/FulfillmentOutboundShipment.yml +0 -433
- data/test/vcr_cassettes/MWSHeaders.yml +0 -2964
- data/test/vcr_cassettes/MerchantFulfillment.yml +0 -753
- data/test/vcr_cassettes/MultibyteQueries.yml +0 -437
- data/test/vcr_cassettes/OffAmazonPayments.yml +0 -433
- data/test/vcr_cassettes/Orders.yml +0 -4740
- data/test/vcr_cassettes/PeddlerVCRMatcher.yml +0 -41
- data/test/vcr_cassettes/Products.yml +0 -7139
- data/test/vcr_cassettes/Recommendations.yml +0 -3145
- data/test/vcr_cassettes/Reports.yml +0 -5549
- data/test/vcr_cassettes/Sellers.yml +0 -433
- data/test/vcr_cassettes/Subscriptions.yml +0 -1529
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'integration_helper'
|
4
|
-
require 'mws/subscriptions'
|
5
|
-
|
6
|
-
class TestSubscriptions < IntegrationTest
|
7
|
-
def test_listing_registered_destinations
|
8
|
-
clients.each do |client|
|
9
|
-
res = client.list_registered_destinations(client.marketplace.id)
|
10
|
-
refute_empty res.parse
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_listing_subscriptions
|
15
|
-
clients.each do |client|
|
16
|
-
res = client.list_subscriptions(client.marketplace.id)
|
17
|
-
refute_empty res.parse
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_getting_service_status
|
22
|
-
clients.each do |client|
|
23
|
-
res = client.get_service_status
|
24
|
-
refute_empty res.parse
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/test/integration_helper.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'credentials'
|
4
|
-
require 'helper'
|
5
|
-
require 'recorder'
|
6
|
-
|
7
|
-
class IntegrationTest < MiniTest::Test
|
8
|
-
include Recorder
|
9
|
-
|
10
|
-
class << self
|
11
|
-
def use(endpoint)
|
12
|
-
@current_endpoint = endpoint
|
13
|
-
end
|
14
|
-
|
15
|
-
def clients
|
16
|
-
klass = MWS.const_get("#{current_endpoint}::Client")
|
17
|
-
::Credentials.to_a.shuffle.each_with_object([]) do |credentials, memo|
|
18
|
-
client = klass.new(credentials)
|
19
|
-
country_code = client.marketplace.country_code
|
20
|
-
memo.define_singleton_method(country_code.downcase) { client }
|
21
|
-
memo << client
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def current_endpoint
|
28
|
-
@current_endpoint ||= name.sub('Test', '')
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def clients
|
33
|
-
self.class.clients
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
::Peddler::VCRMatcher.ignore_seller!
|
38
|
-
|
39
|
-
VCR.configure do |c|
|
40
|
-
c.before_record do |interaction|
|
41
|
-
%w[
|
42
|
-
BuyerName BuyerEmail Name AddressLine1 City StateOrProvinceCode PostalCode
|
43
|
-
Phone Amount AmazonOrderId SellerOrderId
|
44
|
-
].each do |key|
|
45
|
-
interaction.response.body.gsub!(/<#{key}>[^<]+</, "<#{key}>FILTERED<")
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
Credentials.each do |record|
|
50
|
-
c.filter_sensitive_data('MERCHANT_ID') { record['merchant_id'] }
|
51
|
-
c.filter_sensitive_data('AWS_ACCESS_KEY_ID') { record['aws_access_key_id'] }
|
52
|
-
end
|
53
|
-
end
|
data/test/mws.yml
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
- marketplace: CA
|
2
|
-
merchant_id: A2A7WNXBU01UJW
|
3
|
-
aws_access_key_id: AKIAILJW7BWJ6YBK4JUQ
|
4
|
-
aws_secret_access_key: aWkRC0uiw/njt7HbycxYEw7FnejK24I8a+v+BqRs
|
5
|
-
- marketplace: ES
|
6
|
-
merchant_id: A2NEU7G6RGUKF
|
7
|
-
aws_access_key_id: AKIAJAMAR367FRSYNOPA
|
8
|
-
aws_secret_access_key: sYY0puX7lT3lY3jA35CgTcSjcIspzx9WexUl04J6
|
9
|
-
- marketplace: MX
|
10
|
-
merchant_id: A1PCFAUFK3U94S
|
11
|
-
aws_access_key_id: AKIAIHE4A3HDKICFHP4A
|
12
|
-
aws_secret_access_key: Jg8a9DlgPbsQVsY0CzP2X0ph3vPAfQT2Gn+amdoo
|
13
|
-
- marketplace: JP
|
14
|
-
merchant_id: A7BU5WGNVGQ1I
|
15
|
-
aws_access_key_id: AKIAJZ6EOLNDLSOEOLBA
|
16
|
-
aws_secret_access_key: YwD/Y/ihoYPDhl4+u9aoHvuvUpyRrUys1nTHlYSI
|
17
|
-
- marketplace: IT
|
18
|
-
merchant_id: A2APQUVDBVWV7E
|
19
|
-
aws_access_key_id: AKIAIHE4YSF4UF7CDR6Q
|
20
|
-
aws_secret_access_key: yhS//40dfrQ/nIXiyvZCrPXfXLobXFfJGYetTHmp
|
21
|
-
- marketplace: FR
|
22
|
-
merchant_id: A2DP6GIDYN6OTH
|
23
|
-
aws_access_key_id: AKIAIOYKJRT4WIH3P72A
|
24
|
-
aws_secret_access_key: NrpJKu+kndIviLLZnIagpZXhxvgaOp8NZeTtwqcL
|
25
|
-
- marketplace: US
|
26
|
-
merchant_id: A2H6NH4SQYFZ4M
|
27
|
-
aws_access_key_id: AKIAJ25X7BKNXKVCYJXA
|
28
|
-
aws_secret_access_key: hguX3TMfKMrqKm71/dQLKqbv2VGCyZANnCXeHAsC
|
29
|
-
- marketplace: GB
|
30
|
-
merchant_id: A2D9DZ30GEWP6N
|
31
|
-
aws_access_key_id: AKIAJCJNB4MASX5JUMUA
|
32
|
-
aws_secret_access_key: mtCsco7E7tLMFcHfQQ7Wpal+vZxtNBKo+PjTkvm5
|
33
|
-
- marketplace: DE
|
34
|
-
merchant_id: A7ZXDJZD3UIRG
|
35
|
-
aws_access_key_id: AKIAIORT7554FEBW7UBQ
|
36
|
-
aws_secret_access_key: P2ocOVChe/dQUpxRfA1n3TmP+wHrF6GaSzXslvEG
|
data/test/mws.yml.example
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
- marketplace: US
|
2
|
-
aws_access_key_id: AWS_ACCESS_KEY_ID
|
3
|
-
aws_secret_access_key: AWS_SECRET_ACCESS_KEY
|
4
|
-
merchant_id: MERCHANT_ID
|
5
|
-
- marketplace: GB
|
6
|
-
aws_access_key_id: AWS_ACCESS_KEY_ID
|
7
|
-
aws_secret_access_key: AWS_SECRET_ACCESS_KEY
|
8
|
-
merchant_id: MERCHANT_ID
|
9
|
-
- marketplace: DE
|
10
|
-
aws_access_key_id: AWS_ACCESS_KEY_ID
|
11
|
-
aws_secret_access_key: AWS_SECRET_ACCESS_KEY
|
12
|
-
merchant_id: MERCHANT_ID
|
13
|
-
- marketplace: CA
|
14
|
-
aws_access_key_id: AWS_ACCESS_KEY_ID
|
15
|
-
aws_secret_access_key: AWS_SECRET_ACCESS_KEY
|
16
|
-
merchant_id: MERCHANT_ID
|
17
|
-
- marketplace: FR
|
18
|
-
aws_access_key_id: AWS_ACCESS_KEY_ID
|
19
|
-
aws_secret_access_key: AWS_SECRET_ACCESS_KEY
|
20
|
-
merchant_id: MERCHANT_ID
|
21
|
-
- marketplace: JP
|
22
|
-
aws_access_key_id: AWS_ACCESS_KEY_ID
|
23
|
-
aws_secret_access_key: AWS_SECRET_ACCESS_KEY
|
24
|
-
merchant_id: MERCHANT_ID
|
25
|
-
- marketplace: ES
|
26
|
-
aws_access_key_id: AWS_ACCESS_KEY_ID
|
27
|
-
aws_secret_access_key: AWS_SECRET_ACCESS_KEY
|
28
|
-
merchant_id: MERCHANT_ID
|
29
|
-
- marketplace: IT
|
30
|
-
aws_access_key_id: AWS_ACCESS_KEY_ID
|
31
|
-
aws_secret_access_key: AWS_SECRET_ACCESS_KEY
|
32
|
-
merchant_id: MERCHANT_ID
|
data/test/null_client.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'peddler/client'
|
4
|
-
require 'securerandom'
|
5
|
-
|
6
|
-
module Null
|
7
|
-
module Parser
|
8
|
-
def self.new(res, *)
|
9
|
-
res
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class Client < ::Peddler::Client
|
14
|
-
self.path = '/'
|
15
|
-
|
16
|
-
def configure_with_mock_data!
|
17
|
-
self.aws_access_key_id = SecureRandom.hex
|
18
|
-
self.aws_secret_access_key = SecureRandom.hex
|
19
|
-
self.merchant_id = SecureRandom.hex
|
20
|
-
self.marketplace = 'US'
|
21
|
-
end
|
22
|
-
|
23
|
-
self.parser = Parser
|
24
|
-
end
|
25
|
-
end
|
data/test/recorder.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'peddler/vcr_matcher'
|
4
|
-
require 'yaml'
|
5
|
-
require 'vcr'
|
6
|
-
|
7
|
-
# So we can continue testing against old Content-MD5 header
|
8
|
-
::Peddler::VCRMatcher.ignored_params << 'ContentMD5Value'
|
9
|
-
|
10
|
-
VCR.configure do |c|
|
11
|
-
c.hook_into :excon
|
12
|
-
c.cassette_library_dir = 'test/vcr_cassettes'
|
13
|
-
|
14
|
-
c.default_cassette_options = {
|
15
|
-
match_requests_on: [::Peddler::VCRMatcher],
|
16
|
-
record: ENV['RECORD'] ? :new_episodes : :none
|
17
|
-
}
|
18
|
-
|
19
|
-
# c.before_record do |interaction|
|
20
|
-
# code = interaction.response.status.code
|
21
|
-
# interaction.ignore! if code >= 400 && code != 414
|
22
|
-
# end
|
23
|
-
end
|
24
|
-
|
25
|
-
module Recorder
|
26
|
-
def setup
|
27
|
-
ENV['LIVE'] ? VCR.turn_off! : VCR.insert_cassette(test_name)
|
28
|
-
end
|
29
|
-
|
30
|
-
def teardown
|
31
|
-
VCR.eject_cassette if VCR.turned_on?
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def test_name
|
37
|
-
self.class.name.sub('Test', '')
|
38
|
-
end
|
39
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
require 'mws/feeds/client'
|
5
|
-
|
6
|
-
class TestMWSFeedsClient < MiniTest::Test
|
7
|
-
def setup
|
8
|
-
@client = MWS::Feeds::Client.new(marketplace: 'GB')
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_submitting_feed
|
12
|
-
operation = {
|
13
|
-
'Action' => 'SubmitFeed',
|
14
|
-
'FeedType' => 'type',
|
15
|
-
'MarketplaceIdList.Id.1' => '1'
|
16
|
-
}
|
17
|
-
|
18
|
-
@client.stub(:run, nil) do
|
19
|
-
@client.submit_feed('content', 'type', marketplace_id_list: '1')
|
20
|
-
end
|
21
|
-
|
22
|
-
assert_equal operation, @client.operation
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_getting_feed_submission_list
|
26
|
-
operation = {
|
27
|
-
'Action' => 'GetFeedSubmissionList',
|
28
|
-
'FeedSubmissionIdList.Id.1' => '1',
|
29
|
-
'FeedTypeList.Type.1' => '2',
|
30
|
-
'FeedProcessingStatusList.Status.1' => '3'
|
31
|
-
}
|
32
|
-
|
33
|
-
@client.stub(:run, nil) do
|
34
|
-
@client.get_feed_submission_list(
|
35
|
-
feed_submission_id_list: '1',
|
36
|
-
feed_type_list: '2',
|
37
|
-
feed_processing_status_list: '3'
|
38
|
-
)
|
39
|
-
end
|
40
|
-
|
41
|
-
assert_equal operation, @client.operation
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_getting_feed_submission_list_by_next_token
|
45
|
-
operation = {
|
46
|
-
'Action' => 'GetFeedSubmissionListByNextToken',
|
47
|
-
'NextToken' => '1'
|
48
|
-
}
|
49
|
-
|
50
|
-
@client.stub(:run, nil) do
|
51
|
-
@client.get_feed_submission_list_by_next_token('1')
|
52
|
-
end
|
53
|
-
|
54
|
-
assert_equal operation, @client.operation
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_getting_feed_submission_count
|
58
|
-
operation = {
|
59
|
-
'Action' => 'GetFeedSubmissionCount',
|
60
|
-
'FeedTypeList.Type.1' => '1',
|
61
|
-
'FeedProcessingStatusList.Status.1' => '2'
|
62
|
-
}
|
63
|
-
|
64
|
-
@client.stub(:run, nil) do
|
65
|
-
@client.get_feed_submission_count(
|
66
|
-
feed_type_list: '1',
|
67
|
-
feed_processing_status_list: '2'
|
68
|
-
)
|
69
|
-
end
|
70
|
-
|
71
|
-
assert_equal operation, @client.operation
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_canceling_feed_submissions
|
75
|
-
operation = {
|
76
|
-
'Action' => 'CancelFeedSubmissions',
|
77
|
-
'FeedTypeList.Type.1' => '1',
|
78
|
-
'FeedSubmissionIdList.Id.1' => '2'
|
79
|
-
}
|
80
|
-
|
81
|
-
@client.stub(:run, nil) do
|
82
|
-
@client.cancel_feed_submissions(
|
83
|
-
feed_type_list: '1',
|
84
|
-
feed_submission_id_list: '2'
|
85
|
-
)
|
86
|
-
end
|
87
|
-
|
88
|
-
assert_equal operation, @client.operation
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_getting_feed_submission_result
|
92
|
-
operation = {
|
93
|
-
'Action' => 'GetFeedSubmissionResult',
|
94
|
-
'FeedSubmissionId' => '1'
|
95
|
-
}
|
96
|
-
|
97
|
-
@client.stub(:run, nil) do
|
98
|
-
@client.get_feed_submission_result('1')
|
99
|
-
end
|
100
|
-
|
101
|
-
assert_equal operation, @client.operation
|
102
|
-
end
|
103
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
require 'mws/finances/client'
|
5
|
-
|
6
|
-
class TestMWSFinancesClient < MiniTest::Test
|
7
|
-
def setup
|
8
|
-
@client = MWS::Finances::Client.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_listing_financial_event_groups
|
12
|
-
operation = {
|
13
|
-
'Action' => 'ListFinancialEventGroups',
|
14
|
-
'FinancialEventGroupStartedAfter' => '2015-01-01'
|
15
|
-
}
|
16
|
-
|
17
|
-
@client.stub(:run, nil) do
|
18
|
-
@client.list_financial_event_groups('2015-01-01')
|
19
|
-
end
|
20
|
-
|
21
|
-
assert_equal operation, @client.operation
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_listing_financial_event_groups_by_next_token
|
25
|
-
operation = {
|
26
|
-
'Action' => 'ListFinancialEventGroupsByNextToken',
|
27
|
-
'NextToken' => '1'
|
28
|
-
}
|
29
|
-
|
30
|
-
@client.stub(:run, nil) do
|
31
|
-
@client.list_financial_event_groups_by_next_token('1')
|
32
|
-
end
|
33
|
-
|
34
|
-
assert_equal operation, @client.operation
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_listing_financial_events
|
38
|
-
operation = {
|
39
|
-
'Action' => 'ListFinancialEvents',
|
40
|
-
'AmazonOrderId' => '123'
|
41
|
-
}
|
42
|
-
|
43
|
-
@client.stub(:run, nil) do
|
44
|
-
@client.list_financial_events(amazon_order_id: '123')
|
45
|
-
end
|
46
|
-
|
47
|
-
assert_equal operation, @client.operation
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_listing_financial_events_by_next_token
|
51
|
-
operation = {
|
52
|
-
'Action' => 'ListFinancialEventsByNextToken',
|
53
|
-
'NextToken' => '1'
|
54
|
-
}
|
55
|
-
|
56
|
-
@client.stub(:run, nil) do
|
57
|
-
@client.list_financial_events_by_next_token('1')
|
58
|
-
end
|
59
|
-
|
60
|
-
assert_equal operation, @client.operation
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_getting_service_status
|
64
|
-
operation = {
|
65
|
-
'Action' => 'GetServiceStatus'
|
66
|
-
}
|
67
|
-
|
68
|
-
@client.stub(:run, nil) do
|
69
|
-
@client.get_service_status
|
70
|
-
end
|
71
|
-
|
72
|
-
assert_equal operation, @client.operation
|
73
|
-
end
|
74
|
-
end
|
@@ -1,426 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
require 'mws/fulfillment_inbound_shipment/client'
|
5
|
-
|
6
|
-
class TestMWSFulfillmentInboundShipmentClient < MiniTest::Test
|
7
|
-
def setup
|
8
|
-
@client = MWS::FulfillmentInboundShipment::Client.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_getting_inbound_guidance_for_sku
|
12
|
-
operation = {
|
13
|
-
'Action' => 'GetInboundGuidanceForSKU',
|
14
|
-
'MarketplaceId' => 'ATVPDKIKX0DER',
|
15
|
-
'SellerSKUList.Id.1' => 'us001'
|
16
|
-
}
|
17
|
-
|
18
|
-
@client.stub(:run, nil) do
|
19
|
-
@client.get_inbound_guidance_for_sku('ATVPDKIKX0DER', 'us001')
|
20
|
-
end
|
21
|
-
|
22
|
-
assert_equal operation, @client.operation
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_getting_inbound_guidance_for_asin
|
26
|
-
operation = {
|
27
|
-
'Action' => 'GetInboundGuidanceForASIN',
|
28
|
-
'MarketplaceId' => 'ATVPDKIKX0DER',
|
29
|
-
'ASINList.Id.1' => 'B00005N5PF'
|
30
|
-
}
|
31
|
-
|
32
|
-
@client.stub(:run, nil) do
|
33
|
-
@client.get_inbound_guidance_for_asin('ATVPDKIKX0DER', 'B00005N5PF')
|
34
|
-
end
|
35
|
-
|
36
|
-
assert_equal operation, @client.operation
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_creating_inbound_shipment_plan
|
40
|
-
operation = {
|
41
|
-
'Action' => 'CreateInboundShipmentPlan',
|
42
|
-
'LabelPrepPreference' => 'SELLER_LABEL',
|
43
|
-
'ShipFromAddress.Name' => 'test1',
|
44
|
-
'ShipFromAddress.City' => 'Seattle',
|
45
|
-
'ShipFromAddress.CountryCode' => 'US',
|
46
|
-
'InboundShipmentPlanRequestItems.member.1.SellerSKU' => 'SKU00001',
|
47
|
-
'InboundShipmentPlanRequestItems.member.1.Quantity' => '1',
|
48
|
-
'InboundShipmentPlanRequestItems.member.1.PrepDetailsList.member.1.PrepInstruction' => 'Taping',
|
49
|
-
'InboundShipmentPlanRequestItems.member.1.PrepDetailsList.member.1.PrepOwner' => 'AMAZON',
|
50
|
-
'InboundShipmentPlanRequestItems.member.1.PrepDetailsList.member.2.PrepInstruction' => 'BubbleWrapping',
|
51
|
-
'InboundShipmentPlanRequestItems.member.1.PrepDetailsList.member.2.PrepOwner' => 'AMAZON',
|
52
|
-
'InboundShipmentPlanRequestItems.member.2.SellerSKU' => 'SKU00002',
|
53
|
-
'InboundShipmentPlanRequestItems.member.2.Quantity' => '1',
|
54
|
-
'InboundShipmentPlanRequestItems.member.2.PrepDetailsList.member.1.PrepInstruction' => 'Taping',
|
55
|
-
'InboundShipmentPlanRequestItems.member.2.PrepDetailsList.member.1.PrepOwner' => 'AMAZON',
|
56
|
-
'InboundShipmentPlanRequestItems.member.2.PrepDetailsList.member.2.PrepInstruction' => 'BubbleWrapping',
|
57
|
-
'InboundShipmentPlanRequestItems.member.2.PrepDetailsList.member.2.PrepOwner' => 'AMAZON'
|
58
|
-
}
|
59
|
-
|
60
|
-
@client.stub(:run, nil) do
|
61
|
-
address = {
|
62
|
-
'Name' => 'test1',
|
63
|
-
'City' => 'Seattle',
|
64
|
-
'CountryCode' => 'US'
|
65
|
-
}
|
66
|
-
request_items = [
|
67
|
-
{
|
68
|
-
'SellerSKU' => 'SKU00001',
|
69
|
-
'Quantity' => '1',
|
70
|
-
'PrepDetailsList' => [
|
71
|
-
{ 'PrepInstruction' => 'Taping', 'PrepOwner' => 'AMAZON' },
|
72
|
-
{ 'PrepInstruction' => 'BubbleWrapping', 'PrepOwner' => 'AMAZON' }
|
73
|
-
]
|
74
|
-
}, {
|
75
|
-
'SellerSKU' => 'SKU00002',
|
76
|
-
'Quantity' => '1',
|
77
|
-
'PrepDetailsList' => [
|
78
|
-
{ 'PrepInstruction' => 'Taping', 'PrepOwner' => 'AMAZON' },
|
79
|
-
{ 'PrepInstruction' => 'BubbleWrapping', 'PrepOwner' => 'AMAZON' }
|
80
|
-
]
|
81
|
-
}
|
82
|
-
]
|
83
|
-
@client.create_inbound_shipment_plan(address, request_items,
|
84
|
-
label_prep_preference: 'SELLER_LABEL')
|
85
|
-
end
|
86
|
-
|
87
|
-
assert_equal operation, @client.operation
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_creating_inbound_shipment
|
91
|
-
operation = {
|
92
|
-
'Action' => 'CreateInboundShipment',
|
93
|
-
'ShipmentId' => '1',
|
94
|
-
'InboundShipmentHeader.Foo' => '1',
|
95
|
-
'InboundShipmentItems.member.1.Bar' => '2'
|
96
|
-
}
|
97
|
-
|
98
|
-
@client.stub(:run, nil) do
|
99
|
-
@client.create_inbound_shipment('1', { 'Foo' => '1' }, [{ 'Bar' => '2' }])
|
100
|
-
end
|
101
|
-
|
102
|
-
assert_equal operation, @client.operation
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_updating_inbound_shipment
|
106
|
-
operation = {
|
107
|
-
'Action' => 'UpdateInboundShipment',
|
108
|
-
'ShipmentId' => '1',
|
109
|
-
'InboundShipmentHeader.Foo' => '1',
|
110
|
-
'InboundShipmentItems.member.1.Bar' => '2'
|
111
|
-
}
|
112
|
-
|
113
|
-
@client.stub(:run, nil) do
|
114
|
-
@client.update_inbound_shipment('1', { 'Foo' => '1' }, [{ 'Bar' => '2' }])
|
115
|
-
end
|
116
|
-
|
117
|
-
assert_equal operation, @client.operation
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_getting_preorder_info
|
121
|
-
operation = {
|
122
|
-
'Action' => 'GetPreorderInfo',
|
123
|
-
'ShipmentId' => '1'
|
124
|
-
}
|
125
|
-
|
126
|
-
@client.stub(:run, nil) do
|
127
|
-
@client.get_preorder_info('1')
|
128
|
-
end
|
129
|
-
|
130
|
-
assert_equal operation, @client.operation
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_confirming_preorder
|
134
|
-
operation = {
|
135
|
-
'Action' => 'ConfirmPreorder',
|
136
|
-
'ShipmentId' => '1',
|
137
|
-
'NeedByDate' => '2015-12-27'
|
138
|
-
}
|
139
|
-
|
140
|
-
@client.stub(:run, nil) do
|
141
|
-
@client.confirm_preorder('1', Date.new(2015, 12, 27))
|
142
|
-
end
|
143
|
-
|
144
|
-
assert_equal operation, @client.operation
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_getting_prep_instructions_for_sku
|
148
|
-
operation = {
|
149
|
-
'Action' => 'GetPrepInstructionsForSKU',
|
150
|
-
'ShipToCountryCode' => 'US',
|
151
|
-
'SellerSKUList.Id.1' => 'ca_001'
|
152
|
-
}
|
153
|
-
|
154
|
-
@client.stub(:run, nil) do
|
155
|
-
@client.get_prep_instructions_for_sku('US', 'ca_001')
|
156
|
-
end
|
157
|
-
|
158
|
-
assert_equal operation, @client.operation
|
159
|
-
end
|
160
|
-
|
161
|
-
def test_getting_prep_instructions_for_asin
|
162
|
-
operation = {
|
163
|
-
'Action' => 'GetPrepInstructionsForASIN',
|
164
|
-
'ShipToCountryCode' => 'US',
|
165
|
-
'ASINList.Id.1' => 'B00005N5PF',
|
166
|
-
'ASINList.Id.2' => 'B0INVALIDF'
|
167
|
-
}
|
168
|
-
|
169
|
-
@client.stub(:run, nil) do
|
170
|
-
@client.get_prep_instructions_for_asin('US', 'B00005N5PF', 'B0INVALIDF')
|
171
|
-
end
|
172
|
-
|
173
|
-
assert_equal operation, @client.operation
|
174
|
-
end
|
175
|
-
|
176
|
-
def test_handling_bug_when_getting_prep_instructions_for_asin
|
177
|
-
first_run = true
|
178
|
-
callable = lambda {
|
179
|
-
if first_run
|
180
|
-
first_run = false
|
181
|
-
raise Peddler::Errors::Error, "Value null at 'asinList'"
|
182
|
-
end
|
183
|
-
}
|
184
|
-
@client.stub(:run, callable) do
|
185
|
-
@client.get_prep_instructions_for_asin('US', 'B00005N5PF')
|
186
|
-
end
|
187
|
-
|
188
|
-
refute @client.operation.key?('ASINList.Id.1')
|
189
|
-
assert @client.operation.key?('AsinList.Id.1')
|
190
|
-
end
|
191
|
-
|
192
|
-
def test_putting_transport_content_with_package_list
|
193
|
-
transport_details = {
|
194
|
-
parcel_data: {
|
195
|
-
package_list: [
|
196
|
-
{
|
197
|
-
tracking_id: '123'
|
198
|
-
}
|
199
|
-
]
|
200
|
-
}
|
201
|
-
}
|
202
|
-
|
203
|
-
operation = {
|
204
|
-
'Action' => 'PutTransportContent',
|
205
|
-
'ShipmentId' => '1',
|
206
|
-
'IsPartnered' => true,
|
207
|
-
'ShipmentType' => 'Foo',
|
208
|
-
'TransportDetails.ParcelData.PackageList.member.1.TrackingId' => '123'
|
209
|
-
}
|
210
|
-
|
211
|
-
@client.stub(:run, nil) do
|
212
|
-
@client.put_transport_content('1', true, 'Foo', transport_details)
|
213
|
-
end
|
214
|
-
|
215
|
-
assert_equal operation, @client.operation
|
216
|
-
end
|
217
|
-
|
218
|
-
def test_putting_transport_content_with_pallet_list
|
219
|
-
transport_details = {
|
220
|
-
parcel_data: {
|
221
|
-
pallet_list: [
|
222
|
-
{
|
223
|
-
tracking_id: '123'
|
224
|
-
}
|
225
|
-
]
|
226
|
-
}
|
227
|
-
}
|
228
|
-
|
229
|
-
operation = {
|
230
|
-
'Action' => 'PutTransportContent',
|
231
|
-
'ShipmentId' => '1',
|
232
|
-
'IsPartnered' => true,
|
233
|
-
'ShipmentType' => 'Foo',
|
234
|
-
'TransportDetails.ParcelData.PalletList.member.1.TrackingId' => '123'
|
235
|
-
}
|
236
|
-
|
237
|
-
@client.stub(:run, nil) do
|
238
|
-
@client.put_transport_content('1', true, 'Foo', transport_details)
|
239
|
-
end
|
240
|
-
|
241
|
-
assert_equal operation, @client.operation
|
242
|
-
end
|
243
|
-
|
244
|
-
def test_estimating_transport_request
|
245
|
-
operation = {
|
246
|
-
'Action' => 'EstimateTransportRequest',
|
247
|
-
'ShipmentId' => '1'
|
248
|
-
}
|
249
|
-
|
250
|
-
@client.stub(:run, nil) do
|
251
|
-
@client.estimate_transport_request('1')
|
252
|
-
end
|
253
|
-
|
254
|
-
assert_equal operation, @client.operation
|
255
|
-
end
|
256
|
-
|
257
|
-
def test_getting_transport_request
|
258
|
-
operation = {
|
259
|
-
'Action' => 'GetTransportContent',
|
260
|
-
'ShipmentId' => '1'
|
261
|
-
}
|
262
|
-
|
263
|
-
@client.stub(:run, nil) do
|
264
|
-
@client.get_transport_content('1')
|
265
|
-
end
|
266
|
-
|
267
|
-
assert_equal operation, @client.operation
|
268
|
-
end
|
269
|
-
|
270
|
-
def test_confirming_transport_request
|
271
|
-
operation = {
|
272
|
-
'Action' => 'ConfirmTransportRequest',
|
273
|
-
'ShipmentId' => '1'
|
274
|
-
}
|
275
|
-
|
276
|
-
@client.stub(:run, nil) do
|
277
|
-
@client.confirm_transport_request('1')
|
278
|
-
end
|
279
|
-
|
280
|
-
assert_equal operation, @client.operation
|
281
|
-
end
|
282
|
-
|
283
|
-
def test_voiding_transport_request
|
284
|
-
operation = {
|
285
|
-
'Action' => 'VoidTransportRequest',
|
286
|
-
'ShipmentId' => '1'
|
287
|
-
}
|
288
|
-
|
289
|
-
@client.stub(:run, nil) do
|
290
|
-
@client.void_transport_request('1')
|
291
|
-
end
|
292
|
-
|
293
|
-
assert_equal operation, @client.operation
|
294
|
-
end
|
295
|
-
|
296
|
-
def test_getting_package_labels
|
297
|
-
operation = {
|
298
|
-
'Action' => 'GetPackageLabels',
|
299
|
-
'ShipmentId' => '1',
|
300
|
-
'PageType' => '2'
|
301
|
-
}
|
302
|
-
|
303
|
-
@client.stub(:run, nil) do
|
304
|
-
@client.get_package_labels('1', '2')
|
305
|
-
end
|
306
|
-
|
307
|
-
assert_equal operation, @client.operation
|
308
|
-
end
|
309
|
-
|
310
|
-
def test_getting_unique_package_labels
|
311
|
-
operation = {
|
312
|
-
'Action' => 'GetUniquePackageLabels',
|
313
|
-
'ShipmentId' => 'FBAQFGQZ',
|
314
|
-
'PageType' => 'PackageLabel_Letter_6',
|
315
|
-
'PackageLabelsToPrint.member.1' => 'CartonA',
|
316
|
-
'PackageLabelsToPrint.member.2' => 'CartonB',
|
317
|
-
'PackageLabelsToPrint.member.3' => 'CartonC',
|
318
|
-
'PackageLabelsToPrint.member.4' => 'CartonD'
|
319
|
-
}
|
320
|
-
|
321
|
-
@client.stub(:run, nil) do
|
322
|
-
@client.get_unique_package_labels(
|
323
|
-
'FBAQFGQZ',
|
324
|
-
'PackageLabel_Letter_6',
|
325
|
-
%w[CartonA CartonB CartonC CartonD]
|
326
|
-
)
|
327
|
-
end
|
328
|
-
|
329
|
-
assert_equal operation, @client.operation
|
330
|
-
end
|
331
|
-
|
332
|
-
def test_getting_pallet_labels
|
333
|
-
operation = {
|
334
|
-
'Action' => 'GetPalletLabels',
|
335
|
-
'ShipmentId' => 'FBAQFGQZ',
|
336
|
-
'PageType' => 'PackageLabel_Letter_4',
|
337
|
-
'NumberOfPallets' => 4
|
338
|
-
}
|
339
|
-
|
340
|
-
@client.stub(:run, nil) do
|
341
|
-
@client.get_pallet_labels('FBAQFGQZ', 'PackageLabel_Letter_4', 4)
|
342
|
-
end
|
343
|
-
|
344
|
-
assert_equal operation, @client.operation
|
345
|
-
end
|
346
|
-
|
347
|
-
def test_getting_bill_of_lading
|
348
|
-
operation = {
|
349
|
-
'Action' => 'GetBillOfLading',
|
350
|
-
'ShipmentId' => '1'
|
351
|
-
}
|
352
|
-
|
353
|
-
@client.stub(:run, nil) do
|
354
|
-
@client.get_bill_of_lading('1')
|
355
|
-
end
|
356
|
-
|
357
|
-
assert_equal operation, @client.operation
|
358
|
-
end
|
359
|
-
|
360
|
-
def test_listing_inbound_shipments
|
361
|
-
operation = {
|
362
|
-
'Action' => 'ListInboundShipments',
|
363
|
-
'ShipmentStatusList.member.1' => 'Foo',
|
364
|
-
'ShipmentIdList.member.1' => 'Bar'
|
365
|
-
}
|
366
|
-
|
367
|
-
@client.stub(:run, nil) do
|
368
|
-
@client.list_inbound_shipments(
|
369
|
-
shipment_status_list: ['Foo'],
|
370
|
-
shipment_id_list: ['Bar']
|
371
|
-
)
|
372
|
-
end
|
373
|
-
|
374
|
-
assert_equal operation, @client.operation
|
375
|
-
end
|
376
|
-
|
377
|
-
def test_listing_inbound_shipments_by_next_token
|
378
|
-
operation = {
|
379
|
-
'Action' => 'ListInboundShipmentsByNextToken',
|
380
|
-
'NextToken' => '1'
|
381
|
-
}
|
382
|
-
|
383
|
-
@client.stub(:run, nil) do
|
384
|
-
@client.list_inbound_shipments_by_next_token('1')
|
385
|
-
end
|
386
|
-
|
387
|
-
assert_equal operation, @client.operation
|
388
|
-
end
|
389
|
-
|
390
|
-
def test_listing_inbound_shipment_items
|
391
|
-
operation = {
|
392
|
-
'Action' => 'ListInboundShipmentItems'
|
393
|
-
}
|
394
|
-
|
395
|
-
@client.stub(:run, nil) do
|
396
|
-
@client.list_inbound_shipment_items
|
397
|
-
end
|
398
|
-
|
399
|
-
assert_equal operation, @client.operation
|
400
|
-
end
|
401
|
-
|
402
|
-
def test_listing_inbound_shipment_items_by_next_token
|
403
|
-
operation = {
|
404
|
-
'Action' => 'ListInboundShipmentItemsByNextToken',
|
405
|
-
'NextToken' => '1'
|
406
|
-
}
|
407
|
-
|
408
|
-
@client.stub(:run, nil) do
|
409
|
-
@client.list_inbound_shipment_items_by_next_token('1')
|
410
|
-
end
|
411
|
-
|
412
|
-
assert_equal operation, @client.operation
|
413
|
-
end
|
414
|
-
|
415
|
-
def test_getting_service_status
|
416
|
-
operation = {
|
417
|
-
'Action' => 'GetServiceStatus'
|
418
|
-
}
|
419
|
-
|
420
|
-
@client.stub(:run, nil) do
|
421
|
-
@client.get_service_status
|
422
|
-
end
|
423
|
-
|
424
|
-
assert_equal operation, @client.operation
|
425
|
-
end
|
426
|
-
end
|