Update Services & Documentation

This commit is contained in:
alphayax 2016-06-12 18:41:25 +02:00
parent 6f19bfcdb7
commit 6700b1dbb3
45 changed files with 273 additions and 287 deletions

View File

@ -68,11 +68,11 @@
| Method | Description | | Method | Description |
|---|---| |---|---|
| `getAllTasks` | | | `getAllTasks` | Retrieve all FS tasks |
| `getTaskById` | | | `getTaskById` | Retrieve a FS task with the specified id |
| `deleteTask` | | | `deleteTask` | Delete a FS task |
| `deleteTaskById` | | | `deleteTaskById` | Delete a FS task with the specified id |
| `updateTask` | | | `updateTask` | Update a FS task |
<a name="FileUpload"></a> <a name="FileUpload"></a>
## FileUpload ## FileUpload

View File

@ -17,14 +17,14 @@
| Method | Description | | Method | Description |
|---|---| |---|---|
| `getConfiguration` | | | `getConfiguration` | Return the current Filter configuration |
| `setConfiguration` | | | `setConfiguration` | Update the filter configuration |
| `getAll` | Get the list of disks | | `getAll` | Get the list of all filters |
| `getFromId` | | | `getFromId` | Get a specific filter from id |
| `update` | | | `update` | Update a filter |
| `delete` | | | `delete` | Delete a filter |
| `deleteFromId` | | | `deleteFromId` | Delete a filter with the specified id |
| `add` | | | `add` | Add a new filter |
<a name="FilterPlanning"></a> <a name="FilterPlanning"></a>
## FilterPlanning ## FilterPlanning
@ -35,5 +35,5 @@
| Method | Description | | Method | Description |
|---|---| |---|---|
| `getFromFilterId` | | | `getFromFilterId` | Get the filer planning associated with the given filter id |
| `setFromFilterId` | | | `setFromFilterId` | Update the filer planning associated with the given filter id |

View File

@ -16,4 +16,4 @@
| Method | Description | | Method | Description |
|---|---| |---|---|
| `getStats` | | | `getStats` | Return Freebox information & statistics |

View File

@ -62,4 +62,4 @@
| Method | Description | | Method | Description |
|---|---| |---|---|
| `getStatus` | Get the current Connection status | | `getStatus` | Get the current XDSL Connection status |

View File

@ -17,11 +17,11 @@
| Method | Description | | Method | Description |
|---|---| |---|---|
| `getBrowsableInterfaces` | | | `getBrowsableInterfaces` | Get all Lan interfaces |
| `getHostsFromInterface` | | | `getHostsFromInterface` | Get the LanHosts of the specified interface |
| `getHostsFromInterfaceName` | | | `getHostsFromInterfaceName` | Get the LanHosts of the specified interface name |
| `getHostFromId` | | | `getHostFromId` | Get a specific LanHost |
| `updateHostFromInterfaceId` | | | `updateHostFromInterfaceId` | Update a LanHost |
| `wakeOnLan` | Send Wake ok Lan packet to an host | | `wakeOnLan` | Send Wake ok Lan packet to an host |
<a name="LAN"></a> <a name="LAN"></a>
@ -33,5 +33,5 @@
| Method | Description | | Method | Description |
|---|---| |---|---|
| `getConfiguration` | | | `getConfiguration` | Get the current LAN configuration |
| `setConfiguration` | | | `setConfiguration` | Update the LAN configuration |

View File

@ -31,7 +31,7 @@
| Method | Description | | Method | Description |
|---|---| |---|---|
| `getAll` | Getting the list of incoming ports | | `getAll` | Getting the list of incoming ports |
| `getById` | Getting a specific incoming port | | `getFromId` | Getting a specific incoming port |
| `update` | Updating an incoming port | | `update` | Updating an incoming port |
<a name="PortForwarding"></a> <a name="PortForwarding"></a>
@ -48,4 +48,4 @@
| `update` | Update a specific port forwarding | | `update` | Update a specific port forwarding |
| `add` | Add a port forwarding | | `add` | Add a port forwarding |
| `delete` | Delete a port forwarding | | `delete` | Delete a port forwarding |
| `deleteById` | Delete a port forwarding | | `deleteById` | Delete a port forwarding with the specified id |

View File

@ -58,6 +58,6 @@
| `getFromLogin` | Gets the VPNUser with the given login | | `getFromLogin` | Gets the VPNUser with the given login |
| `add` | Creates a new VPNUser | | `add` | Creates a new VPNUser |
| `delete` | Deletes the VPNUser | | `delete` | Deletes the VPNUser |
| `deleteFromLogin` | Deletes the VPNUser | | `deleteFromLogin` | Deletes the VPNUser with the given id |
| `update` | Update a VPN Use | | `update` | Update a VPN Use |
| `getConfigurationFile` | | | `getConfigurationFile` | Generate a new configuration file & download it |

View File

@ -20,11 +20,11 @@
| Method | Description | | Method | Description |
|---|---| |---|---|
| `getAll` | | | `getAll` | Get all Access Points |
| `getFromId` | | | `getFromId` | Get a specific Access Point |
| `getAllowedCombFromId` | To be able to allow user to pick a valid channel combination for a given AP you should use the following api to retrieve the list of allowed channel combination. | | `getAllowedCombFromId` | To be able to allow user to pick a valid channel combination for a given AP you should use the following api to retrieve the list of allowed channel combination. |
| `getStationsFromId` | To be able to allow user to pick a valid channel combination for a given AP you should use the following api to retrieve the list of allowed channel combination. | | `getStationsFromId` | To be able to allow user to pick a valid channel combination for a given AP you should use the following api to retrieve the list of allowed channel combination. |
| `update` | | | `update` | Update an Access Point |
| `getNeighborsFromId` | Get the list of Neighbor seen by the AP | | `getNeighborsFromId` | Get the list of Neighbor seen by the AP |
| `refreshNeighborsScan` | WARNING during the scan the AP will be unavailable. Therefore, you should ask for user confirmation prior to launching a scan. Once launched you should wait until the ap state comes back from scanning to get updated info. | | `refreshNeighborsScan` | WARNING during the scan the AP will be unavailable. Therefore, you should ask for user confirmation prior to launching a scan. Once launched you should wait until the ap state comes back from scanning to get updated info. |
| `getChannelUsageFromId` | List Wi-Fi channels usage | | `getChannelUsageFromId` | List Wi-Fi channels usage |
@ -38,9 +38,9 @@
| Method | Description | | Method | Description |
|---|---| |---|---|
| `getAll` | Get the list of Freebox Access Points | | `getAll` | Get the list of Freebox BSS |
| `getFromId` | Get the list of Freebox Access Points | | `getFromId` | Get a specific BSS |
| `update` | Get the list of Freebox Access Points | | `update` | Update a BSS |
<a name="Config"></a> <a name="Config"></a>
## Config ## Config
@ -51,8 +51,8 @@
| Method | Description | | Method | Description |
|---|---| |---|---|
| `getConfiguration` | | | `getConfiguration` | Get the global wifi configuration |
| `setConfiguration` | | | `setConfiguration` | Update the global wifi configuration |
| `resetConfiguration` | Reset Wifi to default configuration | | `resetConfiguration` | Reset Wifi to default configuration |
<a name="MacFilter"></a> <a name="MacFilter"></a>
@ -64,12 +64,12 @@
| Method | Description | | Method | Description |
|---|---| |---|---|
| `getAll` | | | `getAll` | Get all MacFilters |
| `getFromId` | | | `getFromId` | Get a specific MacFilter |
| `update` | | | `update` | Update a MacFilter |
| `delete` | | | `delete` | Delete a MacFilter |
| `deleteFromId` | | | `deleteFromId` | Delete a MacFilter with the specified id |
| `add` | | | `add` | Add a new MacFilter |
<a name="Planning"></a> <a name="Planning"></a>
## Planning ## Planning
@ -80,5 +80,5 @@
| Method | Description | | Method | Description |
|---|---| |---|---|
| `getPlanning` | | | `getPlanning` | Get the wifi planning |
| `update` | | | `update` | Update the wifi planning |

View File

@ -61,8 +61,8 @@
| Method | Description | | Method | Description |
|---|---| |---|---|
| `getConfiguration` | | | `getConfiguration` | Get the current DHCP configuration |
| `setConfiguration` | | | `setConfiguration` | Update the DHCP configuration |
<a name="FTP"></a> <a name="FTP"></a>
## FTP ## FTP
@ -73,7 +73,7 @@
| Method | Description | | Method | Description |
|---|---| |---|---|
| `getConfiguration` | | | `getConfiguration` | Get the current FTP configuration |
| `setConfiguration` | | | `setConfiguration` | |
<a name="Freeplug"></a> <a name="Freeplug"></a>
@ -85,7 +85,7 @@
| Method | Description | | Method | Description |
|---|---| |---|---|
| `getNetworks` | Get the current system info | | `getNetworks` | Get the freeplug networks information |
| `getFromId` | Get a particular Freeplug information | | `getFromId` | Get a particular Freeplug information |
| `resetFromId` | Reset a Freeplug | | `resetFromId` | Reset a Freeplug |
@ -98,8 +98,8 @@
| Method | Description | | Method | Description |
|---|---| |---|---|
| `getConfiguration` | | | `getConfiguration` | Get the current LCD configuration |
| `setConfiguration` | | | `setConfiguration` | Update the LCD configuration |
<a name="System"></a> <a name="System"></a>
## System ## System

View File

@ -10,5 +10,5 @@ $App->openSession();
// PortForwarding // PortForwarding
$toto = new \alphayax\freebox\api\v3\services\config\NAT\IncomingPort( $App); $toto = new \alphayax\freebox\api\v3\services\config\NAT\IncomingPort( $App);
$a = $toto->getById('http'); $a = $toto->getFromId('http');
var_dump( $a); var_dump( $a);

View File

@ -14,7 +14,7 @@ class Filter extends Service {
const API_PARENTAL_FILTER = '/api/v3/parental/filter/'; const API_PARENTAL_FILTER = '/api/v3/parental/filter/';
/** /**
* @throws \Exception * Return the current Filter configuration
* @return models\ParentalControl\FilterConfig * @return models\ParentalControl\FilterConfig
*/ */
public function getConfiguration(){ public function getConfiguration(){
@ -25,6 +25,7 @@ class Filter extends Service {
} }
/** /**
* Update the filter configuration
* @param models\ParentalControl\FilterConfig $filterConfig * @param models\ParentalControl\FilterConfig $filterConfig
* @return models\ParentalControl\FilterConfig * @return models\ParentalControl\FilterConfig
*/ */
@ -36,7 +37,7 @@ class Filter extends Service {
} }
/** /**
* Get the list of disks * Get the list of all filters
* @throws \Exception * @throws \Exception
* @return models\ParentalControl\Filter[] * @return models\ParentalControl\Filter[]
*/ */
@ -48,6 +49,7 @@ class Filter extends Service {
} }
/** /**
* Get a specific filter from id
* @param int $filterId * @param int $filterId
* @return models\ParentalControl\Filter * @return models\ParentalControl\Filter
*/ */
@ -59,6 +61,7 @@ class Filter extends Service {
} }
/** /**
* Update a filter
* @param models\ParentalControl\Filter $filter * @param models\ParentalControl\Filter $filter
* @return models\ParentalControl\Filter * @return models\ParentalControl\Filter
*/ */
@ -70,6 +73,7 @@ class Filter extends Service {
} }
/** /**
* Delete a filter
* @param models\ParentalControl\Filter $filter * @param models\ParentalControl\Filter $filter
* @return bool * @return bool
*/ */
@ -78,6 +82,7 @@ class Filter extends Service {
} }
/** /**
* Delete a filter with the specified id
* @param int $filterId * @param int $filterId
* @return bool * @return bool
*/ */
@ -89,6 +94,7 @@ class Filter extends Service {
} }
/** /**
* Add a new filter
* @param models\ParentalControl\Filter $filter * @param models\ParentalControl\Filter $filter
* @return models\ParentalControl\Filter * @return models\ParentalControl\Filter
*/ */
@ -98,4 +104,5 @@ class Filter extends Service {
return $rest->getResult( models\ParentalControl\Filter::class); return $rest->getResult( models\ParentalControl\Filter::class);
} }
} }

View File

@ -12,6 +12,7 @@ class FilterPlanning extends Service {
const API_PARENTAL_FILTER_PLANNING = '/api/v3/parental/filter/%u/planning'; const API_PARENTAL_FILTER_PLANNING = '/api/v3/parental/filter/%u/planning';
/** /**
* Get the filer planning associated with the given filter id
* @param int $filterId * @param int $filterId
* @return models\ParentalControl\FilterPlanning * @return models\ParentalControl\FilterPlanning
*/ */
@ -24,6 +25,7 @@ class FilterPlanning extends Service {
} }
/** /**
* Update the filer planning associated with the given filter id
* @param \alphayax\freebox\api\v3\models\ParentalControl\FilterPlanning $filterPlanning * @param \alphayax\freebox\api\v3\models\ParentalControl\FilterPlanning $filterPlanning
* @param int $filterId * @param int $filterId
* @return \alphayax\freebox\api\v3\models\ParentalControl\FilterPlanning * @return \alphayax\freebox\api\v3\models\ParentalControl\FilterPlanning

View File

@ -11,6 +11,7 @@ class Fetch extends Service {
const API_RDD = '/api/v3/rrd/'; const API_RDD = '/api/v3/rrd/';
/** /**
* Return Freebox information & statistics
* @param string $db * @param string $db
* Name of the rrd database to read * Name of the rrd database to read
* @see alphayax\freebox\api\v3\symbols\RRD\Db * @see alphayax\freebox\api\v3\symbols\RRD\Db
@ -36,7 +37,7 @@ class Fetch extends Service {
$rest = $this->getAuthService( self::API_RDD); $rest = $this->getAuthService( self::API_RDD);
$rest->GET( $QueryParameters); $rest->GET( $QueryParameters);
return $rest->getCurlResponse()['result']; return $rest->getResult();
} }
/** /**

View File

@ -21,7 +21,7 @@ class Connection extends Service{
$rest = $this->getAuthService( self::API_CONNECTION); $rest = $this->getAuthService( self::API_CONNECTION);
$rest->GET(); $rest->GET();
return new models\Connection\Status( $rest->getCurlResponse()['result']); return $rest->getResult( models\Connection\Status::class);
} }
/** /**
@ -32,7 +32,7 @@ class Connection extends Service{
$rest = $this->getAuthService( self::API_CONNECTION_CONFIG); $rest = $this->getAuthService( self::API_CONNECTION_CONFIG);
$rest->GET(); $rest->GET();
return new models\Connection\Config( $rest->getCurlResponse()['result']); return $rest->getResult( models\Connection\Config::class);
} }
@ -43,9 +43,9 @@ class Connection extends Service{
*/ */
public function setConfiguration( models\Connection\Config $connectionConfig){ public function setConfiguration( models\Connection\Config $connectionConfig){
$rest = $this->getAuthService( self::API_CONNECTION_CONFIG); $rest = $this->getAuthService( self::API_CONNECTION_CONFIG);
$rest->PUT( $connectionConfig->toArray()); $rest->PUT( $connectionConfig);
return new models\Connection\Config( $rest->getCurlResponse()['result']); return $rest->getResult( models\Connection\Config::class);
} }
/** /**
@ -55,7 +55,7 @@ class Connection extends Service{
$rest = $this->getAuthService( self::API_CONNECTION_IPV6_CONFIG); $rest = $this->getAuthService( self::API_CONNECTION_IPV6_CONFIG);
$rest->GET(); $rest->GET();
return new models\Connection\Ipv6\Configuration( $rest->getCurlResponse()['result']); return $rest->getResult( models\Connection\Ipv6\Configuration::class);
} }
/** /**
@ -65,9 +65,9 @@ class Connection extends Service{
*/ */
public function setIPv6Configuration(models\Connection\Ipv6\Configuration $connectionIpv6Configuration){ public function setIPv6Configuration(models\Connection\Ipv6\Configuration $connectionIpv6Configuration){
$rest = $this->getAuthService( self::API_CONNECTION_IPV6_CONFIG); $rest = $this->getAuthService( self::API_CONNECTION_IPV6_CONFIG);
$rest->PUT( $connectionIpv6Configuration->toArray()); $rest->PUT( $connectionIpv6Configuration);
return new models\Connection\Ipv6\Configuration( $rest->getCurlResponse()['result']); return $rest->getResult( models\Connection\Ipv6\Configuration::class);
} }
} }

View File

