Finished user endpoints, started zone ones.
This commit is contained in:
15
src/Endpoints/EndpointException.php
Normal file
15
src/Endpoints/EndpointException.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: junade
|
||||
* Date: 06/06/2017
|
||||
* Time: 14:24
|
||||
*/
|
||||
|
||||
namespace Cloudflare\API\Endpoints;
|
||||
|
||||
|
||||
class EndpointException extends \Exception
|
||||
{
|
||||
|
||||
}
|
||||
@@ -19,10 +19,26 @@ class User implements API
|
||||
$this->adapter = $adapter;
|
||||
}
|
||||
|
||||
public function getUserDetails()
|
||||
public function getUserDetails(): \stdClass
|
||||
{
|
||||
$user = $this->adapter->get('user', []);
|
||||
$body = json_decode($user->getBody());
|
||||
var_dump($body);
|
||||
return $body->result;
|
||||
}
|
||||
|
||||
public function getUserID(): string
|
||||
{
|
||||
return ($this->getUserDetails())->id;
|
||||
}
|
||||
|
||||
public function getUserEmail(): string
|
||||
{
|
||||
return ($this->getUserDetails())->email;
|
||||
}
|
||||
|
||||
public function updateUserDetails(array $details): \stdClass
|
||||
{
|
||||
$response = $this->adapter->patch("user", [], $details);
|
||||
return json_decode($response->getBody());
|
||||
}
|
||||
}
|
||||
39
src/Endpoints/Zones.php
Normal file
39
src/Endpoints/Zones.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: junade
|
||||
* Date: 06/06/2017
|
||||
* Time: 15:45
|
||||
*/
|
||||
|
||||
namespace Cloudflare\API\Endpoints;
|
||||
|
||||
use Cloudflare\API\Adapter\Adapter;
|
||||
|
||||
class Zones implements API
|
||||
{
|
||||
private $adapter;
|
||||
|
||||
public function __construct(Adapter $adapter)
|
||||
{
|
||||
$this->adapter = $adapter;
|
||||
}
|
||||
|
||||
public function addZone(string $name, bool $jumpstart = false, string $organizationID = ''): \stdClass
|
||||
{
|
||||
$options = [
|
||||
'name' => $name,
|
||||
'jumpstart' => $jumpstart
|
||||
];
|
||||
|
||||
if (!empty($organizationID)) {
|
||||
$organization = new \stdClass();
|
||||
$organization->id = $organizationID;
|
||||
$options["organization"] = $organization;
|
||||
}
|
||||
|
||||
$user = $this->adapter->post('zones', [], $options);
|
||||
$body = json_decode($user->getBody());
|
||||
return $body->result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user