Skip to content

Commit

Permalink
Implement API v4/FileSystem (except FileUpload)
Browse files Browse the repository at this point in the history
Deprecation of major part of v3/FileSystem Services
Fix bug in Directory listing (optional parameters was ignored)
  • Loading branch information
alphayax committed Mar 31, 2018
1 parent ca3cae0 commit c2a523c
Show file tree
Hide file tree
Showing 24 changed files with 1,416 additions and 19 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# Freebox v6 PHP API v3
# Freebox v6 PHP API v3/v4

![stable](https://poser.pugx.org/alphayax/freebox_api_php/v/stable)
![unstable](https://poser.pugx.org/alphayax/freebox_api_php/v/unstable)
Expand All @@ -13,7 +13,9 @@
[![Total Downloads](https://poser.pugx.org/alphayax/freebox_api_php/downloads)](https://packagist.org/packages/alphayax/freebox_api_php)


Implementation PHP de l'API de la freebox (dans sa version 3).
Implementation PHP de l'API de la freebox
- Intégralement dans sa version 3
- Partiellement dans sa version 4

## Prérequis

Expand Down
2 changes: 1 addition & 1 deletion exemple/FileSystem/fileSharingLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
$App->openSession();

/// Scan files in root
$FileSharingLinkService = new \alphayax\freebox\api\v3\services\FileSystem\FileSharingLink( $App);
$FileSharingLinkService = new \alphayax\freebox\api\v4\services\FileSystem\FileSharingLink( $App);
$Links = $FileSharingLinkService->getAll();
var_dump( $Links);

Expand Down
7 changes: 1 addition & 6 deletions exemple/FileSystem/fileUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@
$App->authorize();
$App->openSession();

$FileUploadService = new \alphayax\freebox\api\v3\services\FileSystem\FileUpload( $App);

$authID = $FileUploadService->createAuthorization('/Disque dur/Vidéos/', 'Game.of.Thrones.S06E05.SUBFRENCH.1080i.HDTV.H264-LiBERTY.mkv');
$success = $FileUploadService->uploadFile( $authID, '/home/alphayax/Game.of.Thrones.S06E05.SUBFRENCH.1080i.HDTV.H264-LiBERTY.mkv');
print_r( $success); // 1939839620

$FileUploadService = new \alphayax\freebox\api\v4\services\FileSystem\FileUpload( $App);

$AllUploads = $FileUploadService->getAll();
print_r( $AllUploads);
Expand Down
2 changes: 1 addition & 1 deletion exemple/FileSystem/fsListing.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
$App->openSession();

/// Scan files in root
$FSListService = new \alphayax\freebox\api\v3\services\FileSystem\FileSystemListing( $App);
$FSListService = new \alphayax\freebox\api\v4\services\FileSystem\FileSystemListing( $App);
$FilesInRoot = $FSListService->getFilesFromDirectory( '/');
print_r( $FilesInRoot);

Expand Down
4 changes: 2 additions & 2 deletions exemple/FileSystem/fsOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
$App->authorize();
$App->openSession();

$FSListService = new \alphayax\freebox\api\v3\services\FileSystem\FileSystemOperation( $App);
$FSListService = new \alphayax\freebox\api\v4\services\FileSystem\FileSystemOperation( $App);

/// Uncomment following lines and give existing file names to test
/*
Expand Down Expand Up @@ -48,7 +48,7 @@

/*
sleep(1);
$Task = new \alphayax\freebox\api\v3\services\FileSystem\FileSystemTask($App);
$Task = new \alphayax\freebox\api\v4\services\FileSystem\FileSystemTask($App);
$a = $Task->getTaskById($e->getId());
var_dump( $a);
*/
4 changes: 4 additions & 0 deletions freebox/api/v3/services/FileSystem/FileSharingLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class FileSharingLink extends ServiceAuth {
/**
* Retrieve all File Sharing links
* @return models\FileSystem\ShareLink[]
* @deprecated use v4 service
*/
public function getAll(){
$rest = $this->getService( self::API_SHARE_LINK);
Expand All @@ -27,6 +28,7 @@ public function getAll(){
* Get a file sharing link from his token identifier
* @param $Token
* @return models\FileSystem\ShareLink
* @deprecated use v4 service
*/
public function getFromToken( $Token){
$rest = $this->getService( self::API_SHARE_LINK . $Token);
Expand All @@ -41,6 +43,7 @@ public function getFromToken( $Token){
* No rollback is done, if a file as already been processed it will be left as is.
* @param $Token
* @return bool
* @deprecated use v4 service
*/
public function deleteFromToken( $Token){
$rest = $this->getService( self::API_SHARE_LINK . $Token);
Expand All @@ -55,6 +58,7 @@ public function deleteFromToken( $Token){
* @param int $expire
* @param string $fullUrl
* @return models\FileSystem\ShareLink
* @deprecated use v4 service
*/
public function create( $Path, $expire = 0, $fullUrl = ''){
$Path_b64 = base64_encode( $Path);
Expand Down
2 changes: 2 additions & 0 deletions freebox/api/v3/services/FileSystem/FileSystemListing.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class FileSystemListing extends ServiceAuth {
* @param bool $countSubFolder Return files and sub-folder count for folders
* @param bool $removeHidden Don’t return hidden files in directory listing
* @return models\FileSystem\FileInfo[]
* @deprecated use v4 service
*/
public function getFilesFromDirectory( $DirectoryName = '/Disque dur/', $onlyFolder = true, $countSubFolder = false, $removeHidden = true){
$Directory_b64 = base64_encode( $DirectoryName);
Expand All @@ -38,6 +39,7 @@ public function getFilesFromDirectory( $DirectoryName = '/Disque dur/', $onlyFol
* Get file information
* @param string $DirectoryName
* @return models\FileSystem\FileInfo
* @deprecated use v4 service
*/
public function getFileInformation( $DirectoryName){
$Directory_b64 = base64_encode( $DirectoryName);
Expand Down
20 changes: 20 additions & 0 deletions freebox/api/v3/services/FileSystem/FileSystemOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ private function encodePath($path)
* @param string $conflictMode
* @return models\FileSystem\FsTask
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \alphayax\freebox\Exception\FreeboxApiException
* @deprecated use v4 service
*/
public function move(array $sourceFiles, $destination, $conflictMode = 'recent')
{
Expand All @@ -80,6 +82,8 @@ public function move(array $sourceFiles, $destination, $conflictMode = 'recent')
* @param string $conflictMode : Specify how to react if destination file already exists
* @return models\FileSystem\FsTask
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \alphayax\freebox\Exception\FreeboxApiException
* @deprecated use v4 service
*/
public function copy(array $sourceFiles, $destination, $conflictMode = 'recent')
{
Expand All @@ -101,6 +105,8 @@ public function copy(array $sourceFiles, $destination, $conflictMode = 'recent')
* @param string[] $RemoveFiles
* @return models\FileSystem\FsTask
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \alphayax\freebox\Exception\FreeboxApiException
* @deprecated use v4 service
*/
public function remove(array $RemoveFiles = [])
{
Expand All @@ -124,6 +130,8 @@ public function remove(array $RemoveFiles = [])
* @param bool $isToAppend : Append to the destination
* @return models\FileSystem\FsTask
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \alphayax\freebox\Exception\FreeboxApiException
* @deprecated use v4 service
*/
public function cat(
array $fileParts,
Expand Down Expand Up @@ -155,6 +163,8 @@ public function cat(
* @param string $destination : The destination file
* @return models\FileSystem\FsTask
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \alphayax\freebox\Exception\FreeboxApiException
* @deprecated use v4 service
*/
public function archive(array $fileParts, $destination)
{
Expand All @@ -179,6 +189,8 @@ public function archive(array $fileParts, $destination)
* @param bool $isToOverwrite : Overwrites the destination
* @return models\FileSystem\FsTask
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \alphayax\freebox\Exception\FreeboxApiException
* @deprecated use v4 service
*/
public function extract($source, $destination, $password = '', $isToDelete = false, $isToOverwrite = false)
{
Expand All @@ -203,6 +215,8 @@ public function extract($source, $destination, $password = '', $isToDelete = fal
* @param bool $isToDelete : Delete par2 files after repair
* @return models\FileSystem\FsTask
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \alphayax\freebox\Exception\FreeboxApiException
* @deprecated use v4 service
*/
public function repair($source, $isToDelete = false)
{
Expand All @@ -225,6 +239,8 @@ public function repair($source, $isToDelete = false)
* @param string $hashType : The type of hash (md5, sha1, ...) - Default is md5
* @return models\FileSystem\FsTask
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \alphayax\freebox\Exception\FreeboxApiException
* @deprecated use v4 service
*/
public function computeHash($source, $hashType = 'md5')
{
Expand All @@ -245,6 +261,7 @@ public function computeHash($source, $hashType = 'md5')
* @param $fsTaskId
* @return string
* @throws \GuzzleHttp\Exception\GuzzleException
* @deprecated use v4 service
*/
public function getHashValue($fsTaskId)
{
Expand All @@ -264,6 +281,7 @@ public function getHashValue($fsTaskId)
* @return bool
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \alphayax\freebox\Exception\FreeboxApiException
* @deprecated use v4 service
*/
public function createDirectory($parentDirectory, $newDirectoryName)
{
Expand All @@ -284,6 +302,7 @@ public function createDirectory($parentDirectory, $newDirectoryName)
* @return bool
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \alphayax\freebox\Exception\FreeboxApiException
* @deprecated use v4 service
*/
public function rename($sourceFilePath, $newFileName)
{
Expand All @@ -300,6 +319,7 @@ public function rename($sourceFilePath, $newFileName)
* @param string $sourceFilePath
* @return mixed
* @throws \GuzzleHttp\Exception\GuzzleException
* @deprecated use v4 service
*/
public function download($sourceFilePath)
{
Expand Down
5 changes: 5 additions & 0 deletions freebox/api/v3/services/FileSystem/FileSystemTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class FileSystemTask extends ServiceAuth {
/**
* Retrieve all FS tasks
* @return models\FileSystem\FsTask[]
* @deprecated use v4 service
*/
public function getAllTasks(){
$rest = $this->getService( self::API_FS_TASK);
Expand All @@ -27,6 +28,7 @@ public function getAllTasks(){
* Retrieve a FS task with the specified id
* @param int $TaskId
* @return models\FileSystem\FsTask
* @deprecated use v4 service
*/
public function getTaskById( $TaskId){
$rest = $this->getService( self::API_FS_TASK . $TaskId);
Expand All @@ -39,6 +41,7 @@ public function getTaskById( $TaskId){
* Delete a FS task
* @param models\FileSystem\FsTask $FsTask
* @return bool
* @deprecated use v4 service
*/
public function deleteTask( models\FileSystem\FsTask $FsTask){
return $this->deleteTaskById( $FsTask->getId());
Expand All @@ -48,6 +51,7 @@ public function deleteTask( models\FileSystem\FsTask $FsTask){
* Delete a FS task with the specified id
* @param int $TaskId
* @return bool
* @deprecated use v4 service
*/
public function deleteTaskById( $TaskId){
$rest = $this->getService( self::API_FS_TASK . $TaskId);
Expand All @@ -60,6 +64,7 @@ public function deleteTaskById( $TaskId){
* Update a FS task
* @param models\FileSystem\FsTask $FsTask
* @return bool
* @deprecated use v4 service
*/
public function updateTask( models\FileSystem\FsTask $FsTask){
$rest = $this->getService( self::API_FS_TASK . $FsTask->getId());
Expand Down
5 changes: 5 additions & 0 deletions freebox/api/v3/services/FileSystem/FileUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public function uploadFile( $FileUploadTaskId, $fileToUpload_afi){
/**
* Get the list of uploads
* @return models\FileSystem\FileUpload[]
* @deprecated use v4 service
*/
public function getAll(){
$rest = $this->getService( self::API_UPLOAD);
Expand All @@ -63,6 +64,7 @@ public function getAll(){
* Track an upload status
* @param int $FileUploadId
* @return models\FileSystem\FileUpload
* @deprecated use v4 service
*/
public function getFromId( $FileUploadId){
$rest = $this->getService( self::API_UPLOAD . $FileUploadId);
Expand All @@ -76,6 +78,7 @@ public function getFromId( $FileUploadId){
* The upload status must be in_progress
* @param int $FileUploadId
* @return bool
* @deprecated use v4 service
*/
public function cancelFromId( $FileUploadId){
$Service = sprintf( self::API_UPLOAD_CANCEL, $FileUploadId);
Expand All @@ -89,6 +92,7 @@ public function cancelFromId( $FileUploadId){
* Delete the given FileUpload closing the connection if needed
* @param int $FileUploadId
* @return bool
* @deprecated use v4 service
*/
public function deleteFromId( $FileUploadId){
$rest = $this->getService( self::API_UPLOAD . $FileUploadId);
Expand All @@ -100,6 +104,7 @@ public function deleteFromId( $FileUploadId){
/**
* Deletes all the FileUpload not in_progress
* @return bool
* @deprecated use v4 service
*/
public function cleanTerminated(){
$rest = $this->getService( self::API_UPLOAD_CLEAN);
Expand Down
Loading

0 comments on commit c2a523c

Please sign in to comment.