@ -22,7 +22,7 @@ abstract class DynDns extends Service {
$rest = $this->getAuthService( $service); $rest = $this->getAuthService( $service);
$rest->GET(); $rest->GET();
return new models\Connection\DynDns\Status( $rest->getCurlResponse()['result']); return $rest->getResult( models\Connection\DynDns\Status::class);
} }
/** /**
@ -35,7 +35,7 @@ abstract class DynDns extends Service {
$rest = $this->getAuthService( $service); $rest = $this->getAuthService( $service);
$rest->GET(); $rest->GET();
return new models\Connection\DynDns\Config( $rest->getCurlResponse()['result']); return $rest->getResult( models\Connection\DynDns\Config::class);
} }
/** /**
@ -46,9 +46,9 @@ abstract class DynDns extends Service {
protected function setConfigFromProvider( $provider, models\Connection\DynDns\Config $config){ protected function setConfigFromProvider( $provider, models\Connection\DynDns\Config $config){
$service = sprintf( self::API_CONNECTION_DDNS_CONFIG, $provider); $service = sprintf( self::API_CONNECTION_DDNS_CONFIG, $provider);
$rest = $this->getAuthService( $service); $rest = $this->getAuthService( $service);
$rest->PUT( $config->toArray()); $rest->PUT( $config);
return new models\Connection\DynDns\Config( $rest->getCurlResponse()['result']); return $rest->getResult( models\Connection\DynDns\Config::class);
} }
/** /**
@ -70,4 +70,4 @@ abstract class DynDns extends Service {
*/ */
abstract public function setConfig( models\Connection\DynDns\Config $config); abstract public function setConfig( models\Connection\DynDns\Config $config);
} }

View File

@ -19,7 +19,7 @@ class Ftth extends Service{
$rest = $this->getAuthService( self::API_CONNECTION_FTTH); $rest = $this->getAuthService( self::API_CONNECTION_FTTH);
$rest->GET(); $rest->GET();
return new models\Connection\Ftth\Status( $rest->getCurlResponse()['result']); return $rest->getResult( models\Connection\Ftth\Status::class);
} }
} }

View File

@ -12,14 +12,14 @@ class Xdsl extends Service {
const API_CONNECTION_XDSL = '/api/v3/connection/xdsl/'; const API_CONNECTION_XDSL = '/api/v3/connection/xdsl/';
/** /**
* Get the current Connection status * Get the current XDSL Connection status
* @return models\Connection\Status * @return models\Connection\Status
*/ */
public function getStatus(){ public function getStatus(){
$rest = $this->getAuthService( self::API_CONNECTION_XDSL); $rest = $this->getAuthService( self::API_CONNECTION_XDSL);
$rest->GET(); $rest->GET();
return new models\Connection\Xdsl\XdslInfos( $rest->getCurlResponse()['result']); return $rest->getResult( models\Connection\Xdsl\XdslInfos::class);
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace alphayax\freebox\api\v3\services\config; namespace alphayax\freebox\api\v3\services\config;
use alphayax\freebox\api\v3\models\DhcpConfig; use alphayax\freebox\api\v3\models;
use alphayax\freebox\api\v3\Service; use alphayax\freebox\api\v3\Service;
@ -14,26 +14,26 @@ class DHCP extends Service {
const API_DHCP_CONFIG = '/api/v3/dhcp/config/'; const API_DHCP_CONFIG = '/api/v3/dhcp/config/';
/** /**
* @throws \Exception * Get the current DHCP configuration
* @return DhcpConfig * @return models\DhcpConfig
*/ */
public function getConfiguration(){ public function getConfiguration(){
$rest = $this->getAuthService( self::API_DHCP_CONFIG); $rest = $this->getAuthService( self::API_DHCP_CONFIG);
$rest->GET(); $rest->GET();
return new DhcpConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\DhcpConfig::class);
} }
/** /**
* @param DhcpConfig $new_DhcpConfig * Update the DHCP configuration
* @return DhcpConfig * @param models\DhcpConfig $dhcpConfig
* @throws \Exception * @return models\DhcpConfig
*/ */
public function setConfiguration( DhcpConfig $new_DhcpConfig){ public function setConfiguration( models\DhcpConfig $dhcpConfig){
$rest = $this->getAuthService( self::API_DHCP_CONFIG); $rest = $this->getAuthService( self::API_DHCP_CONFIG);
$rest->PUT( $new_DhcpConfig->toArray()); $rest->PUT( $dhcpConfig);
return new DhcpConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\DhcpConfig::class);
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace alphayax\freebox\api\v3\services\config; namespace alphayax\freebox\api\v3\services\config;
use alphayax\freebox\api\v3\models\FtpConfig; use alphayax\freebox\api\v3\models;
use alphayax\freebox\api\v3\Service; use alphayax\freebox\api\v3\Service;
@ -14,26 +14,25 @@ class FTP extends Service {
const API_FTP_CONFIG = '/api/v3/ftp/config/'; const API_FTP_CONFIG = '/api/v3/ftp/config/';
/** /**
* @throws \Exception * Get the current FTP configuration
* @return FtpConfig * @return models\FtpConfig
*/ */
public function getConfiguration(){ public function getConfiguration(){
$rest = $this->getAuthService( self::API_FTP_CONFIG); $rest = $this->getAuthService( self::API_FTP_CONFIG);
$rest->GET(); $rest->GET();
return new FtpConfig( $rest->getCurlResponse()); return $rest->getResult( models\FtpConfig::class);
} }
/** /**
* @param FtpConfig $new_configConfig * @param models\FtpConfig $ftpConfig
* @return FtpConfig * @return models\FtpConfig
* @throws \Exception
*/ */
public function setConfiguration( FtpConfig $new_configConfig){ public function setConfiguration( models\FtpConfig $ftpConfig){
$rest = $this->getAuthService( self::API_FTP_CONFIG); $rest = $this->getAuthService( self::API_FTP_CONFIG);
$rest->PUT( $new_configConfig); $rest->PUT( $ftpConfig);
return new FtpConfig( $rest->getCurlResponse()); return $rest->getResult( models\FtpConfig::class);
} }
} }

View File

@ -14,7 +14,7 @@ class Freeplug extends Service {
const API_FREEPLUG_RESET = '/api/v3/freeplug/%s/reset/'; const API_FREEPLUG_RESET = '/api/v3/freeplug/%s/reset/';
/** /**
* Get the current system info * Get the freeplug networks information
* @throws \Exception * @throws \Exception
* @return models\Freeplug\FreeplugNetwork[] * @return models\Freeplug\FreeplugNetwork[]
*/ */
@ -22,12 +22,7 @@ class Freeplug extends Service {
$rest = $this->getAuthService( self::API_FREEPLUG); $rest = $this->getAuthService( self::API_FREEPLUG);
$rest->GET(); $rest->GET();
$Network_xs = $rest->getCurlResponse()['result']; return $rest->getResultAsArray( models\Freeplug\FreeplugNetwork::class);
$Networks = [];
foreach( $Network_xs as $Network_x) {
$Networks[] = new models\Freeplug\FreeplugNetwork( $Network_x);
}
return $Networks;
} }
/** /**
@ -39,7 +34,7 @@ class Freeplug extends Service {
$rest = $this->getAuthService( self::API_FREEPLUG . $FreeplugId . DIRECTORY_SEPARATOR); $rest = $this->getAuthService( self::API_FREEPLUG . $FreeplugId . DIRECTORY_SEPARATOR);
$rest->GET(); $rest->GET();
return new models\Freeplug\Freeplug( $rest->getCurlResponse()['result']); return $rest->getResult( models\Freeplug\Freeplug::class);
} }
/** /**
@ -52,7 +47,7 @@ class Freeplug extends Service {
$rest = $this->getAuthService( $Service); $rest = $this->getAuthService( $Service);
$rest->POST(); $rest->POST();
return $rest->getCurlResponse()['success']; return $rest->getSuccess();
} }
} }

View File

@ -1,7 +1,6 @@
<?php <?php
namespace alphayax\freebox\api\v3\services\config\LAN; namespace alphayax\freebox\api\v3\services\config\LAN;
use alphayax\freebox\api\v3\models\LAN\LanHost; use alphayax\freebox\api\v3\models;
use alphayax\freebox\api\v3\models\LAN\LanInterface;
use alphayax\freebox\api\v3\Service; use alphayax\freebox\api\v3\Service;
@ -17,83 +16,74 @@ class Browser extends Service {
const API_WAKE_ON_LAN = '/api/v3/lan/wol/%s/'; const API_WAKE_ON_LAN = '/api/v3/lan/wol/%s/';
/** /**
* @throws \Exception * Get all Lan interfaces
* @return LanInterface * @return models\LAN\LanInterface
*/ */
public function getBrowsableInterfaces(){ public function getBrowsableInterfaces(){
$rest = $this->getAuthService( self::API_LAN_BROWSER_INTERFACES); $rest = $this->getAuthService( self::API_LAN_BROWSER_INTERFACES);
$rest->GET(); $rest->GET();
$LanInterface_xs = $rest->getCurlResponse()['result']; return $rest->getResultAsArray( models\LAN\LanInterface::class);
$LanInterfaces = [];
foreach( $LanInterface_xs as $LanInterface_x) {
$LanInterfaces[] = new LanInterface( $LanInterface_x);
}
return $LanInterfaces;
} }
/** /**
* @param LanInterface $lanInterface * Get the LanHosts of the specified interface
* @return LanHost[] * @param models\LAN\LanInterface $lanInterface
* @throws \Exception * @return models\LAN\LanHost[]
*/ */
public function getHostsFromInterface( LanInterface $lanInterface){ public function getHostsFromInterface( models\LAN\LanInterface $lanInterface){
return $this->getHostsFromInterfaceName( $lanInterface->getName()); return $this->getHostsFromInterfaceName( $lanInterface->getName());
} }
/** /**
* Get the LanHosts of the specified interface name
* @param string $lanInterfaceId * @param string $lanInterfaceId
* @return LanHost[] * @return models\LAN\LanHost[]
* @throws \Exception
*/ */
public function getHostsFromInterfaceName( $lanInterfaceId){ public function getHostsFromInterfaceName( $lanInterfaceId){
$service = sprintf( self::API_LAN_BROWSER_INTERFACE, $lanInterfaceId); $service = sprintf( self::API_LAN_BROWSER_INTERFACE, $lanInterfaceId);
$rest = $this->getAuthService( $service); $rest = $this->getAuthService( $service);
$rest->GET(); $rest->GET();
$LanHost_xs = $rest->getCurlResponse()['result']; return $rest->getResultAsArray( models\LAN\LanHost::class);
$LanHosts = [];
foreach( $LanHost_xs as $LanHost_x) {
$LanHosts[] = new LanHost( $LanHost_x);
}
return $LanHosts;
} }
/** /**
* Get a specific LanHost
* @param string $lanInterfaceId * @param string $lanInterfaceId
* @param string $hostId * @param string $hostId
* @return LanHost * @return models\LAN\LanHost
*/ */
public function getHostFromId( $lanInterfaceId, $hostId){ public function getHostFromId( $lanInterfaceId, $hostId){
$service = sprintf( self::API_LAN_BROWSER_HOST, $lanInterfaceId, $hostId); $service = sprintf( self::API_LAN_BROWSER_HOST, $lanInterfaceId, $hostId);
echo $service;
$rest = $this->getAuthService( $service); $rest = $this->getAuthService( $service);
$rest->GET(); $rest->GET();
return new LanHost( $rest->getCurlResponse()['result']); return $rest->getResult( models\LAN\LanHost::class);
} }
/** /**
* @param LanHost $LanHost * Update a LanHost
* @param models\LAN\LanHost $LanHost
* @param string $lanInterfaceId * @param string $lanInterfaceId
* @return LanHost * @return models\LAN\LanHost
*/ */
public function updateHostFromInterfaceId( LanHost $LanHost, $lanInterfaceId){ public function updateHostFromInterfaceId( models\LAN\LanHost $LanHost, $lanInterfaceId){
$service = sprintf( self::API_LAN_BROWSER_HOST, $lanInterfaceId, $LanHost->getId()); $service = sprintf( self::API_LAN_BROWSER_HOST, $lanInterfaceId, $LanHost->getId());
$rest = $this->getAuthService( $service); $rest = $this->getAuthService( $service);
$rest->PUT( $LanHost->toArray()); $rest->PUT( $LanHost);
return new LanHost( $rest->getCurlResponse()['result']); return $rest->getResult( models\LAN\LanHost::class);
} }
/** /**
* Send Wake ok Lan packet to an host * Send Wake ok Lan packet to an host
* @param LanInterface $lanInterface * @param models\LAN\LanInterface $lanInterface
* @param LanHost $lanHost * @param models\LAN\LanHost $lanHost
* @param string $password * @param string $password
* @return bool * @return bool
*/ */
public function wakeOnLan( LanInterface $lanInterface, LanHost $lanHost, $password = ''){ public function wakeOnLan( models\LAN\LanInterface $lanInterface, models\LAN\LanHost $lanHost, $password = ''){
$service = sprintf( self::API_WAKE_ON_LAN, $lanInterface->getName()); $service = sprintf( self::API_WAKE_ON_LAN, $lanInterface->getName());
$rest = $this->getAuthService( $service); $rest = $this->getAuthService( $service);
$rest->PUT([ $rest->PUT([
@ -101,7 +91,7 @@ class Browser extends Service {
'password' => $password, 'password' => $password,
]); ]);
return (bool) $rest->getCurlResponse()['result']; return $rest->getSuccess();
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace alphayax\freebox\api\v3\services\config\LAN; namespace alphayax\freebox\api\v3\services\config\LAN;
use alphayax\freebox\api\v3\models\LAN\LanConfig; use alphayax\freebox\api\v3\models;
use alphayax\freebox\api\v3\Service; use alphayax\freebox\api\v3\Service;
@ -13,26 +13,26 @@ class LAN extends Service {
const API_LAN_CONFIG = '/api/v3/lan/config/'; const API_LAN_CONFIG = '/api/v3/lan/config/';
/** /**
* @throws \Exception * Get the current LAN configuration
* @return LanConfig * @return models\LAN\LanConfig
*/ */
public function getConfiguration(){ public function getConfiguration(){
$rest = $this->getAuthService( self::API_LAN_CONFIG); $rest = $this->getAuthService( self::API_LAN_CONFIG);
$rest->GET(); $rest->GET();
return new LanConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\LAN\LanConfig::class);
} }
/** /**
* @param LanConfig $new_LanConfig * Update the LAN configuration
* @return LanConfig * @param models\LAN\LanConfig $lanConfig
* @throws \Exception * @return models\LAN\LanConfig
*/ */
public function setConfiguration( LanConfig $new_LanConfig){ public function setConfiguration( models\LAN\LanConfig $lanConfig){
$rest = $this->getAuthService( self::API_LAN_CONFIG); $rest = $this->getAuthService( self::API_LAN_CONFIG);
$rest->PUT( $new_LanConfig->toArray()); $rest->PUT( $lanConfig);
return new LanConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\LAN\LanConfig::class);
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace alphayax\freebox\api\v3\services\config; namespace alphayax\freebox\api\v3\services\config;
use alphayax\freebox\api\v3\models\LCDConfig; use alphayax\freebox\api\v3\models;
use alphayax\freebox\api\v3\Service; use alphayax\freebox\api\v3\Service;
/** /**
@ -12,24 +12,26 @@ class LCD extends Service {
const API_LCD_CONFIG = '/api/v3/lcd/config/'; const API_LCD_CONFIG = '/api/v3/lcd/config/';
/** /**
* @return LCDConfig * Get the current LCD configuration
* @return models\LCDConfig
*/ */
public function getConfiguration(){ public function getConfiguration(){
$rest = $this->getAuthService( self::API_LCD_CONFIG); $rest = $this->getAuthService( self::API_LCD_CONFIG);
$rest->GET(); $rest->GET();
return new LCDConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\LCDConfig::class);
} }
/** /**
* @param LCDConfig $lcdConfig * Update the LCD configuration
* @return LCDConfig * @param models\LCDConfig $lcdConfig
* @return models\LCDConfig
*/ */
public function setConfiguration( LCDConfig $lcdConfig){ public function setConfiguration( models\LCDConfig $lcdConfig){
$rest = $this->getAuthService( self::API_LCD_CONFIG); $rest = $this->getAuthService( self::API_LCD_CONFIG);
$rest->PUT( $lcdConfig->toArray()); $rest->PUT( $lcdConfig);
return new LCDConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\LCDConfig::class);
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace alphayax\freebox\api\v3\services\config\NAT; namespace alphayax\freebox\api\v3\services\config\NAT;
use alphayax\freebox\api\v3\models\NAT\DmzConfig; use alphayax\freebox\api\v3\models;
use alphayax\freebox\api\v3\Service; use alphayax\freebox\api\v3\Service;
@ -15,26 +15,25 @@ class DMZ extends Service {
/** /**
* Get the current Dmz configuration * Get the current Dmz configuration
* @throws \Exception * @return models\NAT\DmzConfig
*/ */
public function getConfiguration(){ public function getConfiguration(){
$rest = $this->getAuthService( self::API_NAT_DMZ); $rest = $this->getAuthService( self::API_NAT_DMZ);
$rest->GET(); $rest->GET();
return new DmzConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\NAT\DmzConfig::class);
} }
/** /**
* Update the current Dmz configuration * Update the current Dmz configuration
* @param DmzConfig $new_DmzConfig * @param models\NAT\DmzConfig $dmzConfig
* @return DmzConfig * @return models\NAT\DmzConfig
* @throws \Exception
*/ */
public function setConfiguration( DmzConfig $new_DmzConfig){ public function setConfiguration( models\NAT\DmzConfig $dmzConfig){
$rest = $this->getAuthService( self::API_NAT_DMZ); $rest = $this->getAuthService( self::API_NAT_DMZ);
$rest->PUT( $new_DmzConfig->toArray()); $rest->PUT( $dmzConfig);
return new DmzConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\NAT\DmzConfig::class);
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace alphayax\freebox\api\v3\services\config\NAT; namespace alphayax\freebox\api\v3\services\config\NAT;
use alphayax\freebox\api\v3\models\NAT\IncomingPortConfig; use alphayax\freebox\api\v3\models;
use alphayax\freebox\api\v3\Service; use alphayax\freebox\api\v3\Service;
@ -15,43 +15,38 @@ class IncomingPort extends Service {
/** /**
* Getting the list of incoming ports * Getting the list of incoming ports
* @throws \Exception * @throws \Exception
* @return IncomingPortConfig[] * @return models\NAT\IncomingPortConfig[]
*/ */
public function getAll(){ public function getAll(){
$rest = $this->getAuthService( self::API_NAT_INCOMING); $rest = $this->getAuthService( self::API_NAT_INCOMING);
$rest->GET(); $rest->GET();
$result = $rest->getCurlResponse()['result']; return $rest->getResultAsArray( models\NAT\IncomingPortConfig::class);
$PortForwardingList = [];
foreach( $result as $PortForwardingElement){
$PortForwardingList[] = new IncomingPortConfig( $PortForwardingElement);
}
return $PortForwardingList;
} }
/** /**
* Getting a specific incoming port * Getting a specific incoming port
* @param string $IncomingPortId * @param string $IncomingPortId
* @return IncomingPortConfig * @return models\NAT\IncomingPortConfig
*/ */
public function getById( $IncomingPortId){ public function getFromId( $IncomingPortId){
$rest = $this->getAuthService( self::API_NAT_INCOMING . $IncomingPortId); $rest = $this->getAuthService( self::API_NAT_INCOMING . $IncomingPortId);
$rest->GET(); $rest->GET();
return new IncomingPortConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\NAT\IncomingPortConfig::class);
} }
/** /**
* Updating an incoming port * Updating an incoming port
* @param IncomingPortConfig $new_IncomingPortConfig * @param models\NAT\IncomingPortConfig $incomingPortConfig
* @return IncomingPortConfig * @return models\NAT\IncomingPortConfig
* @throws \Exception * @throws \Exception
*/ */
public function update( IncomingPortConfig $new_IncomingPortConfig){ public function update( models\NAT\IncomingPortConfig $incomingPortConfig){
$rest = $this->getAuthService( self::API_NAT_INCOMING . $new_IncomingPortConfig->getId()); $rest = $this->getAuthService( self::API_NAT_INCOMING . $incomingPortConfig->getId());
$rest->PUT( $new_IncomingPortConfig->toArray()); $rest->PUT( $incomingPortConfig);
return new IncomingPortConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\NAT\IncomingPortConfig::class);
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace alphayax\freebox\api\v3\services\config\NAT; namespace alphayax\freebox\api\v3\services\config\NAT;
use alphayax\freebox\api\v3\models\NAT\PortForwardingConfig; use alphayax\freebox\api\v3\models;
use alphayax\freebox\api\v3\Service; use alphayax\freebox\api\v3\Service;
@ -16,79 +16,70 @@ class PortForwarding extends Service {
/** /**
* Getting the list of port forwarding * Getting the list of port forwarding
* @throws \Exception * @throws \Exception
* @return PortForwardingConfig[] * @return models\NAT\PortForwardingConfig[]
*/ */
public function getAll(){ public function getAll(){
$rest = $this->getAuthService( self::API_NAT_REDIR); $rest = $this->getAuthService( self::API_NAT_REDIR);
$rest->GET(); $rest->GET();
$result = $rest->getCurlResponse()['result']; return $rest->getResultAsArray( models\NAT\PortForwardingConfig::class);
$PortForwardingList = [];
foreach( $result as $PortForwardingElement){
$PortForwardingList[] = new PortForwardingConfig( $PortForwardingElement);
}
return $PortForwardingList;
} }
/** /**
* Getting a specific port forwarding * Getting a specific port forwarding
* @param $PortForwarding_id * @param $PortForwarding_id
* @return PortForwardingConfig * @return models\NAT\PortForwardingConfig
*/ */
public function getById( $PortForwarding_id){ public function getById( $PortForwarding_id){
$rest = $this->getAuthService( self::API_NAT_REDIR . $PortForwarding_id); $rest = $this->getAuthService( self::API_NAT_REDIR . $PortForwarding_id);
$rest->GET(); $rest->GET();
return new PortForwardingConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\NAT\PortForwardingConfig::class);
} }
/** /**
* Update a specific port forwarding * Update a specific port forwarding
* @param PortForwardingConfig $new_PortForwardingConfig * @param models\NAT\PortForwardingConfig $portForwardingConfig
* @return PortForwardingConfig * @return models\NAT\PortForwardingConfig
* @throws \Exception
*/ */
public function update( PortForwardingConfig $new_PortForwardingConfig){ public function update( models\NAT\PortForwardingConfig $portForwardingConfig){
$rest = $this->getAuthService( self::API_NAT_REDIR . $new_PortForwardingConfig->getId()); $rest = $this->getAuthService( self::API_NAT_REDIR . $portForwardingConfig->getId());
$rest->PUT( $new_PortForwardingConfig->toArray()); $rest->PUT( $portForwardingConfig);
return new PortForwardingConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\NAT\PortForwardingConfig::class);
} }
/** /**
* Add a port forwarding * Add a port forwarding
* @param PortForwardingConfig $new_PortForwardingConfig * @param models\NAT\PortForwardingConfig $portForwardingConfig
* @return PortForwardingConfig * @return models\NAT\PortForwardingConfig
* @throws \Exception
*/ */
public function add( PortForwardingConfig $new_PortForwardingConfig){ public function add( models\NAT\PortForwardingConfig $portForwardingConfig){
$rest = $this->getAuthService( self::API_NAT_REDIR); $rest = $this->getAuthService( self::API_NAT_REDIR);
$rest->POST( $new_PortForwardingConfig->toArray()); $rest->POST( $portForwardingConfig);
return new PortForwardingConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\NAT\PortForwardingConfig::class);
} }
/** /**
* Delete a port forwarding * Delete a port forwarding
* @param PortForwardingConfig $PortForwardingConfig * @param models\NAT\PortForwardingConfig $portForwardingConfig
* @return PortForwardingConfig * @return models\NAT\PortForwardingConfig
* @throws \Exception
*/ */
public function delete( PortForwardingConfig $PortForwardingConfig){ public function delete( models\NAT\PortForwardingConfig $portForwardingConfig){
return $this->deleteById( $PortForwardingConfig->getId()); return $this->deleteById( $portForwardingConfig->getId());
} }
/** /**
* Delete a port forwarding * Delete a port forwarding with the specified id
* @param int $PortForwardingId * @param int $PortForwardingId
* @return boolean success * @return boolean success
* @throws \Exception
*/ */
public function deleteById( $PortForwardingId){ public function deleteById( $PortForwardingId){
$rest = $this->getAuthService( self::API_NAT_REDIR . $PortForwardingId); $rest = $this->getAuthService( self::API_NAT_REDIR . $PortForwardingId);
$rest->DELETE(); $rest->DELETE();
return $rest->getCurlResponse()['success']; return $rest->getSuccess();
} }
} }

View File

@ -19,7 +19,7 @@ class Afp extends Service {
$rest = $this->getAuthService( self::API_NETWORK_SHARE_AFP); $rest = $this->getAuthService( self::API_NETWORK_SHARE_AFP);
$rest->GET(); $rest->GET();
return new models\NetworkShare\AfpConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\NetworkShare\AfpConfig::class);
} }
/** /**
@ -29,9 +29,9 @@ class Afp extends Service {
*/ */
public function setConfiguration( models\NetworkShare\AfpConfig $afpConfig){ public function setConfiguration( models\NetworkShare\AfpConfig $afpConfig){
$rest = $this->getAuthService( self::API_NETWORK_SHARE_AFP); $rest = $this->getAuthService( self::API_NETWORK_SHARE_AFP);
$rest->PUT( $afpConfig->toArray()); $rest->PUT( $afpConfig);
return new models\NetworkShare\AfpConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\NetworkShare\AfpConfig::class);
} }
} }

View File

@ -19,7 +19,7 @@ class Samba extends Service {
$rest = $this->getAuthService( self::API_NETWORK_SHARE_SAMBA); $rest = $this->getAuthService( self::API_NETWORK_SHARE_SAMBA);
$rest->GET(); $rest->GET();
return new models\NetworkShare\SambaConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\NetworkShare\SambaConfig::class);
} }
/** /**
@ -29,9 +29,9 @@ class Samba extends Service {
*/ */
public function setConfiguration( models\NetworkShare\SambaConfig $sambaConfig){ public function setConfiguration( models\NetworkShare\SambaConfig $sambaConfig){
$rest = $this->getAuthService( self::API_NETWORK_SHARE_SAMBA); $rest = $this->getAuthService( self::API_NETWORK_SHARE_SAMBA);
$rest->PUT( $sambaConfig->toArray()); $rest->PUT( $sambaConfig);
return new models\NetworkShare\SambaConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\NetworkShare\SambaConfig::class);
} }
} }

View File

@ -21,7 +21,7 @@ class Config extends Service {
$rest = $this->getAuthService( $service); $rest = $this->getAuthService( $service);
$rest->GET(); $rest->GET();
return new models\SwitchPort\Config( $rest->getCurlResponse()['result']); return $rest->getResult( models\SwitchPort\Config::class);
} }
/** /**
@ -32,9 +32,9 @@ class Config extends Service {
public function update( models\SwitchPort\Config $config){ public function update( models\SwitchPort\Config $config){
$service = sprintf( static::API_SWITCH_PORT_CONFIG, $config->getId()); $service = sprintf( static::API_SWITCH_PORT_CONFIG, $config->getId());
$rest = $this->getAuthService( $service); $rest = $this->getAuthService( $service);
$rest->PUT( $config->toArray()); $rest->PUT( $config);
return new models\SwitchPort\Config( $rest->getCurlResponse()['result']); return $rest->getResult( models\SwitchPort\Config::class);
} }
} }

View File

@ -14,14 +14,14 @@ class Stats extends Service {
/** /**
* Get a port configuration * Get a port configuration
* @param int $portId * @param int $portId
* @return \alphayax\freebox\api\v3\models\SwitchPort\Stats * @return models\SwitchPort\Stats
*/ */
public function getFromPortId( $portId){ public function getFromPortId( $portId){
$service = sprintf( static::API_SWITCH_PORT_STATS, $portId); $service = sprintf( static::API_SWITCH_PORT_STATS, $portId);
$rest = $this->getAuthService( $service); $rest = $this->getAuthService( $service);
$rest->GET(); $rest->GET();
return new models\SwitchPort\Stats( $rest->getCurlResponse()['result']); return $rest->getResult( models\SwitchPort\Stats::class);
} }
} }

