aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@230.to>2013-05-02 22:31:31 +0300
committerFilipp Lepalaan <f@230.to>2013-05-02 22:31:31 +0300
commitb854d9346a6aa72aa978928d03bc0f2b37be0fc9 (patch)
treee23cac43698e871fb9977d0c49c25d07390c21d0
parenta2ad9888148402b75d4f8a77da4c5fbca2f539cb (diff)
downloadpy-gsxws-b854d9346a6aa72aa978928d03bc0f2b37be0fc9.tar.gz
py-gsxws-b854d9346a6aa72aa978928d03bc0f2b37be0fc9.tar.bz2
py-gsxws-b854d9346a6aa72aa978928d03bc0f2b37be0fc9.zip
Refactoring in progress..
-rwxr-xr-xgsxws.py2
-rw-r--r--lookups.py7
-rw-r--r--products.py62
-rw-r--r--repairs.py31
4 files changed, 96 insertions, 6 deletions
diff --git a/gsxws.py b/gsxws.py
index 256d53b..03ec3ba 100755
--- a/gsxws.py
+++ b/gsxws.py
@@ -952,7 +952,7 @@ def connect(
sold_to,
language='en',
timezone='CEST',
- environment='ut',
+ environment='pr',
region='emea',
locale=LOCALE):
"""
diff --git a/lookups.py b/lookups.py
new file mode 100644
index 0000000..c13011e
--- /dev/null
+++ b/lookups.py
@@ -0,0 +1,7 @@
+from repairs import GsxObject
+
+class Lookup(GsxObject):
+ """docstring for Lookup"""
+ def __init__(self, arg):
+ super(Lookup, self).__init__()
+ self.arg = arg
diff --git a/products.py b/products.py
new file mode 100644
index 0000000..16fe1c0
--- /dev/null
+++ b/products.py
@@ -0,0 +1,62 @@
+import sys
+from gsxws import connect, GsxError
+from repairs import GsxObject
+from lookups import Lookup
+
+class GsxRequest(object):
+ def submit(self, method, data, attr=None):
+ """Submits the SOAP envelope
+ """
+ from gsxws import CLIENT, SESSION
+ f = getattr(CLIENT.service, method)
+
+ try:
+ result = f(data)
+ return getattr(result, attr) if attr else result
+ except suds.WebFault, e:
+ raise GsxError(fault=e)
+
+class Product(GsxObject, GsxRequest):
+ """Something serviceable that Apple makes
+ """
+ serialNumber = ""
+ alternateDeviceId = ""
+ configDescription = ""
+
+ def model(self):
+ """Returns the model description of this Product
+
+ >>> Product(serialNumber='DGKFL06JDHJP').model().configDescription
+ iMac (27-inch, Mid 2011)
+ """
+ dt = self._make_type("ns3:fetchProductModelRequestType")
+ dt.productModelRequest = self.data
+ result = self.submit('FetchProductModel', dt, "productModelResponse")[0]
+ self.configDescription = result.configDescription
+ self.productLine = result.productLine
+ self.configCode = result.configCode
+ return result
+
+ def warranty(self):
+ """The Warranty Status API retrieves the same warranty details
+ displayed on the GSX Coverage screen.
+ If part information is provided, the part warranty information is returned.
+ If you do not provide the optional part information in the
+ warranty status request, the unit level warranty information is returned.
+
+ >>> Product(serialNumber='DGKFL06JDHJP').warranty().warrantyStatus
+ Out Of Warranty (No Coverage)
+ """
+ dt = self._make_type("ns3:warrantyStatusRequestType")
+ dt.unitDetail = self.data
+ result = self.submit("WarrantyStatus", dt, "warrantyDetailInfo")
+ return result
+
+ @property
+ def parts(self):
+ pass
+
+if __name__ == '__main__':
+ import doctest
+ connect(*sys.argv[1:4])
+ doctest.testmod()
diff --git a/repairs.py b/repairs.py
index f829d3e..6e47292 100644
--- a/repairs.py
+++ b/repairs.py
@@ -2,14 +2,27 @@
gsxws/repairs.py
"""
import sys
-from gsxws import connect, SESSION
+from gsxws import connect
class GsxObject(object):
- data = dict()
+
+ data = {}
+
def __init__(self, **kwargs):
self.data = kwargs
+ def _make_type(self, new_dt):
+ """
+ Creates the top-level datatype for the API call
+ """
+ from gsxws import CLIENT, SESSION
+ dt = CLIENT.factory.create(new_dt)
+
+ if SESSION:
+ dt.userSession = SESSION
+
+ return dt
class Customer(GsxObject):
"""
@@ -38,7 +51,9 @@ class RepairOrderLine(GsxObject):
class Repair(GsxObject):
- """docstring for Repair"""
+ """
+ Abstract base class for the different GSX Repair types
+ """
customerAddress = None
symptom = ""
diagnosis = ""
@@ -71,10 +86,16 @@ class CarryInRepair(Repair):
fileName = ""
fileData = ""
diagnosedByTechId = ""
-
+
class IndirectOnsiteRepair(Repair):
- """docstring for IndirectOnsiteRepair"""
+ """
+ The Create Indirect Onsite Repair API is designed to create the indirect onsite repairs.
+ When a service provider travels to the customer location to perform repair
+ on a unit eligible for onsite service, they create an indirect repair.
+ Once the repair is submitted, it is assigned a confirmation number,
+ which is a reference number to identify the repair.
+ """
pass