66 lines
No EOL
2.5 KiB
PHP
66 lines
No EOL
2.5 KiB
PHP
<?php
|
|
|
|
namespace DigiComp\HetznerDnsApi\Endpoint;
|
|
|
|
class GetRecord extends \DigiComp\HetznerDnsApi\Runtime\Client\BaseEndpoint implements \DigiComp\HetznerDnsApi\Runtime\Client\Endpoint
|
|
{
|
|
protected $RecordID;
|
|
/**
|
|
* Returns information about a single record.
|
|
*
|
|
* @param string $recordID ID of record to get
|
|
*/
|
|
public function __construct(string $recordID)
|
|
{
|
|
$this->RecordID = $recordID;
|
|
}
|
|
use \DigiComp\HetznerDnsApi\Runtime\Client\EndpointTrait;
|
|
public function getMethod() : string
|
|
{
|
|
return 'GET';
|
|
}
|
|
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);
|
|
}
|
|
public function getExtraHeaders() : array
|
|
{
|
|
return array('Accept' => array('application/json'));
|
|
}
|
|
/**
|
|
* {@inheritdoc}
|
|
*
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\GetRecordUnauthorizedException
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\GetRecordForbiddenException
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\GetRecordNotFoundException
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\GetRecordNotAcceptableException
|
|
*
|
|
* @return null|\DigiComp\HetznerDnsApi\Model\RecordsRecordIDGetResponse200
|
|
*/
|
|
protected function transformResponseBody(string $body, int $status, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
|
|
{
|
|
if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) {
|
|
return $serializer->deserialize($body, 'DigiComp\\HetznerDnsApi\\Model\\RecordsRecordIDGetResponse200', 'json');
|
|
}
|
|
if (401 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\GetRecordUnauthorizedException();
|
|
}
|
|
if (403 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\GetRecordForbiddenException();
|
|
}
|
|
if (404 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\GetRecordNotFoundException();
|
|
}
|
|
if (406 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\GetRecordNotAcceptableException();
|
|
}
|
|
}
|
|
public function getAuthenticationScopes() : array
|
|
{
|
|
return array('Auth-API-Token');
|
|
}
|
|
} |