diff --git a/composer.json b/composer.json
index 2ac6c73..167783e 100644
--- a/composer.json
+++ b/composer.json
@@ -16,7 +16,7 @@
"monolog/monolog": "^1.9.1"
},
"require-dev" : {
- "alphayax/phpdoc_md" : "^1.0.1",
+ "alphayax/phpdoc_md" : "^1.0.3",
"codacy/coverage": "<2.0.0",
"phpunit/phpunit": "^5.4.0",
"zf1/zend-reflection": "1.12.*"
diff --git a/docs/services/FileSystem/FileSystem.md b/docs/services/FileSystem/FileSystem.md
index b3c4f96..8393d7f 100644
--- a/docs/services/FileSystem/FileSystem.md
+++ b/docs/services/FileSystem/FileSystem.md
@@ -20,9 +20,9 @@
| Method | Description |
|---|---|
-| `getAll` | Retrieve a File Sharing link |
-| `getFromToken` | |
-| `deleteFromToken` | Delete a File Sharing link Deletes the ShareLink task with the given token, if the task was running, stop it. |
+| `getAll` | Retrieve all File Sharing links |
+| `getFromToken` | Get a file sharing link from his token identifier |
+| `deleteFromToken` | Delete a File Sharing link for his token identifier Deletes the ShareLink task with the given token, if the task was running, stop it. |
| `create` | Create a File Sharing link |
@@ -34,7 +34,7 @@
| Method | Description |
|---|---|
-| `getFilesFromDirectory` | |
+| `getFilesFromDirectory` | Get all files in a given directory |
| `getFileInformation` | Get file information |
@@ -57,7 +57,7 @@
| `getHashValue` | Get the hash value To get the hash, the task must have succeed and be in the state “done”. |
| `createDirectory` | Create a directory Contrary to other file system tasks, this operation is done synchronously. |
| `rename` | Rename a file/folder Contrary to other file system tasks, this operation is done synchronously. |
-| `download` | Download a file from the freebox server |
+| `download` | Download a file from the freebox server (return the file content) |
## FileSystemTask
diff --git a/docs/services/download/download.md b/docs/services/download/download.md
index e748558..2d29299 100644
--- a/docs/services/download/download.md
+++ b/docs/services/download/download.md
@@ -50,12 +50,16 @@
|---|---|
| `getAll` | Returns the collection of all Download tasks |
| `getFromId` | Returns the Download task with the given id |
+| `getLogFromId` | Get the current system info |
+| `deleteFromId` | Delete a download task (conserve data) |
+| `eraseFromId` | Delete a download task (erase data) |
| `update` | Update a download task |
-| `addFromUrl` | |
-| `addFromUrls` | |
-| `addFromFile` | |
+| `addFromUrl` | Add a download task with the specified URL |
+| `addFromUrls` | Add a download task with all the specified URLs |
+| `addFromFile` | Add a download task with the specified file (torrent, nzb...) |
| `getStats` | Returns the Download task with the given id |
-| `getFilesFromId` | Returns the Download task with the given id |
+| `getFilesFromId` | Returns the downloaded files with the given task id |
+| `updateFilePriority` | Update a download priority |
## Feed
@@ -75,8 +79,8 @@
| `refreshFeeds` | Remotely fetches the RSS feed and updates it. Note that if the remote feed specifies a TTL, trying to update before the ttl will result in feed_is_recent error |
| `getFeedItems` | Returns the collection of all DownloadFeedItems for a given DownloadFeed |
| `updateFeedItem` | Returns the collection of all DownloadFeedItems for a given DownloadFeed |
-| `downloadFeedItem` | Returns the collection of all DownloadFeedItems for a given DownloadFeed |
-| `markFeedAsRead` | Returns the collection of all DownloadFeedItems for a given DownloadFeed |
+| `downloadFeedItem` | Download the specified feed item |
+| `markFeedAsRead` | Mark the specified feed id as "Read" |
## Peer
diff --git a/exemple/download/Bittorent.php b/exemple/download/Bittorent.php
index 29215c7..a9ed2c9 100644
--- a/exemple/download/Bittorent.php
+++ b/exemple/download/Bittorent.php
@@ -12,7 +12,7 @@ $App->openSession();
$DownloadService = new \alphayax\freebox\api\v3\services\download\Download( $App);
$Downloads = $DownloadService->getAll();
print_r( $Downloads);
-/*
+
/// Trackers
$TrackerService = new \alphayax\freebox\api\v3\services\download\Tracker( $App);
$Trackers = $TrackerService->getAll( $Downloads[1]->getId());
@@ -22,7 +22,7 @@ print_r( $Trackers);
$PeerService = new \alphayax\freebox\api\v3\services\download\Peer( $App);
$Peers = $PeerService->getAll( $Downloads[0]->getId());
print_r( $Peers);
-*/
+
$BLService = new \alphayax\freebox\api\v3\services\download\BlackList( $App);
$BLEntries = $BLService->getAllFromDownloadTaskId( $Downloads[0]->getId());
diff --git a/freebox/api/v3/services/FileSystem/FileSharingLink.php b/freebox/api/v3/services/FileSystem/FileSharingLink.php
index 210103e..153d9b9 100644
--- a/freebox/api/v3/services/FileSystem/FileSharingLink.php
+++ b/freebox/api/v3/services/FileSystem/FileSharingLink.php
@@ -1,6 +1,6 @@
getAuthService( self::API_SHARE_LINK);
$rest->GET();
- $ApiReturn = $rest->getCurlResponse();
- $FileSharingLinks = [];
- $FileSharingLink_xs = @$ApiReturn['result'] ?: [];
- foreach( $FileSharingLink_xs as $fileSharingLink_x){
- $FileSharingLinks[] = new ShareLink( $fileSharingLink_x);
- }
- return $FileSharingLinks;
+ return $rest->getResultAsArray( models\FileSystem\ShareLink::class);
}
/**
+ * Get a file sharing link from his token identifier
* @param $Token
- * @return ShareLink
+ * @return models\FileSystem\ShareLink
*/
public function getFromToken( $Token){
$rest = $this->getAuthService( self::API_SHARE_LINK . $Token);
$rest->GET();
- return new ShareLink( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\FileSystem\ShareLink::class);
}
/**
- * Delete a File Sharing link
+ * Delete a File Sharing link for his token identifier
* Deletes the ShareLink task with the given token, if the task was running, stop it.
* No rollback is done, if a file as already been processed it will be left as is.
* @param $Token
@@ -51,7 +46,7 @@ class FileSharingLink extends Service {
$rest = $this->getAuthService( self::API_SHARE_LINK . $Token);
$rest->DELETE();
- return $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
/**
@@ -59,7 +54,7 @@ class FileSharingLink extends Service {
* @param string $Path
* @param int $expire
* @param string $fullUrl
- * @return ShareLink
+ * @return models\FileSystem\ShareLink
*/
public function create( $Path, $expire = 0, $fullUrl = ''){
$Path_b64 = base64_encode( $Path);
@@ -71,7 +66,7 @@ class FileSharingLink extends Service {
'fullurl' => $fullUrl,
]);
- return new ShareLink( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\FileSystem\ShareLink::class);
}
}
diff --git a/freebox/api/v3/services/FileSystem/FileSystemListing.php b/freebox/api/v3/services/FileSystem/FileSystemListing.php
index d1f829e..d1eb23d 100644
--- a/freebox/api/v3/services/FileSystem/FileSystemListing.php
+++ b/freebox/api/v3/services/FileSystem/FileSystemListing.php
@@ -1,6 +1,6 @@
$removeHidden,
]);
- $FileInfo_xs = $rest->getCurlResponse()['result'];
- $FileInfos = [];
- foreach( $FileInfo_xs as $FileInfo_x) {
- $FileInfos[] = new FileInfo( $FileInfo_x);
- }
- return $FileInfos;
+ return $rest->getResultAsArray( models\FileSystem\FileInfo::class);
}
/**
* Get file information
* @param string $DirectoryName
- * @return FileInfo
+ * @return models\FileSystem\FileInfo
*/
public function getFileInformation( $DirectoryName){
$Directory_b64 = base64_encode( $DirectoryName);
$rest = $this->getAuthService( self::API_FS_INFO . $Directory_b64);
$rest->GET();
- return new FileInfo( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\FileSystem\FileInfo::class);
}
}
diff --git a/freebox/api/v3/services/FileSystem/FileSystemOperation.php b/freebox/api/v3/services/FileSystem/FileSystemOperation.php
index c374882..73c2507 100644
--- a/freebox/api/v3/services/FileSystem/FileSystemOperation.php
+++ b/freebox/api/v3/services/FileSystem/FileSystemOperation.php
@@ -1,6 +1,6 @@
$conflictMode,
]);
- return new FsTask( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\FileSystem\FsTask::class);
}
/**
@@ -53,7 +53,7 @@ class FileSystemOperation extends Service {
* @param string[] $sourceFiles
* @param string $destination
* @param string $conflictMode
- * @return FsTask
+ * @return models\FileSystem\FsTask
*/
public function copy( array $sourceFiles = [], $destination, $conflictMode = 'recent'){
/// Convert all paths in base64
@@ -70,13 +70,13 @@ class FileSystemOperation extends Service {
'mode' => $conflictMode,
]);
- return new FsTask( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\FileSystem\FsTask::class);
}
/**
* Delete files
* @param string[] $RemoveFiles
- * @return FsTask
+ * @return models\FileSystem\FsTask
*/
public function remove( array $RemoveFiles = []){
/// Convert all paths in base64
@@ -90,7 +90,7 @@ class FileSystemOperation extends Service {
'files' => $removedFiles_b64,
]);
- return new FsTask( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\FileSystem\FsTask::class);
}
/**
@@ -101,7 +101,7 @@ class FileSystemOperation extends Service {
* @param bool $isToDelete : Deletes source files
* @param bool $isToOverwrite : Overwrites the destination
* @param bool $isToAppend : Append to the destination
- * @return FsTask
+ * @return models\FileSystem\FsTask
*/
public function cat( array $fileParts = [], $destination, $isMultiVolumes = false, $isToDelete = false, $isToOverwrite = false, $isToAppend = false){
/// Convert all paths in base64
@@ -121,14 +121,14 @@ class FileSystemOperation extends Service {
'overwrite' => $isToOverwrite,
]);
- return new FsTask( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\FileSystem\FsTask::class);
}
/**
* Create an archive
* @param string[] $fileParts : The list of files to concatenate
* @param string $destination : The destination file
- * @return FsTask
+ * @return models\FileSystem\FsTask
*/
public function archive( array $fileParts = [], $destination){
/// Convert all paths in base64
@@ -144,7 +144,7 @@ class FileSystemOperation extends Service {
'dst' => $destination_b64,
]);
- return new FsTask( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\FileSystem\FsTask::class);
}
/**
@@ -154,7 +154,7 @@ class FileSystemOperation extends Service {
* @param string $password : The archive password
* @param bool $isToDelete : Delete archive after extraction
* @param bool $isToOverwrite : Overwrites the destination
- * @return FsTask
+ * @return models\FileSystem\FsTask
*/
public function extract( $source, $destination, $password = '', $isToDelete = false, $isToOverwrite = false){
/// Convert all paths in base64
@@ -170,14 +170,14 @@ class FileSystemOperation extends Service {
'overwrite' => $isToOverwrite,
]);
- return new FsTask( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\FileSystem\FsTask::class);
}
/**
* Repair files from a .par2
* @param string $source : The .par2 file
* @param bool $isToDelete : Delete par2 files after repair
- * @return FsTask
+ * @return models\FileSystem\FsTask
*/
public function repair( $source, $isToDelete = false){
/// Convert all paths in base64
@@ -189,7 +189,7 @@ class FileSystemOperation extends Service {
'delete_archive' => $isToDelete,
]);
- return new FsTask( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\FileSystem\FsTask::class);
}
/**
@@ -198,7 +198,7 @@ class FileSystemOperation extends Service {
* @see
* @param string $source : The file to hash
* @param string $hashType : The type of hash (md5, sha1, ...) - Default is md5
- * @return FsTask
+ * @return models\FileSystem\FsTask
*/
public function computeHash( $source, $hashType = 'md5'){
/// Convert all paths in base64
@@ -210,7 +210,7 @@ class FileSystemOperation extends Service {
'hash_type' => $hashType,
]);
- return new FsTask( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\FileSystem\FsTask::class);
}
/**
@@ -224,7 +224,7 @@ class FileSystemOperation extends Service {
$rest = $this->getAuthService( $service);
$rest->GET();
- return $rest->getCurlResponse()['result'];
+ return $rest->getResult();
}
/**
@@ -242,7 +242,7 @@ class FileSystemOperation extends Service {
'dirname' => $newDirectoryName,
]);
- return $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
/**
@@ -260,11 +260,11 @@ class FileSystemOperation extends Service {
'dst' => $newFileName,
]);
- return $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
/**
- * Download a file from the freebox server
+ * Download a file from the freebox server (return the file content)
* @param string $sourceFilePath
* @return mixed
*/
diff --git a/freebox/api/v3/services/FileSystem/FileSystemTask.php b/freebox/api/v3/services/FileSystem/FileSystemTask.php
index ac82642..b5b5716 100644
--- a/freebox/api/v3/services/FileSystem/FileSystemTask.php
+++ b/freebox/api/v3/services/FileSystem/FileSystemTask.php
@@ -1,6 +1,6 @@
getAuthService( self::API_FS_TASK);
$rest->GET();
- $FsTask_xs = $rest->getCurlResponse()['result'];
- $FsTasks = [];
- foreach( $FsTask_xs as $fsTask_x) {
- $FsTasks[] = new FsTask( $fsTask_x);
- }
- return $FsTasks;
+ return $rest->getResultAsArray( models\FileSystem\FsTask::class);
}
/**
* @param int $TaskId
- * @return FsTask
+ * @return models\FileSystem\FsTask
*/
public function getTaskById( $TaskId){
$rest = $this->getAuthService( self::API_FS_TASK . $TaskId);
$rest->GET();
- return new FsTask( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\FileSystem\FsTask::class);
}
/**
- * @param FsTask $FsTask
+ * @param models\FileSystem\FsTask $FsTask
* @return bool
*/
- public function deleteTask( FsTask $FsTask){
+ public function deleteTask( models\FileSystem\FsTask $FsTask){
return $this->deleteTaskById( $FsTask->getId());
}
@@ -55,18 +50,18 @@ class FileSystemTask extends Service {
$rest = $this->getAuthService( self::API_FS_TASK . $TaskId);
$rest->DELETE();
- return $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
/**
- * @param FsTask $FsTask
+ * @param models\FileSystem\FsTask $FsTask
* @return bool
*/
- public function updateTask( FsTask $FsTask){
+ public function updateTask( models\FileSystem\FsTask $FsTask){
$rest = $this->getAuthService( self::API_FS_TASK . $FsTask->getId());
- $rest->PUT( $FsTask->toArray());
+ $rest->PUT( $FsTask);
- return $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
}
diff --git a/freebox/api/v3/services/FileSystem/FileUpload.php b/freebox/api/v3/services/FileSystem/FileUpload.php
index 69f5413..9153050 100644
--- a/freebox/api/v3/services/FileSystem/FileUpload.php
+++ b/freebox/api/v3/services/FileSystem/FileUpload.php
@@ -28,7 +28,7 @@ class FileUpload extends Service {
'upload_name' => $FileName,
]);
- return (int) $rest->getCurlResponse()['result']['id'];
+ return (int) $rest->getResult()['id'];
}
/**
@@ -45,7 +45,7 @@ class FileUpload extends Service {
basename( $fileToUpload_afi) => new \CurlFile( $fileToUpload_afi),
]);
- return $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
/**
@@ -56,12 +56,7 @@ class FileUpload extends Service {
$rest = $this->getAuthService( self::API_UPLOAD);
$rest->GET();
- $FileUpload_xs = @$rest->getCurlResponse()['result'] ?: [];
- $FileUploads = [];
- foreach( $FileUpload_xs as $FileUpload_x) {
- $FileUploads[] = new models\FileSystem\FileUpload( $FileUpload_x);
- }
- return $FileUploads;
+ return $rest->getResultAsArray( models\FileSystem\FileUpload::class);
}
/**
@@ -73,7 +68,7 @@ class FileUpload extends Service {
$rest = $this->getAuthService( self::API_UPLOAD . $FileUploadId);
$rest->GET();
- return new models\FileSystem\FileUpload( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\FileSystem\FileUpload::class);
}
/**
@@ -87,7 +82,7 @@ class FileUpload extends Service {
$rest = $this->getAuthService( $Service);
$rest->DELETE();
- return $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
/**
@@ -99,7 +94,7 @@ class FileUpload extends Service {
$rest = $this->getAuthService( self::API_UPLOAD . $FileUploadId);
$rest->DELETE();
- return $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
/**
@@ -110,7 +105,7 @@ class FileUpload extends Service {
$rest = $this->getAuthService( self::API_UPLOAD_CLEAN);
$rest->DELETE();
- return $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
}
diff --git a/freebox/api/v3/services/download/BlackList.php b/freebox/api/v3/services/download/BlackList.php
index 99f2785..d47ba97 100644
--- a/freebox/api/v3/services/download/BlackList.php
+++ b/freebox/api/v3/services/download/BlackList.php
@@ -28,12 +28,7 @@ class BlackList extends Service {
$rest = $this->getAuthService( $service);
$rest->GET();
- $BlackListEntry_xs = @$rest->getCurlResponse()['result'] ?: [];
- $BlackListEntries = [];
- foreach( $BlackListEntry_xs as $BlackListEntry_x) {
- $BlackListEntries[] = new models\Download\BlackListEntry( $BlackListEntry_x);
- }
- return $BlackListEntries;
+ return $rest->getResultAsArray( models\Download\BlackListEntry::class);
}
/**
@@ -47,7 +42,7 @@ class BlackList extends Service {
$rest = $this->getAuthService( $service);
$rest->DELETE();
- return $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
/**
@@ -60,7 +55,7 @@ class BlackList extends Service {
$rest = $this->getAuthService( $service);
$rest->DELETE();
- return $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
/**
@@ -76,7 +71,7 @@ class BlackList extends Service {
'expire' => $expire,
]);
- return new models\Download\BlackListEntry( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\Download\BlackListEntry::class);
}
}
diff --git a/freebox/api/v3/services/download/Configuration.php b/freebox/api/v3/services/download/Configuration.php
index 5d880fb..3887b08 100644
--- a/freebox/api/v3/services/download/Configuration.php
+++ b/freebox/api/v3/services/download/Configuration.php
@@ -20,7 +20,7 @@ class Configuration extends Service {
$rest = $this->getAuthService( self::API_DOWNLOAD_CONFIG);
$rest->GET();
- return new models\Download\Config\DownloadConfig( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\Download\Config\DownloadConfig::class);
}
/**
@@ -32,7 +32,7 @@ class Configuration extends Service {
$rest = $this->getAuthService( self::API_DOWNLOAD_CONFIG);
$rest->PUT( $downloadConfig->toArray());
- return new models\Download\Config\DownloadConfig( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\Download\Config\DownloadConfig::class);
}
/**
@@ -49,7 +49,7 @@ class Configuration extends Service {
'throttling' => $throttlingMode,
]);
- return $rest->getCurlResponse()['result'];
+ return $rest->getSuccess();
}
}
diff --git a/freebox/api/v3/services/download/Download.php b/freebox/api/v3/services/download/Download.php
index eebca04..6875c49 100644
--- a/freebox/api/v3/services/download/Download.php
+++ b/freebox/api/v3/services/download/Download.php
@@ -26,12 +26,7 @@ class Download extends Service {
$rest = $this->getAuthService( self::API_DOWNLOAD);
$rest->GET();
- $DownloadTask_xs = @$rest->getCurlResponse()['result'] ?: [];
- $DownloadTasks = [];
- foreach( $DownloadTask_xs as $DownloadTask_x) {
- $DownloadTasks[] = new models\Download\Task( $DownloadTask_x);
- }
- return $DownloadTasks;
+ return $rest->getResultAsArray( models\Download\Task::class);
}
/**
@@ -43,46 +38,46 @@ class Download extends Service {
$rest = $this->getAuthService( self::API_DOWNLOAD . $download_id);
$rest->GET();
- return new models\Download\Task( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\Download\Task::class);
}
/**
* Get the current system info
* @param int $download_id
- * @return
+ * @return string
*/
public function getLogFromId( $download_id){
$logService = sprintf( self::API_DOWNLOAD_LOG, $download_id);
$rest = $this->getAuthService( $logService);
$rest->GET();
- return $rest->getCurlResponse()['result'];
+ return $rest->getResult();
}
/**
* Delete a download task (conserve data)
* @param int $download_id
- * @return
+ * @return bool
*/
public function deleteFromId( $download_id){
$rest = $this->getAuthService( self::API_DOWNLOAD . $download_id);
$rest->DELETE();
- return $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
/**
* Delete a download task (erase data)
* @param int $download_id
- * @return
+ * @return bool
*/
public function eraseFromId( $download_id){
$eraseService = sprintf( self::API_DOWNLOAD_ERASE, $download_id);
$rest = $this->getAuthService( $eraseService);
$rest->DELETE();
- return $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
@@ -96,10 +91,11 @@ class Download extends Service {
$rest = $this->getAuthService( $eraseService);
$rest->PUT( $downloadTask->toArray());
- return new models\Download\Task( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\Download\Task::class);
}
/**
+ * Add a download task with the specified URL
* @param string $download_url
* @param string $download_dir
* @param bool|false $recursive
@@ -114,6 +110,7 @@ class Download extends Service {
}
/**
+ * Add a download task with all the specified URLs
* @param array $download_urls A list of URL
* @param string $download_dir The download destination directory (optional: will use the configuration download_dir by default)
* @param bool $recursive If true the download will be recursive
@@ -162,16 +159,16 @@ class Download extends Service {
$rest = $this->getAuthService( self::API_DOWNLOAD_ADD);
$rest->setContentType_XFormURLEncoded();
$rest->POST( $data);
- $response = $rest->getCurlResponse();
- return $response['result']['id'];
+ return $rest->getResult()['id'];
}
/**
+ * Add a download task with the specified file (torrent, nzb...)
* @param $download_file_rdi
* @param string $download_dir_rdi
* @param string $archive_password
- * @return bool
+ * @return int
*/
public function addFromFile( $download_file_rdi, $download_dir_rdi = '', $archive_password = ''){
$rest = $this->getAuthService( self::API_DOWNLOAD_ADD);
@@ -182,22 +179,22 @@ class Download extends Service {
'archive_password' => $archive_password,
]);
- return $rest->getCurlResponse()['result']['id'];
+ return $rest->getResult()['id'];
}
/**
* Returns the Download task with the given id
- * @return models\Download\Task
+ * @return models\Download\Stats\DownloadStats
*/
- public function getStats( ){
+ public function getStats(){
$rest = $this->getAuthService( self::API_DOWNLOAD_STATS);
$rest->GET();
- return new models\Download\Stats\DownloadStats( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\Download\Stats\DownloadStats::class);
}
/**
- * Returns the Download task with the given id
+ * Returns the downloaded files with the given task id
* @param int $taskId
* @return models\Download\File[]
*/
@@ -206,20 +203,16 @@ class Download extends Service {
$rest = $this->getAuthService( $Service);
$rest->GET();
- $DownloadFile_xs = @$rest->getCurlResponse()['result'] ?: [];
- $DownloadFiles = [];
- foreach( $DownloadFile_xs as $DownloadFile_x) {
- $DownloadFiles[] = new models\Download\File( $DownloadFile_x);
- }
- return $DownloadFiles;
+ return $rest->getResultAsArray( models\Download\File::class);
}
/**
+ * Update a download priority
* @param int $downloadTaskId
* @param string $FileId
* @param string $Priority
* @see alphayax\freebox\api\v3\symbols\Download\File\Priority
- * @return
+ * @return bool
*/
public function updateFilePriority( $downloadTaskId, $FileId, $Priority){
$Service = sprintf( self::API_DOWNLOAD_FILES, $downloadTaskId);
@@ -228,7 +221,7 @@ class Download extends Service {
'priority' => $Priority,
]);
- return $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
}
diff --git a/freebox/api/v3/services/download/Feed.php b/freebox/api/v3/services/download/Feed.php
index d641c55..d765a10 100644
--- a/freebox/api/v3/services/download/Feed.php
+++ b/freebox/api/v3/services/download/Feed.php
@@ -27,12 +27,7 @@ class Feed extends Service {
$rest = $this->getAuthService( self::API_DOWNLOAD_FEEDS);
$rest->GET();
- $DownloadFeed_xs = @$rest->getCurlResponse()['result'] ?: [];
- $DownloadFeeds = [];
- foreach( $DownloadFeed_xs as $DownloadFeed_x) {
- $DownloadFeeds[] = new models\Download\Feed\DownloadFeed( $DownloadFeed_x);
- }
- return $DownloadFeeds;
+ return $rest->getResultAsArray( models\Download\Feed\DownloadFeed::class);
}
/**
@@ -45,7 +40,7 @@ class Feed extends Service {
$rest = $this->getAuthService( $service);
$rest->GET();
- return new models\Download\Feed\DownloadFeed( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\Download\Feed\DownloadFeed::class);
}
/**
@@ -59,7 +54,7 @@ class Feed extends Service {
'url' => $downloadFeedUrl,
]);
- return new models\Download\Feed\DownloadFeed( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\Download\Feed\DownloadFeed::class);
}
/**
@@ -72,20 +67,20 @@ class Feed extends Service {
$rest = $this->getAuthService( $service);
$rest->DELETE();
- return (bool) $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
/**
* Update a Download Feed
- * @param \alphayax\freebox\api\v3\models\Download\Feed\DownloadFeed $downloadFeed
- * @return \alphayax\freebox\api\v3\models\Download\Feed\DownloadFeed
+ * @param models\Download\Feed\DownloadFeed $downloadFeed
+ * @return models\Download\Feed\DownloadFeed
*/
- public function updateFeed(models\Download\Feed\DownloadFeed $downloadFeed){
+ public function updateFeed( models\Download\Feed\DownloadFeed $downloadFeed){
$service = sprintf( self::API_DOWNLOAD_FEEDS_ITEM, $downloadFeed->getId());
$rest = $this->getAuthService( $service);
- $rest->PUT( $downloadFeed->toArray());
+ $rest->PUT( $downloadFeed);
- return new models\Download\Feed\DownloadFeed( $rest->getCurlResponse()['result']);
+ return $rest->getResult( models\Download\Feed\DownloadFeed::class);
}
/**
@@ -99,7 +94,7 @@ class Feed extends Service {
$rest = $this->getAuthService( $service);
$rest->POST();
- return (bool) $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
/**
@@ -111,57 +106,50 @@ class Feed extends Service {
$rest = $this->getAuthService( self::API_DOWNLOAD_FEEDS_FETCH);
$rest->POST();
- return (bool) $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
/**
* Returns the collection of all DownloadFeedItems for a given DownloadFeed
* @param $downloadFeedId
- * @return \alphayax\freebox\api\v3\models\Download\Feed\DownloadFeedItem[]
+ * @return models\Download\Feed\DownloadFeedItem[]
*/
public function getFeedItems( $downloadFeedId){
$service = sprintf( self::API_DOWNLOAD_FEEDS_ITEMS, $downloadFeedId);
$rest = $this->getAuthService( $service);
$rest->GET();
- $DownloadFeedItem_xs = @$rest->getCurlResponse()['result'] ?: [];
- $DownloadFeedItems = [];
- foreach( $DownloadFeedItem_xs as $DownloadFeedItem_x) {
- $DownloadFeedItems[] = new models\Download\Feed\DownloadFeedItem( $DownloadFeedItem_x);
- }
- return $DownloadFeedItems;
+ return $rest->getResultAsArray( models\Download\Feed\DownloadFeedItem::class);
}
/**
* Returns the collection of all DownloadFeedItems for a given DownloadFeed
- * @param $downloadFeedId
- * @param \alphayax\freebox\api\v3\models\Download\Feed\DownloadFeedItem $DownloadFeedItem
+ * @param models\Download\Feed\DownloadFeedItem $DownloadFeedItem
* @return bool
*/
- public function updateFeedItem( $downloadFeedId, models\Download\Feed\DownloadFeedItem $DownloadFeedItem){
- $service = sprintf( self::API_DOWNLOAD_FEEDS_ITEMS_ITEM, $downloadFeedId, $DownloadFeedItem->getId());
+ public function updateFeedItem( models\Download\Feed\DownloadFeedItem $DownloadFeedItem){
+ $service = sprintf( self::API_DOWNLOAD_FEEDS_ITEMS_ITEM, $DownloadFeedItem->getFeedId(), $DownloadFeedItem->getId());
$rest = $this->getAuthService( $service);
- $rest->PUT( $DownloadFeedItem->toArray());
+ $rest->PUT( $DownloadFeedItem);
- return (bool) $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
/**
- * Returns the collection of all DownloadFeedItems for a given DownloadFeed
- * @param $downloadFeedId
- * @param \alphayax\freebox\api\v3\models\Download\Feed\DownloadFeedItem $DownloadFeedItem
+ * Download the specified feed item
+ * @param models\Download\Feed\DownloadFeedItem $DownloadFeedItem
* @return bool
*/
- public function downloadFeedItem( $downloadFeedId, models\Download\Feed\DownloadFeedItem $DownloadFeedItem){
- $service = sprintf( self::API_DOWNLOAD_FEEDS_ITEMS_ITEM_DOWNLOAD, $downloadFeedId, $DownloadFeedItem->getId());
+ public function downloadFeedItem( models\Download\Feed\DownloadFeedItem $DownloadFeedItem){
+ $service = sprintf( self::API_DOWNLOAD_FEEDS_ITEMS_ITEM_DOWNLOAD, $DownloadFeedItem->getFeedId(), $DownloadFeedItem->getId());
$rest = $this->getAuthService( $service);
- $rest->POST( $DownloadFeedItem->toArray());
+ $rest->POST( $DownloadFeedItem);
- return (bool) $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
/**
- * Returns the collection of all DownloadFeedItems for a given DownloadFeed
+ * Mark the specified feed id as "Read"
* @param int $downloadFeedId
* @return bool
*/
@@ -170,7 +158,7 @@ class Feed extends Service {
$rest = $this->getAuthService( $service);
$rest->POST();
- return (bool) $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
}
diff --git a/freebox/api/v3/services/download/Peer.php b/freebox/api/v3/services/download/Peer.php
index 467996f..dbe0469 100644
--- a/freebox/api/v3/services/download/Peer.php
+++ b/freebox/api/v3/services/download/Peer.php
@@ -23,12 +23,7 @@ class Peer extends Service {
$rest = $this->getAuthService( $service);
$rest->GET();
- $DownloadPeer_xs = @$rest->getCurlResponse()['result'] ?: [];
- $DownloadPeers = [];
- foreach( $DownloadPeer_xs as $DownloadPeer_x) {
- $DownloadPeers[] = new models\Download\Peer( $DownloadPeer_x);
- }
- return $DownloadPeers;
+ return $rest->getResultAsArray( models\Download\Peer::class);
}
}
diff --git a/freebox/api/v3/services/download/Tracker.php b/freebox/api/v3/services/download/Tracker.php
index 0dc17e8..d19ffe5 100644
--- a/freebox/api/v3/services/download/Tracker.php
+++ b/freebox/api/v3/services/download/Tracker.php
@@ -24,12 +24,7 @@ class Tracker extends Service {
$rest = $this->getAuthService( $service);
$rest->GET();
- $DownloadTracker_xs = @$rest->getCurlResponse()['result'] ?: [];
- $DownloadTrackers = [];
- foreach( $DownloadTracker_xs as $DownloadTracker_x) {
- $DownloadTrackers[] = new models\Download\Tracker( $DownloadTracker_x);
- }
- return $DownloadTrackers;
+ return $rest->getResultAsArray( models\Download\Tracker::class);
}
/**
@@ -46,14 +41,14 @@ class Tracker extends Service {
'announce' => $announceUrl,
]);
- return (bool) $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
/**
* Remove a tracker
* Attempting to call this method on a download other than bittorent will fail
* @param int $downloadTaskId
- * @param string $announceUrl (eg: udp://tracker.openbittorrent.com:80)
+ * @param string $announceUrl (eg: udp://tracker.openbittorrent.com:80)
* @return bool
*/
public function remove( $downloadTaskId, $announceUrl) {
@@ -61,7 +56,7 @@ class Tracker extends Service {
$rest = $this->getAuthService( $service);
$rest->DELETE();
- return (bool) $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
/**
@@ -75,9 +70,9 @@ class Tracker extends Service {
public function update( $downloadTaskId, $announceUrl, models\Download\Tracker $Tracker) {
$service = sprintf( self::API_DOWNLOAD_TRACKER_ITEM, $downloadTaskId, $announceUrl);
$rest = $this->getAuthService( $service);
- $rest->PUT( $Tracker->toArray());
+ $rest->PUT( $Tracker);
- return (bool) $rest->getCurlResponse()['success'];
+ return $rest->getSuccess();
}
}