Finished user endpoints, started zone ones.

This commit is contained in:
Junade Ali
2017-06-06 17:05:21 +01:00
parent 5fcb00153b
commit bf8716e0b8
14 changed files with 957 additions and 312 deletions

View 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
{
}

View File

@@ -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
View 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;
}
}