Update Documentation & readme
Clean up & comment download & FileSystem services Refractor public functions services
This commit is contained in:
parent
13389615be
commit
af7a15c8e8
|
@ -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.*"
|
||||
|
|
|
@ -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 |
|
||||
|
||||
<a name="FileSystemListing"></a>
|
||||
|
@ -34,7 +34,7 @@
|
|||
|
||||
| Method | Description |
|
||||
|---|---|
|
||||
| `getFilesFromDirectory` | |
|
||||
| `getFilesFromDirectory` | Get all files in a given directory |
|
||||
| `getFileInformation` | Get file information |
|
||||
|
||||
<a name="FileSystemOperation"></a>
|
||||
|
@ -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) |
|
||||
|
||||
<a name="FileSystemTask"></a>
|
||||
## FileSystemTask
|
||||
|
|
|
@ -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 |
|
||||
|
||||
<a name="Feed"></a>
|
||||
## 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" |
|
||||
|
||||
<a name="Peer"></a>
|
||||
## Peer
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\services\FileSystem;
|
||||
use alphayax\freebox\api\v3\models\FileSystem\ShareLink;
|
||||
use alphayax\freebox\api\v3\models;
|
||||
use alphayax\freebox\api\v3\Service;
|
||||
|
||||
|
||||
|
@ -13,35 +13,30 @@ class FileSharingLink extends Service {
|
|||
const API_SHARE_LINK = '/api/v3/share_link/';
|
||||
|
||||
/**
|
||||
* Retrieve a File Sharing link
|
||||
* @return ShareLink[]
|
||||
* Retrieve all File Sharing links
|
||||
* @return models\FileSystem\ShareLink[]
|
||||
*/
|
||||
public function getAll(){
|
||||
$rest = $this->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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\services\FileSystem;
|
||||
use alphayax\freebox\api\v3\models\FileSystem\FileInfo;
|
||||
use alphayax\freebox\api\v3\models;
|
||||
use alphayax\freebox\api\v3\Service;
|
||||
|
||||
|
||||
|
@ -14,11 +14,12 @@ class FileSystemListing extends Service {
|
|||
const API_FS_INFO = '/api/v3/fs/info/';
|
||||
|
||||
/**
|
||||
* Get all files in a given directory
|
||||
* @param string $DirectoryName
|
||||
* @param bool $onlyFolder Only list folders
|
||||
* @param bool $countSubFolder Return files and subfolder count for folders
|
||||
* @param bool $countSubFolder Return files and sub-folder count for folders
|
||||
* @param bool $removeHidden Don’t return hidden files in directory listing
|
||||
* @return FileInfo[]
|
||||
* @return models\FileSystem\FileInfo[]
|
||||
*/
|
||||
public function getFilesFromDirectory( $DirectoryName = '/Disque dur/', $onlyFolder = true, $countSubFolder = false, $removeHidden = true){
|
||||
$Directory_b64 = base64_encode( $DirectoryName);
|
||||
|
@ -29,25 +30,20 @@ class FileSystemListing extends Service {
|
|||
'removeHidden' => $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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\services\FileSystem;
|
||||
use alphayax\freebox\api\v3\models\FileSystem\FsTask;
|
||||
use alphayax\freebox\api\v3\models;
|
||||
use alphayax\freebox\api\v3\Service;
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@ class FileSystemOperation extends Service {
|
|||
* @param string[] $sourceFiles
|
||||
* @param string $destination
|
||||
* @param string $conflictMode
|
||||
* @return FsTask
|
||||
* @return models\FileSystem\FsTask
|
||||
*/
|
||||
public function move( array $sourceFiles = [], $destination, $conflictMode = 'recent'){
|
||||
/// Convert all paths in base64
|
||||
|
@ -45,7 +45,7 @@ class FileSystemOperation extends Service {
|
|||
'mode' => $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
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\services\FileSystem;
|
||||
use alphayax\freebox\api\v3\models\FileSystem\FsTask;
|
||||
use alphayax\freebox\api\v3\models;
|
||||
use alphayax\freebox\api\v3\Service;
|
||||
|
||||
|
||||
|
@ -14,36 +14,31 @@ class FileSystemTask extends Service {
|
|||
|
||||
/**
|
||||
* @throws \Exception
|
||||
* @return FsTask[]
|
||||
* @return models\FileSystem\FsTask[]
|
||||
*/
|
||||
public function getAllTasks(){
|
||||
$rest = $this->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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue