8000 Redesign of make_request and the returned response object. And use of xmltodict. by elcolumbio · Pull Request #75 · python-amazon-mws/python-amazon-mws · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jan 4, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
aad50d7
use xmltodict
May 27, 2018
43c6fec
Merge branch 'master' into develop
May 27, 2018
09ffff4
use xmltodict
elcolumbio May 27, 2018
fed8d48
remove dict2xml by DotDict
elcolumbio May 27, 2018
9873263
Merge remote-tracking branch 'origin/develop' into develop
May 27, 2018
14efe58
cleaned up some stuff from my commit #65
May 28, 2018
19a7aa8
removed docs by self documenting code
May 28, 2018
a57ddf6
removed the illusion that we care too much about namespaces
May 28, 2018
ab4c87c
add dependency xmltodict
May 28, 2018
af161cc
raw design of datawrapper withot dictwrapper
May 28, 2018
358d530
bug fixes
May 28, 2018
847bd58
moved validate hash, bug fixes
May 28, 2018
5ac6b7e
parsed and header work for xml files
May 28, 2018
3038d64
use a dotdict inspired from FrozenJson
May 29, 2018
0790415
a DotDict(obj).get(key, default) now returns a DotDict object
May 29, 2018
5622c36
fixed encoding issue #76 , fixed hash function
May 29, 2018
e48d5d7
conformity for accessing response attributes
May 29, 2018
c2b6f99
test the hash function
May 29, 2018
e6656c0
python 2.7 support for collection import
May 29, 2018
05fd2d8
fix previous
May 29, 2018
6a65756
Testing the hash function and a fake request.response
May 29, 2018
4ea6469
tests for the new datawrapper
May 29, 2018
3c2dbd2
python 2
May 29, 2018
d17da86
python2
May 29, 2018
c0de832
python2
May 29, 2018
3e4f340
pythot2 encoding bug
May 29, 2018
1290880
test runs with python2. need some real responses now
May 29, 2018
78e8543
rip atom
May 29, 2018
fa4461b
f
May 29, 2018
95e7be8
removed monkeypatch since overthetop
May 30, 2018
e41926d
revert #72 #68
May 30, 2018
f4c1fa4
fix typos last
May 30, 2018
a9c093b
pprint only for __str__ . Datawrapper parameter force_cdata for backport
Jun 1, 2018
a7ab41b
changed _response_dict to dot_dict
Jun 1, 2018
0462e2e
Code style nitpicks
GriceTurrble Jun 1, 2018
cc2e5ed
Code style nitpicks
GriceTurrble Jun 1, 2018
a678180
fix for #72 and #78 by introducing ignore flag for xml reports
Jun 2, 2018
16d38cb
very naive but 100x faster implementation of chardet.detect
Jun 2, 2018
04a8b95
default to utf8
Jun 2, 2018
7ec8ad2
guess encoding improvements
Jun 2, 2018
7d65c87
docs and adjustment of tests
Jun 5, 2018
52c85e2
Merge remote-tracking branch 'python-amazon-mws/develop' into develop
Jun 10, 2018
62584e8
include subpackage apis in setup
Jun 18, 2018
8c3b98a
typos
Jun 23, 2018
a7ef372
typos
Jun 23, 2018
d37de8c
Merge branch 'develop' into develop
GriceTurrble Aug 2, 2018
cb4e9cd
guess encoding rewritten
Dec 18, 2018
3816db1
typos, unused import counter, docs
Dec 18, 2018
7e387b0
better comments
Dec 18, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
mws/apis/recommendations.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Recommendations(MWS):
"""
URI = '/Recommendations/2013-04-01'
VERSION = '2013-04-01'
NAMESPACE = "{https://mws.amazonservices.com/Recommendations/2013-04-01}"
NEXT_TOKEN_OPERATIONS = [
"ListRecommendations",
]
Expand Down
2 changes: 1 addition & 1 deletion mws/apis/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def get_report(self, report_id):
'Action': 'GetReport',
'ReportId': report_id,
}
return self.make_request(data)
return self.make_request(data, rootkey='ignore')

# # TODO Add:
# def manage_report_schedule(self):
Expand Down
1 change: 0 additions & 1 deletion mws/apis/sellers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Sellers(MWS):
"""
URI = '/Sellers/2011-07-01'
VERSION = '2011-07-01'
NAMESPACE = '{http://mws.amazonservices.com/schema/Sellers/2011-07-01}'
NEXT_TOKEN_OPERATIONS = [
'ListMarketplaceParticipations',
]
Expand Down
119 changes: 63 additions & 56 deletions mws/apis/subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from ..mws import MWS
from .. import utils
# from .. import utils

