aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rwxr-xr-xgsxcl8
-rw-r--r--gsxlib.php81
3 files changed, 72 insertions, 21 deletions
diff --git a/README.md b/README.md
index d1b86f0..dfeb732 100644
--- a/README.md
+++ b/README.md
@@ -27,8 +27,8 @@ If you're in the US, remember to set the fifth argument to the constructor to 'a
##gsxcl##
-The package includes a rudimentary command line client to the GSX API called gsxcl.
-Currently it can perform warranty checks and part lookups.
+The package includes a rudimentary command line client to the GSX API called gsxcl. It can perform various functions in the library and is meant
+mainly as a simple test tool for the library.
##License##
diff --git a/gsxcl b/gsxcl
index 6902d3c..7781f53 100755
--- a/gsxcl
+++ b/gsxcl
@@ -18,7 +18,7 @@ if (FALSE) {
error_reporting(E_ALL|E_STRICT);
}
-$modes = array('warranty', 'parts', 'pending', 'repair', 'lookup', 'status', 'label');
+$modes = array( 'warranty', 'parts', 'pending', 'repair', 'lookup', 'status', 'label', 'model', 'osdispatchdetail' );
$modes_str = implode(', ', $modes);
require 'gsxlib.php';
@@ -97,6 +97,12 @@ switch ($mode)
case 'comptia':
$result = $gsx->compTiaCodes();
break;
+ case 'model':
+ $result = $gsx->productModel( $query );
+ break;
+ case 'osdispatchdetail':
+ $result = $gsx->onsiteDispatchDetail( $query );
+ break;
case 'label':
list($order, $part) = explode(':', $query);
$result = $gsx->returnLabel($order, $part);
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;