Created
October 15, 2012 20:26
-
-
Save jwcobb/3895177 to your computer and use it in GitHub Desktop.
Debug Ticket Evolution order creation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Setup & format your order stuff for the $options variable | |
$apiMethod = 'createOrders'; | |
// Execute the call | |
try { | |
$results = $tevo->$apiMethod($options); | |
} catch (Exception $e) { | |
echo '<h1>Exception thrown trying to perform API request</h1>' . PHP_EOL | |
. _getRequest($tevo, $apiMethod, true) | |
. _getResponse($tevo, $apiMethod, true); | |
exit (1); | |
} | |
/** | |
* Utility function for returning formatted API request info | |
* | |
* @param TicketEvolution_Webservice $tevo | |
* @param string $apiMethod | |
* @param bool $isException | |
* @return string | |
*/ | |
function _getRequest($tevo, $apiMethod, $isException=true) | |
{ | |
$color = ($isException) ? '#f00' : '#ddd'; | |
$html = '<h2>Actual request for ' . $apiMethod . '() method</h2>' . PHP_EOL | |
. '<pre style="background-color: ' . $color . '">' . PHP_EOL | |
. print_r ($tevo->getRestClient()->getHttpClient()->getLastRequest(), true) | |
. '</pre><br />' . PHP_EOL; | |
return $html; | |
} | |
/** | |
* Utility function for returning formatted API response info | |
* | |
* @param TicketEvolution_Webservice $tevo | |
* @param string $apiMethod | |
* @param bool $isException | |
* @return string | |
*/ | |
function _getResponse($tevo, $apiMethod, $isException=true) | |
{ | |
$color = ($isException) ? '#f00' : '#ddd'; | |
$html = '<h2>Actual response for ' . $apiMethod . '() method</h2>' . PHP_EOL | |
. '<pre style="background-color: ' . $color . '">' . PHP_EOL | |
. print_r ($tevo->getRestClient()->getHttpClient()->getLastResponse(), true) | |
. '</pre><br />' . PHP_EOL; | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment