/**
  * Prepare the uri for submission to the api.
  *
  * @param type $path
  * @return string uri
  * @throw OptimalException
  */
 private function prepareURI($path)
 {
     if (!$this->client->getAccount()) {
         throw new OptimalException('Missing or invalid account', 500);
     }
     return $this->uri . '/accounts/' . $this->client->getAccount() . $path;
 }
Esempio n. 2
0
 /**
  * Get the card.
  *
  * @param \OptimalPayments\CustomerVault\Card $card
  * @return bool
  * @throws OptimalException
  * @throws NetbanxException
  */
 public function getCard(CustomerVault\Card $card)
 {
     $card->setRequiredFields(array('profileID', 'id'));
     $card->checkRequiredFields();
     $request = new Request(array('method' => Request::GET, 'uri' => $this->prepareURI("/profiles/" . $card->profileID . "/cards/" . $card->id)));
     $response = $this->client->processRequest($request);
     $response['profileID'] = $card->profileID;
     return new CustomerVault\Card($response);
 }
 /**
  * Go to the next element
  */
 public function next()
 {
     $this->position++;
     if (!$this->valid() && $this->nextPage) {
         $request = new \OptimalPayments\Request($this->nextPage);
         $this->nextPage = null;
         $response = $this->client->processRequest($request);
         $this->parseResponse($response);
     }
 }
 /**
  * Get matching orders
  *
  * @param int $count
  * @return HostedPayment\Order[]
  * @throws OptimalException
  * @throws NetbanxException
  */
 public function getOrders($count = 0)
 {
     $queryStr = array();
     if (!is_int($count) || $count < 0) {
         throw new OptimalException("Invalid count {$count}. Positive integer expected.");
     }
     if ($count) {
         $queryStr['num'] = $count;
     }
     $request = new Request(array('method' => Request::GET, 'uri' => $this->prepareURI("/orders"), 'queryStr' => $queryStr));
     $response = $this->client->processRequest($request);
     return new HostedPayment\Pagerator($this->client, $response, '\\OptimalPayments\\HostedPayment\\Order');
 }