Beispiel #1
0
 public function fetch($page = 1)
 {
     $params = $this->params;
     if ($this->paginate) {
         $params = array_merge($params, array('page' => $page));
     }
     $response = $this->client->get($this->path(), $params);
     $data = $response->json();
     if ($this->paginate) {
         $this->total = $data['total'];
         $this->pages = $data['pages'];
         $this->limit = $data['limit'];
         $this->currentPage = $data['current_page'];
         foreach ($data[static::$name] as $i => $deviceData) {
             $position = $i + ($this->currentPage - 1) * $this->limit;
             $this->setResource($position, $deviceData);
         }
     } else {
         $data = current($data);
         $this->total = count($data);
         foreach ($data as $i => $deviceData) {
             $this->setResource($i, $deviceData);
         }
     }
 }
Beispiel #2
0
 /**
  * Deletes a resource
  *
  * @return void
  */
 public function delete()
 {
     $this->client->delete(static::$path . '/' . $this->id());
 }