View File

@ -19,7 +19,7 @@ class Status extends Service {
$rest = $this->getAuthService( self::API_SWITCH_STATUS); $rest = $this->getAuthService( self::API_SWITCH_STATUS);
$rest->GET(); $rest->GET();
return new models\SwitchPort\Status( $rest->getCurlResponse()['result']); return $rest->getResult( models\SwitchPort\Status::class);
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace alphayax\freebox\api\v3\services\config; namespace alphayax\freebox\api\v3\services\config;
use alphayax\freebox\api\v3\models\SystemConfig; use alphayax\freebox\api\v3\models;
use alphayax\freebox\api\v3\Service; use alphayax\freebox\api\v3\Service;
@ -16,25 +16,24 @@ class System extends Service {
/** /**
* Get the current system info * Get the current system info
* @throws \Exception * @return models\SystemConfig
*/ */
public function getConfiguration(){ public function getConfiguration(){
$rest = $this->getAuthService( self::API_SYSTEM); $rest = $this->getAuthService( self::API_SYSTEM);
$rest->GET(); $rest->GET();
return new SystemConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\SystemConfig::class);
} }
/** /**
* Reboot the Freebox * Reboot the Freebox
* @return array * @return bool
* @throws \Exception
*/ */
public function reboot(){ public function reboot(){
$rest = $this->getAuthService( self::API_SYSTEM_REBOOT); $rest = $this->getAuthService( self::API_SYSTEM_REBOOT);
$rest->POST(); $rest->POST();
return $rest->getCurlResponse(); return $rest->getSuccess();
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace alphayax\freebox\api\v3\services\config\UPnP; namespace alphayax\freebox\api\v3\services\config\UPnP;
use alphayax\freebox\api\v3\models\UPnP\UpnpAvConfig; use alphayax\freebox\api\v3\models;
use alphayax\freebox\api\v3\Service; use alphayax\freebox\api\v3\Service;
/** /**
@ -13,26 +13,26 @@ class AV extends Service {
/** /**
* Get the current UPnP AV configuration * Get the current UPnP AV configuration
* @return UpnpAvConfig * @return models\UPnP\UpnpAvConfig
*/ */
public function getConfiguration(){ public function getConfiguration(){
$rest = $this->getAuthService( self::API_UPNP_AV_CONFIG); $rest = $this->getAuthService( self::API_UPNP_AV_CONFIG);
$rest->GET(); $rest->GET();
return new UpnpAvConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\UPnP\UpnpAvConfig::class);
} }
/** /**
* Update the UPnP AV configuration * Update the UPnP AV configuration
* @param UpnpAvConfig $new_UpnpAvConfig * @param models\UPnP\UpnpAvConfig $upnpAvConfig
* @return UpnpAvConfig * @return models\UPnP\UpnpAvConfig
* @throws \Exception * @throws \Exception
*/ */
public function setConfiguration( UpnpAvConfig $new_UpnpAvConfig){ public function setConfiguration( models\UPnP\UpnpAvConfig $upnpAvConfig){
$rest = $this->getAuthService( self::API_UPNP_AV_CONFIG); $rest = $this->getAuthService( self::API_UPNP_AV_CONFIG);
$rest->PUT( $new_UpnpAvConfig->toArray()); $rest->PUT( $upnpAvConfig);
return new UpnpAvConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\UPnP\UpnpAvConfig::class);
} }
} }

View File

@ -1,7 +1,6 @@
<?php <?php
namespace alphayax\freebox\api\v3\services\config\UPnP; namespace alphayax\freebox\api\v3\services\config\UPnP;
use alphayax\freebox\api\v3\models\UPnP\UpnpIgdConfig; use alphayax\freebox\api\v3\models;
use alphayax\freebox\api\v3\models\UPnP\UpnpIgdRedirection;
use alphayax\freebox\api\v3\Service; use alphayax\freebox\api\v3\Service;
/** /**
@ -15,42 +14,37 @@ class IGD extends Service {
/** /**
* Get the current UPnP AV configuration * Get the current UPnP AV configuration
* @return UpnpIgdConfig * @return models\UPnP\UpnpIgdConfig
*/ */
public function getConfiguration(){ public function getConfiguration(){
$rest = $this->getAuthService( self::API_UPNP_IGD_CONFIG); $rest = $this->getAuthService( self::API_UPNP_IGD_CONFIG);
$rest->GET(); $rest->GET();
return new UpnpIgdConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\UPnP\UpnpIgdConfig::class);
} }
/** /**
* Update the UPnP AV configuration * Update the UPnP AV configuration
* @param UpnpIgdConfig $new_UpnpIgdConfig * @param models\UPnP\UpnpIgdConfig $upnpIgdConfig
* @return UpnpIgdConfig * @return models\UPnP\UpnpIgdConfig
* @throws \Exception * @throws \Exception
*/ */
public function setConfiguration( UpnpIgdConfig $new_UpnpIgdConfig){ public function setConfiguration( models\UPnP\UpnpIgdConfig $upnpIgdConfig){
$rest = $this->getAuthService( self::API_UPNP_IGD_CONFIG); $rest = $this->getAuthService( self::API_UPNP_IGD_CONFIG);
$rest->PUT( $new_UpnpIgdConfig->toArray()); $rest->PUT( $upnpIgdConfig);
return new UpnpIgdConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\UPnP\UpnpIgdConfig::class);
} }
/** /**
* Get the list of current redirection * Get the list of current redirection
* @return UpnpIgdRedirection[] * @return models\UPnP\UpnpIgdRedirection[]
*/ */
public function getRedirections(){ public function getRedirections(){
$rest = $this->getAuthService( self::API_UPNP_IGD_REDIRECTION); $rest = $this->getAuthService( self::API_UPNP_IGD_REDIRECTION);
$rest->GET(); $rest->GET();
$Redirection_xs = $rest->getCurlResponse()['result']; return $rest->getResultAsArray( models\UPnP\UpnpIgdRedirection::class);
$Redirections = [];
foreach( $Redirection_xs as $Redirection_x) {
$Redirections[] = new UpnpIgdRedirection( $Redirection_x);
}
return $Redirections;
} }
/** /**
@ -62,7 +56,7 @@ class IGD extends Service {
$rest = $this->getAuthService( self::API_UPNP_IGD_REDIRECTION . $redirectionId); $rest = $this->getAuthService( self::API_UPNP_IGD_REDIRECTION . $redirectionId);
$rest->DELETE(); $rest->DELETE();
return (bool) $rest->getCurlResponse()['success']; return $rest->getSuccess();
} }
} }

View File

@ -39,7 +39,7 @@ class Config extends Service {
*/ */
public function add( models\VPN\Client\Config\ClientConfig $config) { public function add( models\VPN\Client\Config\ClientConfig $config) {
$rest = $this->getAuthService( self::API_VPN_CLIENT_CONFIG); $rest = $this->getAuthService( self::API_VPN_CLIENT_CONFIG);
$rest->POST( $config->toArray()); $rest->POST( $config);
return $rest->getResult( models\VPN\Client\Config\ClientConfig::class); return $rest->getResult( models\VPN\Client\Config\ClientConfig::class);
} }
@ -69,7 +69,7 @@ class Config extends Service {
*/ */
public function update( models\VPN\Client\Config\ClientConfig $config) { public function update( models\VPN\Client\Config\ClientConfig $config) {
$rest = $this->getAuthService( self::API_VPN_CLIENT_CONFIG. $config->getId()); $rest = $this->getAuthService( self::API_VPN_CLIENT_CONFIG. $config->getId());
$rest->PUT( $config->toArray()); $rest->PUT( $config);
return $rest->getResult( models\VPN\Client\Config\ClientConfig::class); return $rest->getResult( models\VPN\Client\Config\ClientConfig::class);
} }

View File

@ -21,7 +21,7 @@ class Config extends Service {
$rest = $this->getAuthService( $service); $rest = $this->getAuthService( $service);
$rest->GET(); $rest->GET();
return new models\VPN\Server\Config\ServerConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\VPN\Server\Config\ServerConfig::class);
} }
/** /**
@ -32,9 +32,9 @@ class Config extends Service {
public function setConfiguration( models\VPN\Server\Config\ServerConfig $serverConfig){ public function setConfiguration( models\VPN\Server\Config\ServerConfig $serverConfig){
$service = sprintf( self::API_VPN_SERVER_CONFIG, $serverConfig->getId()); $service = sprintf( self::API_VPN_SERVER_CONFIG, $serverConfig->getId());
$rest = $this->getAuthService( $service); $rest = $this->getAuthService( $service);
$rest->PUT( $serverConfig->toArray()); $rest->PUT( $serverConfig);
return new models\VPN\Server\Config\ServerConfig( $rest->getCurlResponse()['result']); return $rest->getResult( models\VPN\Server\Config\ServerConfig::class);
} }
} }

View File

@ -42,7 +42,7 @@ class User extends Service {
*/ */
public function add( models\VPN\Server\User $user){ public function add( models\VPN\Server\User $user){
$rest = $this->getAuthService( self::API_VPN_USER); $rest = $this->getAuthService( self::API_VPN_USER);
$rest->POST( $user->toArray()); $rest->POST( $user);
return $rest->getResult( models\VPN\Server\User::class); return $rest->getResult( models\VPN\Server\User::class);
} }
@ -57,7 +57,7 @@ class User extends Service {
} }
/** /**
* Deletes the VPNUser * Deletes the VPNUser with the given id
* @param string $login * @param string $login
* @return bool * @return bool
*/ */
@ -71,16 +71,17 @@ class User extends Service {
/** /**
* Update a VPN Use * Update a VPN Use
* @param \alphayax\freebox\api\v3\models\VPN\Server\User $user * @param \alphayax\freebox\api\v3\models\VPN\Server\User $user
* @return bool * @return models\VPN\Server\User
*/ */
public function update( models\VPN\Server\User $user){ public function update( models\VPN\Server\User $user){
$rest = $this->getAuthService( self::API_VPN_USER . $user->getLogin()); $rest = $this->getAuthService( self::API_VPN_USER . $user->getLogin());
$rest->PUT( $user->toArray()); $rest->PUT( $user);
return $rest->getResult( models\VPN\Server\User::class); return $rest->getResult( models\VPN\Server\User::class);
} }
/** /**
* Generate a new configuration file & download it
* @param string $serverName * @param string $serverName
* @param string $login * @param string $login
* @return string The content of the configuration file * @return string The content of the configuration file

View File

@ -17,6 +17,7 @@ class AccessPoint extends Service {
const API_WIFI_AP_CHANNEL_USAGE = '/api/v3/wifi/ap/%u/channel_usage/'; const API_WIFI_AP_CHANNEL_USAGE = '/api/v3/wifi/ap/%u/channel_usage/';
/** /**
* Get all Access Points
* @return \alphayax\freebox\api\v3\models\WiFi\AccessPoint\AP[] * @return \alphayax\freebox\api\v3\models\WiFi\AccessPoint\AP[]
*/ */
public function getAll(){ public function getAll(){
@ -27,6 +28,7 @@ class AccessPoint extends Service {
} }
/** /**
* Get a specific Access Point
* @param int $accessPointId * @param int $accessPointId
* @return \alphayax\freebox\api\v3\models\WiFi\AccessPoint\AP * @return \alphayax\freebox\api\v3\models\WiFi\AccessPoint\AP
*/ */
@ -64,6 +66,7 @@ class AccessPoint extends Service {
} }
/** /**
* Update an Access Point
* @param $accessPoint * @param $accessPoint
* @return \alphayax\freebox\api\v3\models\WiFi\AccessPoint\AP * @return \alphayax\freebox\api\v3\models\WiFi\AccessPoint\AP
*/ */

View File

@ -1,6 +1,7 @@
<?php <?php
namespace alphayax\freebox\api\v3\services\config\WiFi; namespace alphayax\freebox\api\v3\services\config\WiFi;
use alphayax\freebox\api\v3\Service; use alphayax\freebox\api\v3\Service;
use alphayax\freebox\api\v3\models;
/** /**
* Class Bss * Class Bss
@ -11,38 +12,38 @@ class Bss extends Service {
const API_WIFI_BSS = '/api/v3/wifi/bss/'; const API_WIFI_BSS = '/api/v3/wifi/bss/';
/** /**
* Get the list of Freebox Access Points * Get the list of Freebox BSS
* @return \alphayax\freebox\api\v3\models\WiFi\Bss\Bss[] * @return models\WiFi\Bss\Bss[]
*/ */
public function getAll() { public function getAll() {
$rest = $this->getAuthService( self::API_WIFI_BSS); $rest = $this->getAuthService( self::API_WIFI_BSS);
$rest->GET(); $rest->GET();
return $rest->getResultAsArray( \alphayax\freebox\api\v3\models\WiFi\Bss\Bss::class); return $rest->getResultAsArray( models\WiFi\Bss\Bss::class);
} }
/** /**
* Get the list of Freebox Access Points * Get a specific BSS
* @param $BssId * @param $BssId
* @return \alphayax\freebox\api\v3\models\WiFi\Bss\Bss * @return models\WiFi\Bss\Bss
*/ */
public function getFromId( $BssId) { public function getFromId( $BssId) {
$rest = $this->getAuthService( self::API_WIFI_BSS . $BssId); $rest = $this->getAuthService( self::API_WIFI_BSS . $BssId);
$rest->GET(); $rest->GET();
return $rest->getResult( \alphayax\freebox\api\v3\models\WiFi\Bss\Bss::class); return $rest->getResult( models\WiFi\Bss\Bss::class);
} }
/** /**
* Get the list of Freebox Access Points * Update a BSS
* @param \alphayax\freebox\api\v3\models\WiFi\Bss\Bss $Bss * @param models\WiFi\Bss\Bss $Bss
* @return \alphayax\freebox\api\v3\models\WiFi\Bss\Bss * @return models\WiFi\Bss\Bss
*/ */
public function update( \alphayax\freebox\api\v3\models\WiFi\Bss\Bss $Bss) { public function update( models\WiFi\Bss\Bss $Bss) {
$rest = $this->getAuthService( self::API_WIFI_BSS . $Bss->getId()); $rest = $this->getAuthService( self::API_WIFI_BSS . $Bss->getId());
$rest->PUT( $Bss); $rest->PUT( $Bss);
return $rest->getResult( \alphayax\freebox\api\v3\models\WiFi\Bss\Bss::class); return $rest->getResult( models\WiFi\Bss\Bss::class);
} }
} }

