Exemplo n.º 1
0
 /**
  * @return Collection
  */
 public function getAll()
 {
     $list = new Collection();
     $items = $this->getShortList();
     if (empty($items)) {
         return $list;
     }
     foreach ($items as $item) {
         $list->add(new Corporation($item->id, $this->instanceIdentifier));
     }
     return $list;
 }
Exemplo n.º 2
0
 /**
  * @param bool $id
  * @return bool|\VCAPI\Common\Collection
  * @throws \ErrorException
  */
 public function getStorage($id = false)
 {
     $result = Request::get('/corporation_items/storage/' . $this->id . '.json', $this->instanceIdentifier);
     if (!empty($result->error)) {
         Error::exception($result->setFlash[0]->msg);
         return false;
     }
     $storageCollection = new Collection();
     foreach ($result->storage as $item) {
         if ($id != false) {
             if ($item->CorporationItem->item_type_id == $id) {
                 $count = $item->CorporationItem->quantity;
                 return $count;
             }
         } else {
             $product = new Product($item->ItemType);
             $product->quantity = $item->CorporationItem->quantity;
             $storageCollection->add($product);
         }
     }
     return $storageCollection;
 }
Exemplo n.º 3
0
Arquivo: User.php Projeto: pshon/vcapi
 /**
  * Get all companies that belong to user
  *
  * @return \VCAPI\Common\Collection
  * @throws \ErrorException
  */
 public function getCompanies()
 {
     $result = Request::get('/companies/user_companies.json', $this->instanceIdentifier);
     if (empty($result->userId)) {
         return Error::exception('Authorization error');
     }
     $companies = new Collection();
     foreach ($result->companies as $company) {
         $companies->add(new Company($company->Company, $this->instanceIdentifier));
     }
     return $companies;
 }