diff options
author | Filipp Lepalaan <filipp@mac.com> | 2011-05-04 10:21:42 +0300 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2011-05-04 10:21:42 +0300 |
commit | d9b7519391b86f79573c756c357a84eda83fa725 (patch) | |
tree | 67040609d5426398c233a964ba3e8db215d208d1 | |
parent | 7564c53dffb75c643dc32406ad0a939fa31d8833 (diff) | |
download | gsxlib-d9b7519391b86f79573c756c357a84eda83fa725.tar.gz gsxlib-d9b7519391b86f79573c756c357a84eda83fa725.tar.bz2 gsxlib-d9b7519391b86f79573c756c357a84eda83fa725.zip |
Added repairStatus()
-rw-r--r-- | gsxlib.php | 90 |
1 files changed, 60 insertions, 30 deletions
@@ -66,7 +66,7 @@ class GsxLib try { $this->session_id = $this->client->Authenticate($a)->AuthenticateResponse->userSessionId; } catch (SoapFault $e) { - exit('Authentication with GSX failed. Does this GSX account have access to this environment?'); + exit('Authentication with GSX failed. Does this account have access to '.$environment.' ?'); } // there's a session going, put the credentials in there @@ -78,6 +78,36 @@ class GsxLib } /** + * Get current GSX status of repair + * @param mixed $dispatchId + */ + public function repairStatus($dispatchId) + { + $toCheck = array(); + + if (!is_array($dispatchId)) { + $dispatchId = array($dispatchId); + } + + foreach ($dispatchId as $id) { + if (self::looksLike($id, 'dispatchId')) { + $toCheck[] = $id; + } + } + + if (empty($toCheck)) { + exit('No valid dispatch IDs given'); + } + + $req = array('RepairStatus' => array( + 'repairConfirmationNumbers' => $toCheck + )); + + return $this->request($req)->repairStatus; + + } + + /** * Return details for given dispatch ID * @param string $dispatchId * @return object lookupResponseData @@ -118,35 +148,6 @@ class GsxLib } /** - * Try to "categorise" a string - * About identifying serial numbers - before 2010, Apple had a logical - * serial number format, with structure, that you could id quite reliably. - * unfortunately, it's no longer the case - * @param string $string - */ - static function looksLike($string, $what = null) - { - $result = false; - - $rex = array( - 'partNumber' => '/^[a-z]?\d{3}\-\d{4}$/i', - 'serialNumber' => '/^[a-z0-9]{11,12}$/i', - 'eeeCode' => '/^[a-z0-9]{3,4}$/i', - 'repairNumber' => '/^\d{12}$/', - 'dispatchId' => '/^G\d{9}$/i' - ); - - foreach ($rex as $k => $v) { - if (preg_match($v, $string)) { - $result = $k; - } - } - - return ($what) ? ($result == $what) : $result; - - } - - /** * A shortcut for checking warranty status of device */ public function warrantyStatus($serialNumber) @@ -196,6 +197,35 @@ class GsxLib } + /** + * Try to "categorise" a string + * About identifying serial numbers - before 2010, Apple had a logical + * serial number format, with structure, that you could id quite reliably. + * unfortunately, it's no longer the case + * @param string $string + */ + static function looksLike($string, $what = null) + { + $result = false; + + $rex = array( + 'partNumber' => '/^[a-z]?\d{3}\-\d{4}$/i', + 'serialNumber' => '/^[a-z0-9]{11,12}$/i', + 'eeeCode' => '/^[a-z0-9]{3,4}$/i', + 'repairNumber' => '/^\d{12}$/', + 'dispatchId' => '/^G\d{9}$/i' + ); + + foreach ($rex as $k => $v) { + if (preg_match($v, $string)) { + $result = $k; + } + } + + return ($what) ? ($result == $what) : $result; + + } + } |