aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@230.to>2013-05-07 11:00:53 +0300
committerFilipp Lepalaan <f@230.to>2013-05-07 11:00:53 +0300
commit2680b7d1925b4317715dcc89b2af4aec1646d8cb (patch)
treee7cc365ace8673497579900f2d54db8e80038ee1
parent3a8df5289690a37e1edbc0387833610fa9f6dfcb (diff)
downloadpy-gsxws-2680b7d1925b4317715dcc89b2af4aec1646d8cb.tar.gz
py-gsxws-2680b7d1925b4317715dcc89b2af4aec1646d8cb.tar.bz2
py-gsxws-2680b7d1925b4317715dcc89b2af4aec1646d8cb.zip
Some invoice-related fixes
-rwxr-xr-xgsxws.py24
-rw-r--r--test_bulk_returns.py20
2 files changed, 15 insertions, 29 deletions
diff --git a/gsxws.py b/gsxws.py
index fb0e03e..9f77ea7 100755
--- a/gsxws.py
+++ b/gsxws.py
@@ -33,6 +33,7 @@ import suds
import base64
import urllib
import hashlib
+import logging
import tempfile
from suds.client import Client
@@ -177,7 +178,7 @@ class GsxObject(object):
Submits the SOAP envelope
"""
f = getattr(CLIENT.service, method)
-
+
try:
result = f(data)
return getattr(result, attr) if attr else result
@@ -206,12 +207,12 @@ class GsxObject(object):
if isinstance(v, basestring):
# convert dates to native Python types
- if re.search('^\d{2}/\d{2}/\d{2}$', v):
+ if re.search(r'^\d{2}/\d{2}/\d{2}$', v):
m, d, y = v.split('/')
v = date(2000+int(y), int(m), int(d))
# strip currency prefix and munge into float
- if re.search('Price$', k):
+ if re.search(r'Price$', k):
v = float(re.sub('[A-Z ,]', '', v))
setattr(data, k, v)
@@ -267,9 +268,9 @@ class Content(GsxObject):
class CompTIA(object):
- '''
+ """
Stores and accesses CompTIA codes.
- '''
+ """
MODIFIERS = (
("A", "Not Applicable"),
@@ -414,26 +415,28 @@ class GsxResponse(dict):
return nodedict
+
class GsxError(Exception):
def __init__(self, message=None, code=None, fault=None):
if isinstance(fault, suds.WebFault):
self.code = fault.fault.faultcode
- self.message=fault.fault.faultstring
+ self.message = fault.fault.faultstring
else:
self.code = code
self.message = message
-
+
self.data = (self.code, self.message)
def __getitem__(self, idx):
return self.data[idx]
-
+
def __repr__(self):
print self.data
def __str__(self):
return self.data[1]
+
class Lookup(GsxObject):
def lookup(self, dt, method):
dt = self._make_type(dt)
@@ -468,8 +471,11 @@ class Lookup(GsxObject):
"""
The Invoice ID Lookup API allows AASP users
to fetch the invoice generated for last 24 hrs
+
+ >>> Lookup(shipTo=677592, invoiceDate='02/06/12').invoices()
"""
- return self.lookup('ns1:invoiceIDLookupRequestType', 'InvoiceIDLookup')
+ result = self.lookup('ns1:invoiceIDLookupRequestType', 'InvoiceIDLookup')
+ return result.invoiceID # This is actually a list of Invoice ID's...
def invoice_details(self):
"""
diff --git a/test_bulk_returns.py b/test_bulk_returns.py
deleted file mode 100644
index 8e4a494..0000000
--- a/test_bulk_returns.py
+++ /dev/null
@@ -1,20 +0,0 @@
-import json
-import gsxws
-import logging
-
-logging.basicConfig(level=logging.INFO)
-logging.getLogger('suds.client').setLevel(logging.DEBUG)
-
-sold_to = ''
-gsxws.connect(user_id='', password='', sold_to=sold_to, environment='ut')
-
-rep = gsxws.Repair(dispatchId='')
-#rep.update_sn({'partNumber':'661-5465', 'serialNumber': 'VM020ZLD5RU', 'oldSerialNumber': 'W80320QAAGZ'})
-rep.mark_complete()
-df = open('/Users/filipp/Projects/py-gsxws/tests/parts_register_return.json')
-data = json.loads(df.read())
-data['shipToCode'] = sold_to
-
-print data
-ret = gsxws.Returns(**data)
-print ret.register_parts()