62 lines
No EOL
2.1 KiB
PHP
62 lines
No EOL
2.1 KiB
PHP
<?php
|
|
|
|
namespace DigiComp\HetznerDnsApi\Endpoint;
|
|
|
|
class DeleteRecord extends \DigiComp\HetznerDnsApi\Runtime\Client\BaseEndpoint implements \DigiComp\HetznerDnsApi\Runtime\Client\Endpoint
|
|
{
|
|
protected $RecordID;
|
|
/**
|
|
* Deletes a record.
|
|
*
|
|
* @param string $recordID ID of record to delete
|
|
*/
|
|
public function __construct(string $recordID)
|
|
{
|
|
$this->RecordID = $recordID;
|
|
}
|
|
use \DigiComp\HetznerDnsApi\Runtime\Client\EndpointTrait;
|
|
public function getMethod() : string
|
|
{
|
|
return 'DELETE';
|
|
}
|
|
public function getUri() : string
|
|
{
|
|
return str_replace(array('{RecordID}'), array($this->RecordID), '/records/{RecordID}');
|
|
}
|
|
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null) : array
|
|
{
|
|
return array(array(), null);
|
|
}
|
|
/**
|
|
* {@inheritdoc}
|
|
*
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\DeleteRecordUnauthorizedException
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\DeleteRecordForbiddenException
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\DeleteRecordNotFoundException
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\DeleteRecordNotAcceptableException
|
|
*
|
|
* @return null
|
|
*/
|
|
protected function transformResponseBody(string $body, int $status, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
|
|
{
|
|
if (200 === $status) {
|
|
return null;
|
|
}
|
|
if (401 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\DeleteRecordUnauthorizedException();
|
|
}
|
|
if (403 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\DeleteRecordForbiddenException();
|
|
}
|
|
if (404 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\DeleteRecordNotFoundException();
|
|
}
|
|
if (406 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\DeleteRecordNotAcceptableException();
|
|
}
|
|
}
|
|
public function getAuthenticationScopes() : array
|
|
{
|
|
return array('Auth-API-Token');
|
|
}
|
|
} |