refractor services

Add SystemConfig class
This commit is contained in:
alphayax 2016-02-03 22:09:51 +01:00
parent d021a3e2ab
commit f23cff48b1
7 changed files with 59 additions and 12 deletions

View File

@ -0,0 +1,44 @@
<?php
namespace alphayax\freebox\api\v3\models;
use alphayax\freebox\api\v3\Model;
/**
* Class SystemConfig
* @package alphayax\freebox\api\v3\models
*/
class SystemConfig extends Model {
/** @var string (Read-only) freebox firmware version */
protected $firmware_version;
/** @var string (Read-only) freebox mac address */
protected $mac;
/** @var string (Read-only) freebox serial number */
protected $serial;
/** @var string (Read-only) readable freebox uptime */
protected $uptime;
/** @var int (Read-only) freebox uptime (in seconds) */
protected $uptime_val;
/** @var string (Read-only) freebox hardware revision */
protected $board_name;
/** @var int (Read-only) temp cpum (°C) */
protected $temp_cpum;
/** @var int (Read-only) temp sw (°C) */
protected $temp_sw;
/** @var int (Read-only) temp cpub (°C) */
protected $temp_cpub;
/** @var int (Read-only) fan rpm */
protected $fan_rpm;
/** @var bool (Read-only) is the box authenticated (“étape 6”) */
protected $box_authenticated;
}

View File

@ -1,5 +1,5 @@
<?php
namespace alphayax\freebox\api\v3\config;
namespace alphayax\freebox\api\v3\services\config;
use alphayax\freebox\api\v3\models\DhcpConfig;
use alphayax\freebox\api\v3\Service;

View File

@ -1,5 +1,5 @@
<?php
namespace alphayax\freebox\api\v3\config;
namespace alphayax\freebox\api\v3\services\config;
use alphayax\freebox\api\v3\Service;

View File

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

View File

@ -1,5 +1,5 @@
<?php
namespace alphayax\freebox\api\v3\login;
namespace alphayax\freebox\api\v3\services\login;
use alphayax\freebox\api\v3\Service;
use alphayax\freebox\utils\Application;
use alphayax\utils\cli\IO;

View File

@ -1,5 +1,5 @@
<?php
namespace alphayax\freebox\api\v3\login;
namespace alphayax\freebox\api\v3\services\login;
use alphayax\freebox\api\v3\Service;
@ -8,7 +8,7 @@ use alphayax\freebox\api\v3\Service;
* @package alphayax\freebox\api\v3
* @author <alphayax@gmail.com>
*/
class Login extends Service {
class Session extends Service {
/// APIs services
const API_LOGIN = '/api/v3/login/';

View File

@ -1,6 +1,6 @@
<?php
namespace alphayax\freebox\utils;
use alphayax\freebox\api;
use alphayax\freebox\api\v3\services;
/**
* Class Application
@ -39,7 +39,7 @@ class Application {
* Ask authorization to the freebox and save the app token
*/
public function authorize(){
new api\v3\login\Authorize( $this);
new services\login\Authorize( $this);
}
/**
@ -47,7 +47,7 @@ class Application {
* @throws \Exception
*/
public function openSession(){
$Login = new api\v3\login\Login( $this);
$Login = new services\login\Session( $this);
$Login->ask_login_status();
$Login->create_session();