aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@230.to>2013-08-15 17:41:44 +0300
committerFilipp Lepalaan <f@230.to>2013-08-15 17:41:44 +0300
commitfc4b53765bbe428bedba0c8657317c6870891d92 (patch)
tree343c7bde568225a6c656f36cc1ff3d4cead902cd
parent774c8ed94e07f75fe38d5067dfea9b19bb32e77d (diff)
downloadpy-gsxws-fc4b53765bbe428bedba0c8657317c6870891d92.tar.gz
py-gsxws-fc4b53765bbe428bedba0c8657317c6870891d92.tar.bz2
py-gsxws-fc4b53765bbe428bedba0c8657317c6870891d92.zip
Added support for general escalations
-rw-r--r--gsxws/escalations.py73
-rw-r--r--tests/test_gsxws.py53
2 files changed, 113 insertions, 13 deletions
diff --git a/gsxws/escalations.py b/gsxws/escalations.py
index 2bf56e1..fa82a7a 100644
--- a/gsxws/escalations.py
+++ b/gsxws/escalations.py
@@ -1,23 +1,84 @@
# -*- coding: utf-8 -*-
+import os.path
from core import GsxObject
+from lookups import Lookup
+
+STATUS_OPEN = 'O'
+STATUS_CLOSED = 'C'
+STATUS_ESCALATED = 'E'
+
+STATUSES = (
+ (STATUS_OPEN, 'Open'),
+ (STATUS_CLOSED, 'Closed'),
+ (STATUS_ESCALATED, 'Escalated'),
+)
+
+CONTEXTS = (
+ 'Serial Number',
+ 'Alternate Device Id',
+ 'Dispatch Id',
+ 'SRO Number',
+ 'Invoice Number',
+ 'Order Number',
+ 'SSO number',
+ 'Part Number',
+ 'EEE Code',
+ 'Tracking Number',
+ 'Module Serial Number',
+ 'Escalation Id',
+)
+
+ISSUE_TYPES = (
+ ('AMQ', 'Account Management Question'),
+ ('UQ', 'Account Management Question'),
+ ('OSI', 'Order Status Issue'),
+ ('PRI', 'Part Return Issue'),
+ ('PPOR', 'Problem Placing Order/Repair'),
+ ('PUR', 'Problem Updating Repair'),
+ ('SCI', 'Shipping Carrier Issue'),
+ ('SES', 'Service Excellence Scoring'),
+ ('ARF', 'Apple Retail Feedback'),
+ ('DF', 'Depot Feedback'),
+ ('FS', 'GSX Feedback/Suggestion'),
+ ('WS', 'GSX Web Services (API)'),
+ ('SEPI', 'Service Excellence Program Information'),
+ ('TTI', 'Technical or Troubleshooting Issue'),
+ ('DTA', 'Diagnostic Tool Assistance'),
+ ('BIQ', 'Billing or Invoice Question'),
+ ('SESC', 'Safety Issue'),
+)
+
+
+class FileAttachment(GsxObject):
+ def __init__(self, fp):
+ super(FileAttachment, self).__init__()
+ self.fileName = os.path.basename(fp)
+ self.fileData = open(fp, 'r')
class Escalation(GsxObject):
+ _namespace = 'asp:'
+
def create(self):
"""
The Create General Escalation API allows users to create
a general escalation in GSX. The API was earlier known as GSX Help.
"""
- dt = self._make_type("ns1:createGenEscRequestType")
- dt.escalationRequest = self.data
- return self.submit("CreateGeneralEscalation", dt, "escalationConfirmation")
+ return self._submit("escalationRequest", "CreateGeneralEscalation",
+ "escalationConfirmation")
def update(self):
"""
The Update General Escalation API allows Depot users to
update a general escalation in GSX.
"""
- dt = self._make_type("ns1:updateGeneralEscRequestType")
- dt.escalationRequest = self.data
- return self.submit("UpdateGeneralEscalation", dt, "escalationConfirmation")
+ return self._submit("escalationRequest", "UpdateGeneralEscalation",
+ "escalationConfirmation")
+
+ def lookup(self):
+ """
+ The General Escalation Details Lookup API allows to fetch details
+ of a general escalation created by AASP or a carrier.
+ """
+ return Lookup(escalationId=self.escalationId).lookup("GeneralEscalationDetailsLookup")
diff --git a/tests/test_gsxws.py b/tests/test_gsxws.py
index c24217c..efc830e 100644
--- a/tests/test_gsxws.py
+++ b/tests/test_gsxws.py
@@ -4,8 +4,43 @@ import logging
from datetime import date
from unittest import main, skip, TestCase
-from gsxws import repairs
from gsxws.objectify import parse
+from gsxws import repairs, escalations
+
+
+class TestEscalationFunctions(TestCase):
+ def setUp(self):
+ from gsxws.core import connect
+ logging.basicConfig(level=logging.DEBUG)
+ connect('', '', '', 'it')
+ esc = escalations.Escalation()
+ esc.shipTo = ''
+ esc.issueTypeCode = 'WS'
+ esc.notes = 'This is a test'
+ self.escalation = esc.create()
+
+ def test_create_general_escalation(self):
+ self.assertTrue(self.escalation.escalationId)
+
+ def test_update_general_escalation(self):
+ esc = escalations.Escalation()
+ esc.escalationId = self.escalation.escalationId
+ esc.status = escalations.STATUS_CLOSED
+ result = esc.update()
+ self.assertEqual(result.updateStatus, 'SUCCESS')
+
+ def test_attach_general_escalation(self):
+ esc = escalations.Escalation()
+ esc.escalationId = self.escalation.escalationId
+ esc.attachment = escalations.FileAttachment('/tmp/logo.png')
+ result = esc.update()
+ self.assertEqual(result.updateStatus, 'SUCCESS')
+
+ def test_lookup_general_escalation(self):
+ esc = escalations.Escalation()
+ esc.escalationId = self.escalation.escalationId
+ result = esc.lookup()
+ self.assertEqual(result.escalationType, 'GSX Help')
class TestRepairFunctions(TestCase):
@@ -18,8 +53,8 @@ class TestRepairFunctions(TestCase):
rep.serialNumber = ''
rep.unitReceivedDate = '08/12/2013'
rep.unitReceivedTime = '11:00 am'
- rep.shipTo = '677592'
- rep.poNumber = '677592'
+ rep.shipTo = ''
+ rep.poNumber = ''
rep.symptom = 'test'
rep.diagnosis = 'test'
customer = repairs.Customer(emailAddress='test@example.com')
@@ -40,7 +75,8 @@ class TestRepairFunctions(TestCase):
class TestWarrantyFunctions(TestCase):
def setUp(self):
- self.data = parse('tests/fixtures/warranty_status.xml', 'warrantyDetailInfo')
+ self.data = parse('tests/fixtures/warranty_status.xml',
+ 'warrantyDetailInfo')
def test_purchase_date(self):
self.assertIsInstance(self.data.estimatedPurchaseDate, date)
@@ -58,7 +94,8 @@ class TestWarrantyFunctions(TestCase):
class TestActivation(TestCase):
def setUp(self):
- self.data = parse('tests/fixtures/ios_activation.xml', 'activationDetailsInfo')
+ self.data = parse('tests/fixtures/ios_activation.xml',
+ 'activationDetailsInfo')
def test_unlock_date(self):
self.assertIsInstance(self.data.unlockDate, date)
@@ -74,7 +111,8 @@ class TestActivation(TestCase):
class TestPartsLookup(TestCase):
def setUp(self):
- self.data = parse('tests/fixtures/parts_lookup.xml', 'PartsLookupResponse')
+ self.data = parse('tests/fixtures/parts_lookup.xml',
+ 'PartsLookupResponse')
self.part = self.data.parts[0]
def test_parts(self):
@@ -96,7 +134,8 @@ class TestPartsLookup(TestCase):
class TestOnsiteDispatchDetail(TestCase):
def setUp(self):
- self.data = parse('tests/fixtures/onsite_dispatch_detail.xml', 'onsiteDispatchDetails')
+ self.data = parse('tests/fixtures/onsite_dispatch_detail.xml',
+ 'onsiteDispatchDetails')
def test_details(self):
self.assertEqual(self.data.dispatchId, 'G101260028')