# TODO include NotificationType enumeration
# TODO set up a basic object for Subscription and Destination types?
Expand All @@ -20,7 +19,6 @@ class Subscriptions(MWS):
"""
URI = "/Subscriptions/2013-07-01"
VERSION = "2013-07-01"
NAMESPACE = "{http://mws.amazonaws.com/Subscriptions/2013-07-01}"

# TODO include a helper method for configuring and saving a destination to the object with a keyname
# This might cut down on some time setting up all the values for the destination for each call,
Expand All @@ -47,7 +45,6 @@ def register_destination(self, marketplace_id, attributes=None, delivery_channel

delivery_channel: Currently only supports SQS
attributes: example {"sqsQueueUrl": "https://sqs.eu-west-2.amazonaws.com/378051892504/Amazon_MWS_Notify"}

"""
if attributes is None:
raise ValueError("attributes cannot be None")
Expand All @@ -57,8 +54,10 @@ def register_destination(self, marketplace_id, attributes=None, delivery_channel
"MarketplaceId": marketplace_id,
"Destination.DeliveryChannel": delivery_channel
}
data.update(utils.enumerate_keyed_param("Destination.AttributeList.member", self._parse_attributes(attributes)))

data.update(utils.enumerate_keyed_param(
"Destination.AttributeList.member",
self._parse_attributes(attributes),
))
return self.make_request(data, "POST")

