aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@230.to>2013-02-04 11:52:31 +0200
committerFilipp Lepalaan <f@230.to>2013-02-04 11:52:31 +0200
commit87a151fce1d2f646d609be7a4522e267d7b50383 (patch)
treed5d686f96aefd0f25627a20fb21dd0767746627f
parentde4dd51c635200c180c45b9a6dbcce8fc2ea6b20 (diff)
downloadpy-gsxws-87a151fce1d2f646d609be7a4522e267d7b50383.tar.gz
py-gsxws-87a151fce1d2f646d609be7a4522e267d7b50383.tar.bz2
py-gsxws-87a151fce1d2f646d609be7a4522e267d7b50383.zip
Fix tracking URL formatting
-rwxr-xr-xgsxws.py46
-rw-r--r--setup.py3
2 files changed, 38 insertions, 11 deletions
diff --git a/gsxws.py b/gsxws.py
index da7d6ea..8f4d0fa 100755
--- a/gsxws.py
+++ b/gsxws.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+
#coding=utf-8
import re
@@ -516,8 +518,8 @@ class Repair(GsxObject):
dt = self._make_type('ns1:markRepairCompleteRequestType')
dt.repairConfirmationNumbers = [self.data['dispatchId']]
result = CLIENT.service.MarkRepairComplete(dt)
- print result
- return result
+
+ return result.repairConfirmationNumbers
def delete(self):
"""
@@ -549,7 +551,17 @@ class Repair(GsxObject):
dt = self._make_type('ns0:repairDetailsRequestType')
dt.dispatchId = self.data['dispatchId']
results = CLIENT.service.RepairDetails(dt)
- return results.lookupResponseData[0]
+ details = results.lookupResponseData[0]
+
+ # fix tracking URL if available
+ for i, p in enumerate(details.partsInfo):
+ try:
+ url = re.sub('<<TRKNO>>', p.deliveryTrackingNumber, p.carrierURL)
+ details.partsInfo[i].carrierURL = url
+ except AttributeError, e:
+ pass
+
+ return details
class Communication(GsxObject):
def get_content():
@@ -630,22 +642,24 @@ def init(env='ut', region='emea'):
CLIENT = Client(url)
-def connect(user_id, password, sold_to, lang='en', tz='CEST',
- env='ut', region='emea', locale=LOCALE):
+def connect(user_id, password, sold_to,
+ language='en', timezone='CEST',
+ environment='ut', region='emea', locale=LOCALE):
+
global SESSION
global LOCALE
SESSION = {}
LOCALE = LOCALE
- init(env, region)
+ init(environment, region)
account = CLIENT.factory.create('ns3:authenticateRequestType')
account.userId = user_id
account.password = password
- account.languageCode = lang
- account.userTimeZone = tz
+ account.languageCode = language
+ account.userTimeZone = timezone
account.serviceAccountNo = sold_to
result = CLIENT.service.Authenticate(account)
@@ -659,7 +673,21 @@ def logout():
if __name__ == '__main__':
import json
import sys
- #connect(*sys.argv[1:4])
+ import argparse
+
+ parser = argparse.ArgumentParser(description='Communicate with GSX Web Services')
+
+ parser.add_argument('user_id')
+ parser.add_argument('password')
+ parser.add_argument('sold_to')
+ parser.add_argument('--language', default='en')
+ parser.add_argument('--timezone', default='CEST')
+ parser.add_argument('--environment', default='pr')
+ parser.add_argument('--region', default='emea')
+ args = parser.parse_args()
+
+ #connect(**vars(args))
+
#f = 'tests/create_carryin_repair.json'
#f = 'tests/update_escalation.json'
#fp = open(f, 'r')
diff --git a/setup.py b/setup.py
index 6358bfb..f5c6aa0 100644
--- a/setup.py
+++ b/setup.py
@@ -1,9 +1,8 @@
from setuptools import setup, find_packages
-import sys, os
setup(
name="gsxws",
- version="0.2",
+ version="0.1",
description="Apple GSX integration.",
install_requires = ['suds'],
classifiers=[