From 8bc02bb1baf9adf7b856a9bdabb5251c1a77e311 Mon Sep 17 00:00:00 2001 From: Paul Voelker Date: Fri, 20 Sep 2019 12:18:59 +0200 Subject: [PATCH 1/4] fix Orders acknowledge and cancel --- walmart/walmart.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/walmart/walmart.py b/walmart/walmart.py index 28f2167..fc257fc 100644 --- a/walmart/walmart.py +++ b/walmart/walmart.py @@ -358,11 +358,11 @@ def all(self, **kwargs): def acknowledge(self, id): url = self.url + '/%s/acknowledge' % id - return self.send_request(method='POST', url=url) + return self.connection.send_request(method='POST', url=url) def cancel(self, id, lines): url = self.url + '/%s/cancel' % id - return self.send_request( + return self.connection.send_request( method='POST', url=url, data=self.get_cancel_payload(lines)) def get_cancel_payload(self, lines): From 0fb81a3d107fcc4df17fe619b02e5937f6196ee9 Mon Sep 17 00:00:00 2001 From: Paul Voelker Date: Fri, 20 Sep 2019 13:06:44 +0200 Subject: [PATCH 2/4] fix INVALID_TOKEN.GMP_GATEWAY_API handling --- walmart/walmart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/walmart/walmart.py b/walmart/walmart.py index fc257fc..5c89266 100644 --- a/walmart/walmart.py +++ b/walmart/walmart.py @@ -121,7 +121,7 @@ def send_request( )) elif response.status_code == 400: data = response.json() - if data["error"][0]["code"] == \ + if data["errors"]["error"][0]["code"] == \ "INVALID_TOKEN.GMP_GATEWAY_API": # Refresh the token as the current token has expired self.authenticate() From df976bdc108d6d53c825a5add1f66c6f618df634 Mon Sep 17 00:00:00 2001 From: Paul Voelker Date: Fri, 20 Sep 2019 15:40:14 +0200 Subject: [PATCH 3/4] fix invalid token handling --- walmart/walmart.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/walmart/walmart.py b/walmart/walmart.py index 5c89266..8911a41 100644 --- a/walmart/walmart.py +++ b/walmart/walmart.py @@ -114,14 +114,8 @@ def send_request( response.raise_for_status() except requests.exceptions.HTTPError: if response.status_code == 401: - raise WalmartAuthenticationError(( - "Invalid client_id or client_secret. Please verify " - "your credentials from https://developer.walmart." - "com/#/generateKey" - )) - elif response.status_code == 400: data = response.json() - if data["errors"]["error"][0]["code"] == \ + if data["error"][0]["code"] == \ "INVALID_TOKEN.GMP_GATEWAY_API": # Refresh the token as the current token has expired self.authenticate() From 349301e0b3fd64a154a76fefb48447c4a65fe55d Mon Sep 17 00:00:00 2001 From: Paul Voelker Date: Fri, 20 Sep 2019 16:02:18 +0200 Subject: [PATCH 4/4] remove unused WalmartAuthenticationError import --- walmart/walmart.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/walmart/walmart.py b/walmart/walmart.py index 8911a41..82cec26 100644 --- a/walmart/walmart.py +++ b/walmart/walmart.py @@ -10,8 +10,6 @@ from lxml import etree from lxml.builder import E, ElementMaker -from .exceptions import WalmartAuthenticationError - def epoch_milliseconds(dt): "Walmart accepts timestamps as epoch time in milliseconds"