aboutsummaryrefslogtreecommitdiffstats
path: root/gsxlib.php
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2011-05-04 15:58:02 +0300
committerFilipp Lepalaan <filipp@mac.com>2011-05-04 15:58:02 +0300
commit00c0f79d93ee7c33c57d8749d297ec5fd3a33af3 (patch)
tree3105cf737419a2a8b369d8ae0f13a72a5a58f3aa /gsxlib.php
parentc7765c9b7a6ef6ca4e0baccae7896db4481f5f40 (diff)
downloadgsxlib-00c0f79d93ee7c33c57d8749d297ec5fd3a33af3.tar.gz
gsxlib-00c0f79d93ee7c33c57d8749d297ec5fd3a33af3.tar.bz2
gsxlib-00c0f79d93ee7c33c57d8749d297ec5fd3a33af3.zip
Added all kinds of stuff
Diffstat (limited to 'gsxlib.php')
-rw-r--r--gsxlib.php104
1 files changed, 94 insertions, 10 deletions
diff --git a/gsxlib.php b/gsxlib.php
index 6e0caf8..04e2655 100644
--- a/gsxlib.php
+++ b/gsxlib.php
@@ -18,6 +18,8 @@ class GsxLib
private $region;
private $session_id;
private $environment;
+
+ const timeout = 30;
function __construct($account, $username, $password, $environment = '', $region = 'emea', $tz = 'CEST')
{
@@ -56,7 +58,8 @@ class GsxLib
'password' => $password,
'serviceAccountNo' => $account,
'languageCode' => 'en',
- 'userTimeZone' => $tz)
+ 'userTimeZone' => $tz,
+ )
);
if (@$_SESSION['_gsxlib_session_timeout'] > time()) {
@@ -64,15 +67,19 @@ class GsxLib
}
try {
- $this->session_id = $this->client->Authenticate($a)->AuthenticateResponse->userSessionId;
- } catch (SoapFault $e) {
+ $this->session_id = $this->client
+ ->Authenticate($a)
+ ->AuthenticateResponse
+ ->userSessionId;
+ }
+ catch (SoapFault $e) {
exit('Authentication with GSX failed. Does this account have access to '.$environment.' ?');
}
// there's a session going, put the credentials in there
if (session_id()) {
$_SESSION['_gsxlib_session_id'] = $this->session_id;
- $_SESSION['_gsxlib_session_timeout'] = time()+(60*30);
+ $_SESSION['_gsxlib_session_timeout'] = time()+(60*self::timeout);
}
}
@@ -107,6 +114,59 @@ class GsxLib
}
+ public function bulkReturnProforma()
+ {
+
+ }
+
+ public function repairLookup($query)
+ {
+ $fields = array(
+ 'repairConfirmationNumber' => '',
+ 'customerEmailAddress' => '',
+ 'customerFirstName' => '',
+ 'customerLastName' => '',
+ 'fromDate' => '',
+ 'toDate' => '',
+ 'incompleteRepair' => 'N',
+ 'pendingShipment' => 'N',
+ 'purchaseOrderNumber' => '',
+ 'repairNumber' => '',
+ 'repairStatus' => '',
+ 'repairType' => 'CA',
+ 'serialNumber' => '',
+ 'shipToCode' => '',
+ 'soldToReferenceNumber' => '',
+ 'technicianFirstName' => '',
+ 'technicianLastName' => '',
+ 'unreceivedModules' => 'N',
+ );
+
+ if (!is_array($query)) {
+ if (self::looksLike($query, 'dispatchId')) {
+ $query = array('repairConfirmationNumber' => $query);
+ } else {
+ exit('Invalid query for repair lookup: ' . $query);
+ }
+ }
+
+ foreach ($fields as $k => $v) {
+ if (array_key_exists($k, $query)) {
+ $fields[$k] = $query[$k];
+ }
+ }
+
+ $req = array('RepairLookup' => array('lookupRequestData' => $fields));
+ return $this->request($req)->lookupResponseData;
+
+ }
+
+ /**
+ * List parts pending for return
+ * Default to Open Carry-Ins
+ * @param mixed $repairData
+ * @return mixed
+ */
public function partsPendingReturn($repairData = null)
{
$fields = array(
@@ -124,10 +184,14 @@ class GsxLib
'createdToDate' => '',
);
- if ($repairData) {
- foreach ($fields as $f) {
- if (array_key_exists($f, $repairData)) {
- $fields[$f] = $repairData[$f];
+ if (!is_array($repairData)) {
+ $repairData = array();
+ }
+
+ if (!empty($repairData)) {
+ foreach ($fields as $k => $v) {
+ if (array_key_exists($k, $repairData)) {
+ $fields[$k] = $repairData[$f];
}
}
}
@@ -162,6 +226,25 @@ class GsxLib
}
+ public function returnLabel($returnOrder, $partNumber)
+ {
+ if (!self::looksLike($returnOrder, 'returnOrder')) {
+ exit('Invalid order number: ' . $returnOrder);
+ }
+
+ if (!self::partNumber($part, 'partNumber')) {
+ exit('Invalid part number: ' . $partNumber);
+ }
+
+ $req = array('ReturnLabel' => array(
+ 'returnOrderNumber' => $returnOrder,
+ 'partNumber' => $partNumber
+ ));
+
+ return $this->request($req)->returnLabelData;
+
+ }
+
/**
* a shortcut for looking up part information
* @param mixed $string
@@ -246,11 +329,12 @@ class GsxLib
$result = false;
$rex = array(
- 'partNumber' => '/^[a-z]?\d{3}\-\d{4}$/i',
+ 'partNumber' => '/^([a-z]{1,2})?\d{3}\-\d{4}$/i',
'serialNumber' => '/^[a-z0-9]{11,12}$/i',
'eeeCode' => '/^[a-z0-9]{3,4}$/i',
+ 'returnOrder' => '/^7\d{9}$/',
'repairNumber' => '/^\d{12}$/',
- 'dispatchId' => '/^G\d{9}$/i'
+ 'dispatchId' => '/^G\d{9}$/i',
);
foreach ($rex as $k => $v) {