Skip to content
This repository was archived by the owner on May 8, 2018. It is now read-only.

Commit 66d72cd

Browse files
committed
quick fixes
1 parent d45a681 commit 66d72cd

File tree

3 files changed

+45
-39
lines changed

3 files changed

+45
-39
lines changed

mws/__init__.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
from mws import Feeds
3-
from mws import InboundShipments
4-
from mws import Inventory
5-
from mws import Products
6-
from mws import Orders
7-
from mws import OutboundShipments
8-
from mws import Sellers
9-
from mws import Recommendations
10-
from mws import Reports
2+
__version__ = '0.3'
3+
4+
from mws import *

mws/mws.py

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,34 @@
2121
from requests.exceptions import HTTPError
2222

2323

24+
__all__ = [
25+
'AmazonTextResponse',
26+
'AmazonXMLResponse',
27+
'Feeds',
28+
'Inventory',
29+
'Reports',
30+
'Orders',
31+
'Products',
32+
'Recommendations',
33+
'Sellers',
34+
]
35+
36+
# See https://images-na.ssl-images-amazon.com/images/G/01/mwsportal/doc/en_US/bde/MWSDeveloperGuide._V357736853_.pdf page 8
37+
# for a list of the end points and marketplace IDs
38+
39+
MARKETPLACES = {
40+
"CA" : "https://mws.amazonservices.ca", #A2EUQ1WTGCTBG2
41+
"US" : "https://mws.amazonservices.com", #ATVPDKIKX0DER",
42+
"DE" : "https://mws-eu.amazonservices.com", #A1PA6795UKMFR9
43+
"ES" : "https://mws-eu.amazonservices.com", #A1RKKUPIHCS9HS
44+
"FR" : "https://mws-eu.amazonservices.com", #A13V1IB3VIYZZH
45+
"IN" : "https://mws.amazonservices.in", #A21TJRUUN4KGV
46+
"IT" : "https://mws-eu.amazonservices.com", #APJ6JRA9NG5V4
47+
"UK" : "https://mws-eu.amazonservices.com", #A1F83G8C2ARO7P
48+
"JP" : "https://mws.amazonservices.jp", #A1VC38T7YXB528
49+
"CN" : "https://mws.amazonservices.com.cn", #AAHKV2X7AFYLW
50+
}
51+
2452

2553
class MWSError(Exception):
2654
"""
@@ -114,40 +142,23 @@ class MWS(object):
114142
# Which is the name of the parameter for that specific account type.
115143
ACCOUNT_TYPE = "SellerId"
116144

117-
def __init__(self, access_key, secret_key, account_id, region = 'US',
118-
domain='', uri="", version=""):
145+
def __init__(self, access_key, secret_key, account_id, region='US', domain='', uri="", version=""):
119146
self.access_key = access_key
120147
self.secret_key = secret_key
121148
self.account_id = account_id
122149
self.version = version or self.VERSION
123-
self.region = region
124-
# Get the domain for the default of passed region, or use the passed domain
125-
self.domain = domain or self.get_region_endpoint()
126150
self.uri = uri or self.URI
127-
128-
def get_region_endpoint(self):
129-
# See https://images-na.ssl-images-amazon.com/images/G/01/mwsportal/doc/en_US/bde/MWSDeveloperGuide._V357736853_.pdf page 8
130-
# for a list of the end points and marketplace IDs
131-
try:
132-
marketplaces = {
133-
"CA" : "https://mws.amazonservices.ca", #A2EUQ1WTGCTBG2
134-
"US" : "https://mws.amazonservices.com", #ATVPDKIKX0DER",
135-
"DE" : "https://mws-eu.amazonservices.com", #A1PA6795UKMFR9
136-
"ES" : "https://mws-eu.amazonservices.com", #A1RKKUPIHCS9HS
137-
"FR" : "https://mws-eu.amazonservices.com", #A13V1IB3VIYZZH
138-
"IN" : "https://mws.amazonservices.in", #A21TJRUUN4KGV
139-
"IT" : "https://mws-eu.amazonservices.com", #APJ6JRA9NG5V4
140-
"UK" : "https://mws-eu.amazonservices.com", #A1F83G8C2ARO7P
141-
"JP" : "https://mws.amazonservices.jp", #A1VC38T7YXB528
142-
"CN" : "https://mws.amazonservices.com.cn", #AAHKV2X7AFYLW
151+
152+
if domain:
153+
self.domain = domain
154+
elif region in MARKETPLACES:
155+
self.domain = MARKETPLACES[region]
156+
else:
157+
error_msg = "Incorrect region supplied ('%(region)s'). Must be one of the following: %(marketplaces)s" % {
158+
"marketplaces" : ', '.join(MARKETPLACES.keys()),
159+
"region" : region,
143160
}
144-
return marketplaces[self.region.upper()]
145-
# Didn't pass a valid marketplace location.
146-
except KeyError:
147-
raise MWSError("Incorrect region supplied ('%(region)s'). Must be one of the following: %(marketplaces)s" % {
148-
"marketplaces" : marketplaces.keys(),
149-
"region" : self.region,
150-
})
161+
raise MWSError(error_msg)
151162

152163
def make_request(self, extra_data, method="GET", **kwargs):
153164
"""Make request to Amazon MWS API with these parameters

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/env python
2-
32
from setuptools import setup
43

4+
from mws import __version__
5+
56
setup(
67
name="python-amazon-mws",
7-
version="0.3",
8+
version=__version__,
89
description="A python interface for Amazon MWS",
910
author="Paulo Alvarado",
1011
author_email="commonzenpython@gmail.com",

0 commit comments

Comments
 (0)