parent
b1d76be281
commit
0f7df821e3
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\dhcp;
|
||||
namespace alphayax\freebox\api\v3\config;
|
||||
use alphayax\freebox\api\v3\Service;
|
||||
|
||||
|
||||
|
@ -19,12 +19,7 @@ class DHCP extends Service {
|
|||
$rest = $this->getAuthService( self::API_DHCP_CONFIG);
|
||||
$rest->GET();
|
||||
|
||||
$response = $rest->getCurlResponse();
|
||||
if( ! $response->success){
|
||||
throw new \Exception( __FUNCTION__ . ' Fail');
|
||||
}
|
||||
|
||||
return $response;
|
||||
return $rest->getCurlResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,15 +29,9 @@ class DHCP extends Service {
|
|||
*/
|
||||
public function set_attribute_configuration( $new_config_x = []){
|
||||
$rest = $this->getAuthService( self::API_DHCP_CONFIG);
|
||||
$rest->setSessionToken( $this->application->getSessionToken());
|
||||
$rest->PUT( $new_config_x);
|
||||
|
||||
$response = $rest->getCurlResponse();
|
||||
if( ! $response->success){
|
||||
throw new \Exception( __FUNCTION__ . ' Fail');
|
||||
}
|
||||
|
||||
return $response;
|
||||
return $rest->getCurlResponse();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\utils;
|
||||
use alphayax;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -7,33 +8,45 @@ namespace alphayax\freebox\utils;
|
|||
* @package alphayax\utils
|
||||
* @author <alphayax@gmail.com>
|
||||
*/
|
||||
class RestAuth extends \alphayax\utils\Rest {
|
||||
class RestAuth extends alphayax\utils\Rest {
|
||||
|
||||
/** @var string */
|
||||
protected $session_token = '';
|
||||
|
||||
/**
|
||||
*
|
||||
* @param null $curl_post_data
|
||||
*/
|
||||
public function GET(){
|
||||
public function GET( $curl_post_data = null){
|
||||
$this->add_XFbxAppAuth_Header();
|
||||
parent::GET();
|
||||
parent::GET( $curl_post_data);
|
||||
$this->checkResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $curl_post_data
|
||||
*/
|
||||
public function POST( $curl_post_data){
|
||||
public function POST( $curl_post_data = null){
|
||||
$this->add_XFbxAppAuth_Header();
|
||||
parent::POST( $curl_post_data);
|
||||
$this->checkResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $curl_post_data
|
||||
*/
|
||||
public function PUT( $curl_post_data){
|
||||
public function PUT( $curl_post_data = null){
|
||||
$this->add_XFbxAppAuth_Header();
|
||||
parent::PUT( $curl_post_data);
|
||||
$this->checkResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $curl_post_data
|
||||
*/
|
||||
public function DELETE( $curl_post_data = null){
|
||||
$this->add_XFbxAppAuth_Header();
|
||||
parent::DELETE( $curl_post_data);
|
||||
$this->checkResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,10 +58,20 @@ class RestAuth extends \alphayax\utils\Rest {
|
|||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function checkResponse(){
|
||||
$response = $this->getCurlResponse();
|
||||
if( false === $response->success){
|
||||
throw new \Exception( $response->msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $session_token
|
||||
*/
|
||||
public function setSessionToken($session_token){
|
||||
public function setSessionToken( $session_token){
|
||||
$this->session_token = $session_token;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue