aboutsummaryrefslogtreecommitdiffstats
path: root/gsxlib.php
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2011-12-03 23:16:16 +0200
committerFilipp Lepalaan <filipp@mac.com>2011-12-03 23:16:16 +0200
commit5ac597d3d0b3f44699f96b47bc6c62348f5b0d26 (patch)
tree235a6af4036bd1c216e5b610d3b1baa8ea9105d3 /gsxlib.php
parent6ffa28a28f11490f0e27dcdbbc67210d492fac0e (diff)
downloadgsxlib-5ac597d3d0b3f44699f96b47bc6c62348f5b0d26.tar.gz
gsxlib-5ac597d3d0b3f44699f96b47bc6c62348f5b0d26.tar.bz2
gsxlib-5ac597d3d0b3f44699f96b47bc6c62348f5b0d26.zip
Added fetching product model, onsite dispatch details
Diffstat (limited to 'gsxlib.php')
-rw-r--r--gsxlib.php81
1 files changed, 63 insertions, 18 deletions
diff --git a/gsxlib.php b/gsxlib.php
index a8ed084..07e5018 100644
--- a/gsxlib.php
+++ b/gsxlib.php
@@ -79,7 +79,10 @@ class GsxLib
->userSessionId;
}
catch (SoapFault $e) {
- exit('Authentication with GSX failed. Does this account have access to '.$environment.' ?');
+ if( empty( $environment )) {
+ $environment = 'production';
+ }
+ exit('Authentication with GSX failed. Does this account have access to '.$environment."?\n");
}
// there's a session going, put the credentials in there
@@ -281,15 +284,9 @@ class GsxLib
/**
* A shortcut for checking warranty status of device
*/
- public function warrantyStatus($serialNumber)
+ public function warrantyStatus( $serialNumber )
{
- $serialNumber = trim($serialNumber);
- // SNs should never start with an S, but they're often coded into barcodes
- // and since an "old- ormat" SN + S would still qualify as a "new format" SN,
- // we strip it here
- $serialNumber = ltrim($serialNumber, 'sS');
-
- if (!self::looksLike($serialNumber, 'serialNumber')) {
+ if( !$this->isValidSerialNumber( $serialNumber )) {
exit('Invalid serial number: ' . $serialNumber);
}
@@ -301,6 +298,54 @@ class GsxLib
}
+ public function productModel( $serialNumber )
+ {
+ if( !$this->isValidSerialNumber( $serialNumber )) {
+ exit('Invalid serial number: ' . $serialNumber);
+ }
+
+ $req = array( 'FetchProductModelRequest' => array(
+ 'userSession' => array( 'userSessionId' => $this->session_id ),
+ 'productModelRequest' => array( 'serialNumber' => $serialNumber )
+ ));
+
+ $response = $this->client->FetchProductModel( $req )->FetchProductModelResponse;
+ return $response->productModelResponse;
+
+ }
+
+ public function onsiteDispatchDetail( $query )
+ {
+ if( !self::looksLike( $query, 'dispatchId' )) {
+ exit( "Invalid dispatch ID: $query" );
+ }
+
+ $req = array( 'OnsiteDispatchDetailRequest' => array(
+ 'userSession' => array( 'userSessionId' => $this->session_id ),
+ 'lookupRequestData' => array(
+ 'dispatchId' => $query,
+ 'dispatchSentFromDate' => '',
+ 'dispatchSentToDate' => ''
+ )
+ ));
+
+ $response = $this->client->OnsiteDispatchDetail( $req )->OnsiteDispatchDetailResponse;
+
+ return $response->onsiteDispatchDetails;
+
+ }
+
+ public function isValidSerialNumber( $serialNumber )
+ {
+ $serialNumber = trim( $serialNumber );
+ // SNs should never start with an S, but they're often coded into barcodes
+ // and since an "old- ormat" SN + S would still qualify as a "new format" SN,
+ // we strip it here and not in self::looksLike
+ $serialNumber = ltrim($serialNumber, 'sS');
+
+ return self::looksLike( $serialNumber, 'serialNumber' );
+ }
+
/**
* return the GSX user session ID
* I still keep the property private since it should not be modified
@@ -315,24 +360,24 @@ class GsxLib
/**
* Do the actual SOAP request
*/
- private function request($req)
+ private function request( $req )
{
$result = FALSE;
// split the request name and data
- list($r, $p) = each($req);
+ list( $r, $p ) = each( $req );
// add session info
- $p['userSession'] = array('userSessionId' => $this->session_id);
- $request = array($r.'Request' => $p);
-
+ $p['userSession'] = array( 'userSessionId' => $this->session_id );
+ $request = array( $r.'Request' => $p );
+ print_r( $request );
try {
- $result = $this->client->$r($request);
+ $result = $this->client->$r( $request );
$resp = "{$r}Response";
return $result->$resp;
}
catch (SoapFault $e) {
- print($this->client->__getLastRequest());
- trigger_error($e->getMessage());
+ print( $this->client->__getLastRequest() );
+ trigger_error( $e->getMessage() );
}
return $result;
@@ -346,7 +391,7 @@ class GsxLib
* unfortunately, it's no longer the case
* @param string $string string to check
*/
- static function looksLike($string, $what = null)
+ static function looksLike( $string, $what = null )
{
$result = false;