From 1682659a37c29820bc44e3e9646f0e99abbe0fd7 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Sat, 3 Dec 2011 23:49:08 +0200 Subject: Fixed repair status lookup --- gsxlib.php | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/gsxlib.php b/gsxlib.php index 07e5018..60d57e5 100644 --- a/gsxlib.php +++ b/gsxlib.php @@ -97,7 +97,7 @@ class GsxLib * Get current GSX status of repair * @param mixed $dispatchId */ - public function repairStatus($dispatchId) + public function repairStatus( $dispatchId ) { $toCheck = array(); @@ -128,7 +128,7 @@ class GsxLib } - public function repairLookup($query) + public function repairLookup( $query ) { $fields = array( 'repairConfirmationNumber' => '', @@ -151,22 +151,26 @@ class GsxLib 'unreceivedModules' => 'N', ); - if (!is_array($query)) { - if (self::looksLike($query, 'dispatchId')) { - $query = array('repairConfirmationNumber' => $query); - } else { - exit('Invalid query for repair lookup: ' . $query); - } - } + $like = self::looksLike( $query ); - foreach ($fields as $k => $v) { - if (array_key_exists($k, $query)) { - $fields[$k] = $query[$k]; - } + switch( $like ) { + case 'dispatchId': + $query = array( 'repairConfirmationNumber' => $query ); + break; + case 'serialNumber': + $query = array( 'serialNumber' => $query ); + break; } - $req = array('RepairLookup' => array('lookupRequestData' => $fields)); - return $this->request($req)->lookupResponseData; + $query = array_merge( $fields, $query ); + + $req = array( 'RepairLookupRequest' => + array( 'userSession' => array( 'userSessionId' => $this->session_id ), 'lookupRequestData' => $query ) + ); + + $response = $this->client->RepairLookup( $req )->RepairLookupResponse; + + return $response->lookupResponseData; } @@ -314,6 +318,8 @@ class GsxLib } + + public function onsiteDispatchDetail( $query ) { if( !self::looksLike( $query, 'dispatchId' )) { -- cgit v1.2.3