Added extra endpoints.
This commit is contained in:
46
src/Endpoints/DNS.php
Normal file
46
src/Endpoints/DNS.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: junade
|
||||||
|
* Date: 09/06/2017
|
||||||
|
* Time: 15:14
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Cloudflare\API\Endpoints;
|
||||||
|
|
||||||
|
use Cloudflare\API\Adapter\Adapter;
|
||||||
|
|
||||||
|
class DNS implements API
|
||||||
|
{
|
||||||
|
private $adapter;
|
||||||
|
|
||||||
|
public function __construct(Adapter $adapter)
|
||||||
|
{
|
||||||
|
$this->adapter = $adapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRecord(string $zoneID, string $type, string $name, string $content, int $ttl = 0, bool $proxied = true): bool
|
||||||
|
{
|
||||||
|
$options = [
|
||||||
|
'type' => $type,
|
||||||
|
'name' => $name,
|
||||||
|
'content' => $content,
|
||||||
|
'proxied' => $proxied
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($ttl > 0) {
|
||||||
|
$options['ttl'] = $ttl;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $this->adapter->post('zones/' . $zoneID . '/dns_records', [], $options);
|
||||||
|
|
||||||
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
|
if (isset($body->result->id)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,7 +9,6 @@
|
|||||||
namespace Cloudflare\API\Endpoints;
|
namespace Cloudflare\API\Endpoints;
|
||||||
|
|
||||||
use Cloudflare\API\Adapter\Adapter;
|
use Cloudflare\API\Adapter\Adapter;
|
||||||
use Symfony\Component\Config\Definition\Exception\Exception;
|
|
||||||
|
|
||||||
class Zones implements API
|
class Zones implements API
|
||||||
{
|
{
|
||||||
@@ -123,7 +122,7 @@ class Zones implements API
|
|||||||
public function purge(string $zoneID, array $files = [], array $tags = []): bool
|
public function purge(string $zoneID, array $files = [], array $tags = []): bool
|
||||||
{
|
{
|
||||||
if (empty($files) && empty($tags)) {
|
if (empty($files) && empty($tags)) {
|
||||||
throw new Exception("No files or tags to purge.");
|
throw new EndpointException("No files or tags to purge.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$options = [
|
$options = [
|
||||||
|
|||||||
14
tests/Endpoints/DNSTest.php
Normal file
14
tests/Endpoints/DNSTest.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: junade
|
||||||
|
* Date: 09/06/2017
|
||||||
|
* Time: 15:31
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Cloudflare\API\Endpoints\DNS;
|
||||||
|
|
||||||
|
class DNSTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
22
tests/Endpoints/PageRules.php
Normal file
22
tests/Endpoints/PageRules.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: junade
|
||||||
|
* Date: 09/06/2017
|
||||||
|
* Time: 16:17
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Cloudflare\API\Adapter;
|
||||||
|
|
||||||
|
|
||||||
|
use Cloudflare\API\Endpoints\API;
|
||||||
|
|
||||||
|
class PageRules implements API
|
||||||
|
{
|
||||||
|
private $adapter;
|
||||||
|
|
||||||
|
public function __construct(Adapter $adapter)
|
||||||
|
{
|
||||||
|
$this->adapter = $adapter;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user