php-extended/php-api-fr-gouv-finances-mioga-object

A library that implements the php-extended/php-api-fr-gouv-finances-mioga-interface library


README

A php API wrapper to connect to mioga.finances.gouv.fr instances

coverage build status

Installation

The installation of this library is made via composer and the autoloading of all classes of this library is made through their autoloader.

  • Download composer.phar from their website.
  • Then run the following command to install this library as dependency :
  • php composer.phar php-extended/php-api-fr-gouv-finances-mioga-object ^7

Supported Functionnalities

FunctionnalityStatusMain method
Global.LoginImplementedMiogaEndpoint->login()
Magellan.Folder.CreateImplementedMiogaFolder->createChildFolder()
Magellan.Folder.BrowseImplementedMiogaFolder->hasFile()
Magellan.Folder.RenameImplementedMiogaFolder->rename()
Magellan.Folder.DeleteImplementedMiogaFolder->delete()
Magellan.Folder.CopyImplementedMiogaFolder->copyTo()
Magellan.Folder.MoveImplementedMiogaFolder->moveTo()
Magellan.Folder.ZDDownloadImplementedMiogaFolder->zipDownload()
Magellan.Folder.ZSDownloadImplementedMiogaFolder->zipDownloadToStream()
Magellan.File.UploadImplementedMiogaFolder->uploadFile()
Magellan.File.ZUploadImplementedMiogaFolder->uploadZipFileAndDecompress()
Magellan.File.RenameImplementedMiogaFile->rename()
Magellan.File.DeleteImplementedMiogaFile->delete()
Magellan.File.CopyImplementedMiogaFile->copyTo()
Magellan.File.MoveImplementedMiogaFile->moveTo()
Magellan.File.LockImplementedMiogaFile->lock()
Magellan.File.UnlockImplementedMiogaFile->unlock()
Magellan.File.DDownloadImplementedMiogaFile->download()
Magellan.File.SDownloadImplementedMiogaFile->downloadToStream()
Magellan.MassDownloadImplementedMiogaEndpoint->downloadSynchronize()
Magellan.MassUploadImplementedMiogaEndpoint->uploadSynchronize()
Bottin.User.AddImplementedMiogaBottinEndpoint->addUser()
Bottin.User.DeleteImplementedMiogaBottinEndpoint->removeUser()
Bottin.User.ListImplementedMiogaBottinEndpoint->getUserData()
Bottin.User.EnableImplementedMiogaBottinEndpoint->enableUser()
Bottin.User.DisableImplementedMiogaBottinEndpoint->disableUser()
Bottin.Status.ListImplementedMiogaBottinEndpoint->getUserStatuses()

Basic Usage

Globally, all methods throw \PhpExtended\MiogaFinancesGouvFrApi\MiogaException exceptions if something goes wrong. It may be connection issues, or parameter issues, or server issues, or anything else.

Global.Login

This functionnality performs login and persistent session management for a specific account.


use PhpExtended\Endpoint\HttpEndpoint;
use PhpExtended\Endpoint\HttpJsonEndpoint;
use PhpExtended\MiogaFinancesGouvFrApi\MiogaEndpoint;

/* @var $client \Psr\Http\Client\ClientInterface */

$endpoint = new MiogaEndpoint(new HttpJsonEndpoint(new HttpEndpoint($client)));

The creation of the proxy object is the only thing needed to log in. The login is not done at the instanciation of the object, before the first request for useful information in the instance.

Magellan.Folder.Create

This functionnality performs creating a directory under a specific directory.


$folder->createFolder('<subfolder name>');

This method creates a folder or throws an exception trying.

Magellan.Folder.Browse

This functionnality performs listing of files and directories under a specific directory.


$folder = $mioga->getFolder($path);

This method returns a MiogaFolder object or throws an exception trying.

Magellan.Folder.Rename

This functionnality performs renaming of a specific directory.


$folder->rename('<new name>');

This renames the folder or throws an exception trying. Warning, once this folder is renamed, the node is invalid and all of its hierarchy should be considered dead nodes. You must discard the reference to current node and get a new one from the parent folder.

Magellan.Folder.Delete

This functionnality performs deletion of a specific directory and all of its subhierarchy.


$folder->delete();

This deletes the folder or throws an exception trying. Warning, once this folder is deleted, the node is invalid. The hierarchy should be reloaded from parent folder.

Magellan.Folder.Copy

This functionnality performs copy of a specific directory and all of its subhierarchy into another directory.


$folder->copyFolderToFolder($otherFolder);

This copies the whole hierarchy or throws an exception trying.

Magellan.Folder.Move

This functionnality performs move of a specifyc directory and all of its subhierarchy into another directory.


$folder->moveFolderToFolder($otherFolder);

This moves (cut and paste) the whole hierarchy or throws an exception trying. Warning, once this folder is moved, the node is invalid. The hierarchy should be reloaded from parent folder. You must discard the reference to current node and get a new one from the parent folder.

Magellan.Folder.ZDDownload

This functionnality performs direct download of the target folder. The folder and all of its file hierarchy is compressed into a zip file.


$data = $folder->zipDownload();

