コード例 #1
0
 /**
  * Updates the resell package with given id.
  *
  * @param string $id
  * @param int    $amount
  * @param int    $price
  * @param string $description
  *
  * @throws NonExistentIdApiException
  */
 public function update($id, $amount, $price, $description)
 {
     $result = $this->connectToStorageInternalWorker->connect()->update(array('id' => $id), array('$set' => array('amount' => (int) $amount, 'price' => (int) $price, 'description' => $description)));
     if ($result['n'] == 0) {
         throw new NonExistentIdApiException();
     }
 }
コード例 #2
0
 /**
  * Deletes the resell package with given id.
  *
  * @param string $id
  *
  * @throws NonExistentIdApiException
  */
 public function delete($id)
 {
     $result = $this->connectToStorageInternalWorker->connect()->remove(array('id' => $id));
     if ($result['n'] == 0) {
         throw new NonExistentIdApiException();
     }
 }
コード例 #3
0
 /**
  * Picks the resell package with given id.
  *
  * @param string $id
  *
  * @return array A resell package as an array with the following keys:
  *               id, amount, and price.
  *
  * @throws NonExistentIdInternalException
  */
 public function pick($id)
 {
     $resellPackage = $this->connectToStorageInternalWorker->connect()->findOne(['id' => $id], ['_id' => 0]);
     if (!$resellPackage) {
         throw new NonExistentIdInternalException();
     }
     return $resellPackage;
 }
コード例 #4
0
 /**
  * Collect resell packages, sorted ascending by amount.
  *
  * @return \Iterator An array of resell packages with the following keys:
  *                   id, amount, price and description
  */
 public function collect()
 {
     return $this->connectToStorageInternalWorker->connect()->find()->fields(['_id' => 0])->sort(['amount' => 1]);
 }
コード例 #5
0
 /**
  * Creates a resell package.
  *
  * @param string $id
  * @param int    $amount
  * @param int    $price
  * @param string $description
  */
 public function create($id, $amount, $price, $description)
 {
     $this->connectToStorageInternalWorker->connect()->insert(array('id' => $id, 'amount' => (int) $amount, 'price' => (int) $price, 'description' => $description));
 }