/**
  * Check the response for any errors it might indicate. Will throw an exception if API response indicates an error.
  * Will throw an exception if it has a problem determining success or error.
  * @param string response The API response to examine
  */
 public function HandleErrors($response)
 {
     // To handle plain text response
     if (!IsValidXml($response)) {
         return;
     }
     $responseXml = simplexml_load_string($response);
     IntuitErrorHandler::HandleErrorsXml($responseXml);
 }
 /**
  * Returns the response by calling REST service.
  *
  * @param RequestParameters $requestParameters The parameters
  * @param string $requestBody The request body
  * @param string $oauthRequestUri The OAuth request uri
  */
 public function GetResponseSyncRest($requestParameters, $requestBody, $oauthRequestUri)
 {
     $handler = new FaultHandler($this->context);
     // Create a variable for storing the response.
     $response = '';
     $responseCode = NULL;
     try {
         // Check whether the retryPolicy is null.
         if ($this->context->IppConfiguration->RetryPolicy == NULL) {
             // If yes then call the rest service without retry framework enabled.
             list($responseCode, $response) = $this->CallRestService($requestParameters, $requestBody, $oauthRequestUri);
         } else {
             // Not yet implemented
             throw new IdsException("Retry policy not available in this SDK");
             // If no then call the rest service using the execute action of retry framework.
             // $this->context->IppConfiguration->RetryPolicy->ExecuteAction(() =>
             // {
             //     $response = $this->CallRestService($requestParameters, $requestBody, $oauthRequestUri);
             // });
         }
     } catch (Exception $webException) {
         // System.Net.HttpWebRequest.Abort() was previously called.-or- The time-out
         // period for the request expired.-or- An error occurred while processing the request.
         $isIpp = false;
         if ($this->context->ServiceType == IntuitServicesType::IPP) {
             $isIpp = true;
         }
         $idsException = $handler->ParseResponseAndThrowException($webException, $responseCode, $isIpp);
         if ($idsException != null) {
             $this->context->IppConfiguration->Logger->CustomLogger->Log(TraceLevel::Error, $idsException->getMessage());
             throw $idsException;
         }
     }
     if ($this->context->ServiceType == IntuitServicesType::IPP) {
         // Handle errors here
         IntuitErrorHandler::HandleErrors($response);
     } else {
         // Check the response if there are any fault tags and throw appropriate exceptions.
         $oneException = $handler->ParseErrorResponseAndPrepareException($response);
         if (exception != null) {
             throw $oneException;
         }
     }
     // Return the response.
     return $response;
 }