The zipDownload method on this object returns the raw data of the zip file representing the downloaded folder. WARNING : this method downloads the whole file into memory and can break the memory limit on large files. It is thus recommanded to use the streaming download method instead.

Magellan.Folder.ZSDownload

This functionnality performs streaming download of the target folder. The folder and all of its file hierarchy is compressed into a zip file.


$stream = fopen($localpath);
$folder->zipDownloadToStream($stream);

The zipDownloadToStream method on this object returns nothing but executes the streaming download by downloading the zip file to the given output stream. This method is blocking.

Magellan.File.Upload

This functionnality performs uploading of a file from a given path on the real file system.


$folder->uploadFile($filePath);

This method uploads the file at the $filePath location, or throws an exception trying. It also throws exceptions if the file does not exists at given path.

Magellan.File.ZUpload

This functionnality performs uploading of a zip file from a given path on the real file system and unzips it into the filesystem.


$folder->uploadZipFileAndUncompress($filePath);

This method uploads the file at the $filePath location, or throws an exception trying. It also throws exception if the file does not exists at given path, or if the file cannot be uncompressed.

Magellan.File.Rename

This functionnality performs renaming of a specific file.


$file->rename('<new name>');

This renames the file or throws an exception trying. Warning, once this file is renamed, the node is invalid. The hierarchy should be reloaded from parent folder. You must discard the reference to current node and get a new one from the parent folder.

Magellan.File.Delete

This functionnality performs deletion of a specific file.


$file->delete();

This deletes the file or throws an exception trying. Warning, once this file is deleted, the node is invalid. The hierarchy should be reloaded from parent folder.

Magellan.File.Copy

This functionnality performs copy of a specific file into another directory.


$file->copyFileToFolder($otherFolder);

This copies the file or throws an exception trying.

Magellan.File.Move

This functionnality performs move of a specifyc file into another directory.


$file->moveFileToFolder($otherFolder);

This moves (cut and paste) the file or throws an exception trying. Warning, once this file is moved, the node is invalid. The hierarchy should be reloaded from parent folder. You must discard the reference to current node and get a new one from the parent folder.

Magellan.File.Lock

This functionnality performs locking of a specific file.


$file->lock();

This locks the file or throws an exception trying.

Magellan.File.Unlock

This functionnality performs unlocking of a specific file.


$file->unlock();

This unlocks the file or throws an exception trying.

Magellan.File.DDownload

This functionnality performs direct download of the target file.


$data = $file->download();

The download method on the MiogaFile object returns the raw data of the file. WARNING : this method downloads the whole file into memory and can break the memory limit on large files. It is thus recommanded to use the streaming download method instead.

Magellan.File.SDownload

This functionnality performs streaming download of the target file.


$stream = fopen($localpath);
$file->downloadToStream($stream);

The downloadToStream method on this object returns nothing but executes the streaming download by downloading the file to the given output stream. This method is blocking.

Magellan.MassDownload

This functionnality performs folder hierarchy synchronization between a folder into a mioga instance and a local folder, by downloading recursively all files from the remote server and saving them into the local folder hierarchy.


$endpoint->downloadSynchronize($miogaFolder, $localFolder);

This method tries to download all the files and write them into the filesystem or throws an exception trying.

Magellan.MassUpload

This functionnality performs folder hierarchy synchronization between a local folder and a folder into a mioga instance, by uploading recursively all files from the local folder hierarchy into the remote server.


$endpoint->uploadSynchronize($localFolder, $miogaFolder);

This method tries to upload all the files and write them into the filesystem or throws an exception trying.

Bottin.User.Add

This functionnality performs adding of a specific user.


$bottinApi->addUser($user_email);

This method throws a MiogaException if the user cannot be found in the ldap by its email, returns true if the process succeeds, and false if it fails.

Bottin.User.Delete

This functionnality performs deletion of a specific user.


$bottinApi->deleteUser($miogaUser);

This method deletes the given user or throws an exception trying.

Bottin.User.List

This functionnality performs listing of all the available users.


$userList = $bottinApi->getUserData();

// to be able to get specific users, do:
foreach($userList as $user)
{
	/* @var $user \PhpExtended\MiogaFinancesGouvFrApi\Bottin\MiogaUser */
	// do something
}

This method returns all the users or throws an exception trying.

Bottin.User.Enable

This functionnality reactivates a disabled user.


$bottinApi->enableUser($miogaUser);

This method returns true on success, false on failure, and throws an exception in case of server failure.

Bottin.User.Disable

This functionnality disactivates an active user.


$bottinApi->disableUser($miogaUser);

This method returns true on success, false on failure, and throws an exception in case of server failure.

Bottin.Status.List

This functionnality performs listing of all the available statuses.


$statusList = $bottinApi->getUserStatuses();

// to be able to compare with existing statuses, do:
foreach($statusList as $status)
{
	/* @var $status \PhpExtended\MiogaFinancesGouvFrApi\Bottin\MiogaStatus */
	if($status->getIdent() === '<value to compare>')
	{
		// do something
	}
}

This method returns all the user statuses or throws an exception trying.

License

MIT (See license file).