diff --git a/exemple.php b/exemple.php index ad6b33a..fd06256 100644 --- a/exemple.php +++ b/exemple.php @@ -9,9 +9,9 @@ $App->authorize(); $App->openSession(); -$System = new \alphayax\freebox\api\v3\services\config\System( $App); +$Downloads = new \alphayax\freebox\api\v3\services\download\Download( $App); +$a = $Downloads->getAll(); +var_dump( $a); -/** @var \alphayax\freebox\api\v3\models\SystemConfig $SystemConfig */ -$SystemConfig = $System->getConfiguration(); - -\alphayax\utils\cli\IO::stdout( 'Uptime : '. $SystemConfig->uptime); +$b = $Downloads->getLogFromId( 156); +var_dump( $b); \ No newline at end of file diff --git a/freebox/api/v3/services/download/Download.php b/freebox/api/v3/services/download/Download.php new file mode 100644 index 0000000..dcc4e54 --- /dev/null +++ b/freebox/api/v3/services/download/Download.php @@ -0,0 +1,89 @@ +getAuthService( self::API_DOWNLOAD); + $rest->GET(); + return $rest->getCurlResponse()['result']; + } + + /** + * Get the current system info + * @param int $download_id + * @return + */ + public function getFromId( $download_id){ + $rest = $this->getAuthService( self::API_DOWNLOAD . $download_id); + $rest->GET(); + return $rest->getCurlResponse()['result']; + } + + /** + * Get the current system info + * @param int $download_id + * @return + */ + public function getLogFromId( $download_id){ + $logService = sprintf( self::API_DOWNLOAD_LOG, $download_id); + $rest = $this->getAuthService( $logService); + $rest->GET(); + return $rest->getCurlResponse()['result']; + } + + + /** + * Delete a download task (conserve data) + * @param int $download_id + * @return + */ + public function deleteFromId( $download_id){ + $rest = $this->getAuthService( self::API_DOWNLOAD . $download_id); + $rest->DELETE(); + return $rest->getCurlResponse()['result']; + } + + /** + * Delete a download task (erase data) + * @param int $download_id + * @return + */ + public function eraseFromId( $download_id){ + $eraseService = sprintf( self::API_DOWNLOAD_ERASE, $download_id); + $rest = $this->getAuthService( $eraseService); + $rest->DELETE(); + return $rest->getCurlResponse()['result']; + } + + + /** + * Delete a download task (erase data) + * @param int $download_id + * @param array $data + * @return + */ + public function updateFromId( $download_id, $data){ + $eraseService = sprintf( self::API_DOWNLOAD_ERASE, $download_id); + $rest = $this->getAuthService( $eraseService); + $rest->PUT( $data); + return $rest->getCurlResponse()['result']; + } + + +}