aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@230.to>2013-05-20 00:16:45 +0300
committerFilipp Lepalaan <f@230.to>2013-05-20 00:16:45 +0300
commitafd1136818b9a99b187c2c7adc5c369172eda22e (patch)
tree7853cb7a9023164add560f981e1091e69cce8e5a
parent5e13bcd86093ccd50ef8e4bf79046eca4e0ab9ac (diff)
downloadpy-gsxws-afd1136818b9a99b187c2c7adc5c369172eda22e.tar.gz
py-gsxws-afd1136818b9a99b187c2c7adc5c369172eda22e.tar.bz2
py-gsxws-afd1136818b9a99b187c2c7adc5c369172eda22e.zip
Update get_label
-rw-r--r--gsxws/core.py3
-rw-r--r--gsxws/returns.py39
2 files changed, 10 insertions, 32 deletions
diff --git a/gsxws/core.py b/gsxws/core.py
index 1fecb4c..63b9f81 100644
--- a/gsxws/core.py
+++ b/gsxws/core.py
@@ -384,6 +384,9 @@ class GsxObject(object):
if k in ['packingList', 'proformaFileData', 'returnLabelFileData']:
v = base64.b64decode(v)
+ of = tempfile.NamedTemporaryFile(suffix=".pdf", delete=False)
+ of.write(v)
+ v = of.name
if isinstance(v, basestring):
diff --git a/gsxws/returns.py b/gsxws/returns.py
index 65d1dae..9043ecd 100644
--- a/gsxws/returns.py
+++ b/gsxws/returns.py
@@ -42,11 +42,14 @@ CARRIERS = (
class Return(GsxObject):
+
+ _namespace = "asp:"
+
def __init__(self, order_number=None, *args, **kwargs):
super(Return, self).__init__(*args, **kwargs)
if order_number is not None:
- self.data['returnOrderNumber'] = order_number
+ self.returnOrderNumber = order_number
def get_pending(self):
"""
@@ -77,38 +80,10 @@ class Return(GsxObject):
so we're parsing the raw SOAP response and creating a "fake" return object from that.
"""
if not validate(part_number, 'partNumber'):
- raise ValueError('%s is not a valid part number' % part_number)
-
- class ReturnData(dict):
- pass
-
- rd = ReturnData()
-
- CLIENT.set_options(retxml=True)
-
- dt = CLIENT.factory.create('ns1:returnLabelRequestType')
- dt.returnOrderNumber = self.data['returnOrderNumber']
- dt.partNumber = part_number
- dt.userSession = SESSION
-
- try:
- result = CLIENT.service.ReturnLabel(dt)
- except suds.WebFault, e:
- raise GsxError(fault=e)
-
- el = ET.fromstring(result).findall('*//%s' % 'returnLabelData')[0]
-
- for r in el.iter():
- k, v = r.tag, r.text
- if k in ['packingList', 'proformaFileData', 'returnLabelFileData']:
- v = base64.b64decode(v)
- of = tempfile.NamedTemporaryFile(suffix=".pdf", delete=False)
- of.write(v)
- v = of.name
-
- setattr(rd, k, v)
+ raise ValueError("%s is not a valid part number" % part_number)
- return rd
+ self._submit("ReturnLabelRequest", "ReturnLabel", "returnLabelData")
+ return self._req.objects[0]
def get_proforma(self):
"""