def deregister_destination(self, marketplace_id, attributes=None, delivery_channel="SQS"):
Expand All @@ -70,7 +69,6 @@ def deregister_destination(self, marketplace_id, attributes=None, delivery_chann

delivery_channel: Currently only supports SQS
attributes: example {"sqsQueueUrl": "https://sqs.eu-west-2.amazonaws.com/378051892504/Amazon_MWS_Notify"}

"""
if attributes is None:
raise ValueError("attributes cannot be None")
Expand All @@ -80,8 +78,10 @@ def deregister_destination(self, marketplace_id, attributes=None, delivery_chann
"MarketplaceId": marketplace_id,
"Destination.DeliveryChannel": delivery_channel
}
data.update(utils.enumerate_keyed_param("Destination.AttributeList.member", self._parse_attributes(attributes)))

data.update(utils.enumerate_keyed_param(
"Destination.AttributeList.member",
self._parse_attributes(attributes),
))
return self.make_request(data, "POST")

def list_registered_destinations(self, marketplace_id):
Expand All @@ -91,9 +91,10 @@ def list_registered_destinations(self, marketplace_id):
Docs:
http://docs.developer.amazonservices.com/en_US/subscriptions/Subscriptions_ListRegisteredDestinations.html
"""
data = {"Action": "ListRegisteredDestinations",
"MarketplaceId": marketplace_id}

data = {
"Action": "ListRegisteredDestinations",
"MarketplaceId": marketplace_id,
}
return self.make_request(data, "POST")

def send_test_notification_to_destination(self, marketplace_id, attributes=None, delivery_channel="SQS"):
Expand All @@ -105,16 +106,19 @@ def send_test_notification_to_destination(self, marketplace_id, attributes=None,

delivery_channel: Currently only supports SQS
attributes: example {"sqsQueueUrl": "https://sqs.eu-west-2.amazonaws.com/378051892504/Amazon_MWS_Notify"}

"""
if attributes is None:
raise ValueError("attributes cannot be None")

data = {"Action": "SendTestNotificationToDestination",
"MarketplaceId": marketplace_id,
"Destination.DeliveryChannel": delivery_channel}
data.update(utils.enumerate_keyed_param("Destination.AttributeList.member", self._parse_attributes(attributes)))

data = {
"Action": "SendTestNotificationToDestination",
"MarketplaceId": marketplace_id,
"Destination.DeliveryChannel": delivery_channel,
}
data.update(utils.enumerate_keyed_param(
"Destination.AttributeList.member",
self._parse_attributes(attributes),
))
return self.make_request(data, method="POST")

def create_subscription(self, marketplace_id, attributes=None,
Expand All @@ -127,23 +131,23 @@ def create_subscription(self, marketplace_id, attributes=None,

delivery_channel: Currently only supports SQS
attributes: example {"sqsQueueUrl": "https://sqs.eu-west-2.amazonaws.com/378051892504/Amazon_MWS_Notify"}

"""

if attributes is None:
raise ValueError("attributes cannot be None")

if notification_type is None:
raise ValueError("notification_type cannot be None")
data = {"Action": "CreateSubscription",
"MarketplaceId": marketplace_id,
"Subscription.Destination.DeliveryChannel": delivery_channel,
"Subscription.IsEnabled": str(is_enabled).lower(),
"Subscription.NotificationType": notification_type}

data.update(utils.enumerate_keyed_param("Subscription.Destination.AttributeList.member",
self._parse_attributes(attributes)))

data = {
"Action": "CreateSubscription",
"MarketplaceId": marketplace_id,
"Subscription.Destination.DeliveryChannel": delivery_channel,
"Subscription.IsEnabled": str(is_enabled).lower(),
"Subscription.NotificationType": notification_type,
}
data.update(utils.enumerate_keyed_param(
"Subscription.Destination.AttributeList.member",
self._parse_attributes(attributes),
))
return self.make_request(data, "POST")

def get_subscription(self, marketplace_id, attributes=None, notification_type=None, delivery_channel="SQS"):
Expand All @@ -155,25 +159,25 @@ def get_subscription(self, marketplace_id, attributes=None, notification_type=No

delivery_channel: Currently only supports SQS
attributes: example {"sqsQueueUrl": "https://sqs.eu-west-2.amazonaws.com/378051892504/Amazon_MWS_Notify"}

"""

if attributes is None:
raise ValueError("attributes cannot be None")

if notification_type is None:
raise ValueError("notification_type cannot be None")
data = {"Action": "GetSubscription",
"MarketplaceId": marketplace_id,
"Destination.DeliveryChannel": delivery_channel,
"NotificationType": notification_type}
data.update(utils.enumerate_keyed_param("Destination.AttributeList.member",
self._parse_attributes(attributes)))

data = {
"Action": "GetSubscription",
"MarketplaceId": marketplace_id,
"Destination.DeliveryChannel": delivery_channel,
"NotificationType": notification_type,
}
data.update(utils.enumerate_keyed_param(
"Destination.AttributeList.member",
self._parse_attributes(attributes),
))
return self.make_request(data, "POST")

def delete_subscription(self, marketplace_id, attributes=None, notification_type=None, delivery_channel="SQS"):

"""
Deletes the subscription for the specified notification type and destination.

Expand All @@ -182,21 +186,22 @@ def delete_subscription(self, marketplace_id, attributes=None, notification_type

delivery_channel: Currently only supports SQS
attributes: example {"sqsQueueUrl": "https://sqs.eu-west-2.amazonaws.com/378051892504/Amazon_MWS_Notify"}

"""

if attributes is None:
raise ValueError("attributes cannot be None")

if notification_type is None:
raise ValueError("notification_type cannot be None")
data = {"Action": "DeleteSubscription",
"MarketplaceId": marketplace_id,
"Destination.DeliveryChannel": delivery_channel,
"NotificationType": notification_type}

data.update(utils.enumerate_keyed_param("Destination.AttributeList.member", self._parse_attributes(attributes)))

data = {
"Action": "DeleteSubscription",
"MarketplaceId": marketplace_id,
"Destination.DeliveryChannel": delivery_channel,
"NotificationType": notification_type,
}
data.update(utils.enumerate_keyed_param(
"Destination.AttributeList.member",
self._parse_attributes(attributes),
))
return self.make_request(data, "POST")

def list_subscriptions(self, marketplace_id):
Expand All @@ -210,7 +215,6 @@ def list_subscriptions(self, marketplace_id):
"Action": "ListSubscriptions",
"MarketplaceId": marketplace_id,
}

return self.make_request(data, "POST")

def update_subscription(self, marketplace_id, attributes=None,
Expand All @@ -230,12 +234,15 @@ def update_subscription(self, marketplace_id, attributes=None,

if notification_type is None:
raise ValueError("notification_type cannot be None")
data = {"Action": "UpdateSubscription",
"MarketplaceId": marketplace_id,
"Subscription.Destination.DeliveryChannel": delivery_channel,
"Subscription.IsEnabled": str(is_enabled).lower(),
"Subscription.NotificationType": notification_type}

data.update(utils.enumerate_keyed_param("Subscription.Destination.AttributeList.member",
self._parse_attributes(attributes)))
data = {
"Action": "UpdateSubscription",
"MarketplaceId": marketplace_id,
"Subscription.Destination.DeliveryChannel": delivery_channe 56BA l,
"Subscription.IsEnabled": str(is_enabled).lower(),
"Subscription.NotificationType": notification_type,
}
data.update(utils.enumerate_keyed_param(
"Subscription.Destination.AttributeList.member",
self._parse_attributes(attributes),
))
return self.make_request(data, "POST")
Loading
0