diff options
author | Filipp Lepalaan <f@230.to> | 2013-05-20 00:16:45 +0300 |
---|---|---|
committer | Filipp Lepalaan <f@230.to> | 2013-05-20 00:16:45 +0300 |
commit | afd1136818b9a99b187c2c7adc5c369172eda22e (patch) | |
tree | 7853cb7a9023164add560f981e1091e69cce8e5a /gsxws/returns.py | |
parent | 5e13bcd86093ccd50ef8e4bf79046eca4e0ab9ac (diff) | |
download | py-gsxws-afd1136818b9a99b187c2c7adc5c369172eda22e.tar.gz py-gsxws-afd1136818b9a99b187c2c7adc5c369172eda22e.tar.bz2 py-gsxws-afd1136818b9a99b187c2c7adc5c369172eda22e.zip |
Update get_label
Diffstat (limited to 'gsxws/returns.py')
-rw-r--r-- | gsxws/returns.py | 39 |
1 files changed, 7 insertions, 32 deletions
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): """ |