View File

@ -13,6 +13,7 @@ class Config extends Service {
const API_WIFI_CONFIG_RESET = '/api/v3/wifi/config/reset/'; const API_WIFI_CONFIG_RESET = '/api/v3/wifi/config/reset/';
/** /**
* Get the global wifi configuration
* @return models\WiFi\GlobalConfig * @return models\WiFi\GlobalConfig
*/ */
public function getConfiguration(){ public function getConfiguration(){
@ -23,6 +24,7 @@ class Config extends Service {
} }
/** /**
* Update the global wifi configuration
* @param models\WiFi\GlobalConfig $globalConfig * @param models\WiFi\GlobalConfig $globalConfig
* @return models\WiFi\GlobalConfig * @return models\WiFi\GlobalConfig
*/ */

View File

@ -12,6 +12,7 @@ class MacFilter extends Service {
const API_WIFI_MAC_FILTER = '/api/v3/wifi/mac_filter/'; const API_WIFI_MAC_FILTER = '/api/v3/wifi/mac_filter/';
/** /**
* Get all MacFilters
* @return models\WiFi\MacFilter[] * @return models\WiFi\MacFilter[]
*/ */
public function getAll(){ public function getAll(){
@ -22,6 +23,7 @@ class MacFilter extends Service {
} }
/** /**
* Get a specific MacFilter
* @param $MacFilterId * @param $MacFilterId
* @return models\WiFi\MacFilter * @return models\WiFi\MacFilter
*/ */
@ -33,6 +35,7 @@ class MacFilter extends Service {
} }
/** /**
* Update a MacFilter
* @param \alphayax\freebox\api\v3\models\WiFi\MacFilter $MacFilter * @param \alphayax\freebox\api\v3\models\WiFi\MacFilter $MacFilter
* @return \alphayax\freebox\api\v3\models\WiFi\MacFilter * @return \alphayax\freebox\api\v3\models\WiFi\MacFilter
*/ */
@ -44,19 +47,18 @@ class MacFilter extends Service {
} }
/** /**
* Delete a MacFilter
* @param \alphayax\freebox\api\v3\models\WiFi\MacFilter $MacFilter * @param \alphayax\freebox\api\v3\models\WiFi\MacFilter $MacFilter
* @return \alphayax\freebox\api\v3\models\WiFi\MacFilter * @return bool
*/ */
public function delete( models\WiFi\MacFilter $MacFilter){ public function delete( models\WiFi\MacFilter $MacFilter){
$rest = $this->getAuthService( self::API_WIFI_MAC_FILTER . $MacFilter->getId()); return $this->deleteFromId( $MacFilter->getId());
$rest->PUT( $MacFilter);
return $rest->getResult( models\WiFi\MacFilter::class);
} }
/** /**
* Delete a MacFilter with the specified id
* @param $MacFilterId * @param $MacFilterId
* @return \alphayax\freebox\api\v3\models\WiFi\MacFilter * @return bool
*/ */
public function deleteFromId( $MacFilterId){ public function deleteFromId( $MacFilterId){
$rest = $this->getAuthService( self::API_WIFI_MAC_FILTER . $MacFilterId); $rest = $this->getAuthService( self::API_WIFI_MAC_FILTER . $MacFilterId);
@ -66,6 +68,7 @@ class MacFilter extends Service {
} }
/** /**
* Add a new MacFilter
* @param \alphayax\freebox\api\v3\models\WiFi\MacFilter $MacFilter * @param \alphayax\freebox\api\v3\models\WiFi\MacFilter $MacFilter
* @return \alphayax\freebox\api\v3\models\WiFi\MacFilter * @return \alphayax\freebox\api\v3\models\WiFi\MacFilter
*/ */

View File

@ -12,6 +12,7 @@ class Planning extends Service {
const API_WIFI_PLANNING = '/api/v3/wifi/planning/'; const API_WIFI_PLANNING = '/api/v3/wifi/planning/';
/** /**
* Get the wifi planning
* @return \alphayax\freebox\api\v3\models\WiFi\Planning * @return \alphayax\freebox\api\v3\models\WiFi\Planning
*/ */
public function getPlanning(){ public function getPlanning(){
@ -22,6 +23,7 @@ class Planning extends Service {
} }
/** /**
* Update the wifi planning
* @param \alphayax\freebox\api\v3\models\WiFi\Planning $planning * @param \alphayax\freebox\api\v3\models\WiFi\Planning $planning
* @return \alphayax\freebox\api\v3\models\WiFi\Planning * @return \alphayax\freebox\api\v3\models\WiFi\Planning
*/ */
@ -31,5 +33,5 @@ class Planning extends Service {
return $rest->getResult( models\WiFi\Planning::class); return $rest->getResult( models\WiFi\Planning::class);
} }
} }

View File

@ -30,7 +30,7 @@ class Configuration extends Service {
*/ */
public function setConfiguration( models\Download\Config\DownloadConfig $downloadConfig){ public function setConfiguration( models\Download\Config\DownloadConfig $downloadConfig){
$rest = $this->getAuthService( self::API_DOWNLOAD_CONFIG); $rest = $this->getAuthService( self::API_DOWNLOAD_CONFIG);
$rest->PUT( $downloadConfig->toArray()); $rest->PUT( $downloadConfig);
return $rest->getResult( models\Download\Config\DownloadConfig::class); return $rest->getResult( models\Download\Config\DownloadConfig::class);
} }

View File

@ -89,7 +89,7 @@ class Download extends Service {
public function update( models\Download\Task $downloadTask){ public function update( models\Download\Task $downloadTask){
$eraseService = sprintf( self::API_DOWNLOAD_ERASE, $downloadTask->getId()); $eraseService = sprintf( self::API_DOWNLOAD_ERASE, $downloadTask->getId());
$rest = $this->getAuthService( $eraseService); $rest = $this->getAuthService( $eraseService);
$rest->PUT( $downloadTask->toArray()); $rest->PUT( $downloadTask);
return $rest->getResult( models\Download\Task::class); return $rest->getResult( models\Download\Task::class);
} }

View File

@ -48,10 +48,10 @@ class Session extends Service {
'password' => hash_hmac( 'sha1', $this->challenge, $this->application->getAppToken()), 'password' => hash_hmac( 'sha1', $this->challenge, $this->application->getAppToken()),
]); ]);
if( ! $rest->getCurlResponse()['success']){ if( ! $rest->getSuccess()){
throw new \Exception( $rest->getCurlResponse()['error_code'] .' : '. $rest->getCurlResponse()['msg']); throw new \Exception( $rest->getCurlResponse()['error_code'] .' : '. $rest->getCurlResponse()['msg']);
} }
$this->session_token = $rest->getCurlResponse()['result']['session_token']; $this->session_token = $rest->getResult()['session_token'];
} }
/** /**