diff options
Diffstat (limited to 'gsxws')
-rw-r--r-- | gsxws/core.py | 1 | ||||
-rw-r--r-- | gsxws/products.py | 16 | ||||
-rw-r--r-- | gsxws/repairs.py | 9 | ||||
-rw-r--r-- | gsxws/xmltodict.py | 4 |
4 files changed, 18 insertions, 12 deletions
diff --git a/gsxws/core.py b/gsxws/core.py index c70cd36..4dd50e5 100644 --- a/gsxws/core.py +++ b/gsxws/core.py @@ -264,7 +264,6 @@ class GsxRequest(object): logging.debug("Response: %s %s %s" % (res.status, res.reason, xml)) response = response or self._response - logging.debug("Looking for %s" % response) root = ET.fromstring(xml).find("*//%s" % response) data = xmltodict.ConvertXmlToDict(root) self.objects = data[response] diff --git a/gsxws/products.py b/gsxws/products.py index d3c1860..96352f1 100644 --- a/gsxws/products.py +++ b/gsxws/products.py @@ -11,7 +11,7 @@ from core import GsxObject, GsxError def models(): """ >>> models() # doctest: +ELLIPSIS - {'iphone_acc': {'models': 'Bluetooth Headset',... + {'MAC_ACC': {'models': ['AirPort Card', ... """ import os import yaml @@ -48,28 +48,28 @@ class Product(GsxObject): >>> Product('DGKFL06JDHJP').warranty().warrantyStatus u'Out Of Warranty (No Coverage)' >>> Product('DGKFL06JDHJP').warranty().estimatedPurchaseDate - '2011-06-02' + datetime.date(2011, 6, 2) """ self._submit("unitDetail", "WarrantyStatus", "warrantyDetailInfo") - self.warrantyDetails = self._req.objects[0] + self.warrantyDetails = self._req.objects return self.warrantyDetails def parts(self): """ >>> Product('DGKFL06JDHJP').parts() # doctest: +ELLIPSIS - [<core.GsxObject object at ... + {'exchangePrice': '0', 'isSerialized': 'N', 'partType': 'Other',... >>> Product(productName='MacBook Pro (17-inch, Mid 2009)').parts() # doctest: +ELLIPSIS - [<core.GsxObject object at ... + {'exchangePrice': '0', 'isSerialized': 'N', 'partType': 'Other',... """ - if hasattr(self, "serialNumber"): + try: return Lookup(serialNumber=self.serialNumber).parts() - else: + except AttributeError: return Lookup(productName=self.productName).parts() def repairs(self): """ >>> Product(serialNumber='DGKFL06JDHJP').repairs() # doctest: +ELLIPSIS - <core.GsxObject object at ... + {'customerName': 'Lepalaan,Filipp',... """ return Lookup(serialNumber=self.serialNumber).repairs() diff --git a/gsxws/repairs.py b/gsxws/repairs.py index 3461092..ee649d8 100644 --- a/gsxws/repairs.py +++ b/gsxws/repairs.py @@ -74,6 +74,9 @@ class Repair(GsxObject): serial number entry (see KGB serial update). >>> Repair('G135762375').update_sn(ServicePart('661-4964', oldSerialNumber='W882300FK22YA')) + Traceback (most recent call last): + ... + GsxError: This repair cannot be updated. """ self.partInfo = parts if hasattr(self, "dispatchId"): @@ -113,7 +116,7 @@ class Repair(GsxObject): to retrieve more details of the repair. >>> Repair(repairStatus='Open').lookup() #doctest: +ELLIPSIS - [<core.GsxObject object at ... + {'customerName': 'Lepalaan,Filipp',... """ self._namespace = "core:" return Lookup(**self._data).repairs() @@ -146,7 +149,7 @@ class Repair(GsxObject): u'Closed and Completed' """ self.repairConfirmationNumbers = self.dispatchId - status = self._submit("RepairStatusRequest", "RepairStatus", "repairStatus")[0] + status = self._submit("RepairStatusRequest", "RepairStatus", "repairStatus") self.repairStatus = status.repairStatus self._status = status return status @@ -157,7 +160,7 @@ class Repair(GsxObject): similar to the Repair Lookup API. >>> Repair('G135773004').details() #doctest: +ELLIPSIS - <core.GsxObject object at ... + {'isACPlusConsumed': 'N', 'configuration': 'IPAD 3RD GEN,WIFI+CELLULAR,16GB,BLACK',... """ self._namespace = "core:" details = self._submit("RepairDetailsRequest", "RepairDetails", "lookupResponseData") diff --git a/gsxws/xmltodict.py b/gsxws/xmltodict.py index c577e55..b8973ae 100644 --- a/gsxws/xmltodict.py +++ b/gsxws/xmltodict.py @@ -33,6 +33,10 @@ class XmlDictObject(dict): if re.search(r'^[YN]$', v): v = (v == "Y") + # convert true/false to boolean + if re.search(r'^(true)|(false)$', v): + v = (v == "true") + # strip currency prefix and munge into float if re.search(r'Price$', item): v = float(re.sub(r'[A-Z ,]', '', v)) |