Example #1
0
 /**
  * @param ReadByQuery $query
  * @param int $maxTotalCount
  * @param array $params Overriding params
  *
  * @return ArrayIterator
  * @throws ResultException
  */
 public function executeQuery(ReadByQuery $query, $maxTotalCount = self::DEFAULT_MAX_TOTAL_COUNT, array $params = [])
 {
     $this->setMaxTotalCount($maxTotalCount);
     $content = new Content([$query]);
     $response = parent::execute($content, false, null, false, $params);
     $result = $response->getOperation()->getResult();
     if ($result->getStatus() !== 'success') {
         throw new ResultException('An error occurred trying to get query records', $result->getErrors());
     }
     if ($result->getTotalCount() > $this->getMaxTotalCount()) {
         throw new ResultException('Query result totalcount of ' . $result->getTotalCount() . ' exceeds max totalcount parameter of ' . $this->getMaxTotalCount());
     }
     $records = new ArrayIterator();
     foreach ($result->getDataArray() as $record) {
         $records->append($record);
     }
     while ($result->getNumRemaining() > 0) {
         // Do readMore's with the resultId until number remaining is zero
         $readMore = new ReadMore();
         $readMore->setResultId($result->getResultId());
         $content = new Content([$readMore]);
         $response = parent::execute($content, false, null, false, $params);
         $result = $response->getOperation()->getResult();
         if ($result->getStatus() !== 'success') {
             throw new ResultException('An error occurred trying to query subsequent records', $result->getErrors());
         }
         foreach ($result->getDataArray() as $record) {
             $records->append($record);
         }
     }
     $records->rewind();
     return $records;
 }
 /**
  * Execute a synchronous request to the API
  *
  * @param Content $contentBlock Content block to send
  * @param bool $transaction Force the operation to be one transaction
  * @param string $requestControlId Request control ID
  * @param bool $uniqueFunctionControlIds Force the function control ID's to be unique
  * @param array $params Overriding params, @see IntacctClient::__construct()
  *
  * @return SynchronousResponse
  */
 public function execute(Content $contentBlock, $transaction = false, $requestControlId = null, $uniqueFunctionControlIds = false, array $params = [])
 {
     return parent::execute($contentBlock, $transaction, $requestControlId, $uniqueFunctionControlIds, $params);
 }