72 lines
No EOL
2.8 KiB
PHP
72 lines
No EOL
2.8 KiB
PHP
<?php
|
|
|
|
namespace DigiComp\HetznerDnsApi\Endpoint;
|
|
|
|
class GetRecords extends \DigiComp\HetznerDnsApi\Runtime\Client\BaseEndpoint implements \DigiComp\HetznerDnsApi\Runtime\Client\Endpoint
|
|
{
|
|
/**
|
|
* Returns all records associated with user.
|
|
*
|
|
* @param array $queryParameters {
|
|
* @var string $zone_id ID of zone
|
|
* @var float $per_page Number of records to be shown per page. Returns all by default
|
|
* @var float $page A page parameter specifies the page to fetch.<br />The number of the first page is 1
|
|
* }
|
|
*/
|
|
public function __construct(array $queryParameters = array())
|
|
{
|
|
$this->queryParameters = $queryParameters;
|
|
}
|
|
use \DigiComp\HetznerDnsApi\Runtime\Client\EndpointTrait;
|
|
public function getMethod() : string
|
|
{
|
|
return 'GET';
|
|
}
|
|
public function getUri() : string
|
|
{
|
|
return '/records';
|
|
}
|
|
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'));
|
|
}
|
|
protected function getQueryOptionsResolver() : \Symfony\Component\OptionsResolver\OptionsResolver
|
|
{
|
|
$optionsResolver = parent::getQueryOptionsResolver();
|
|
$optionsResolver->setDefined(array('zone_id', 'per_page', 'page'));
|
|
$optionsResolver->setRequired(array());
|
|
$optionsResolver->setDefaults(array('page' => 1));
|
|
$optionsResolver->setAllowedTypes('zone_id', array('string'));
|
|
$optionsResolver->setAllowedTypes('per_page', array('float'));
|
|
$optionsResolver->setAllowedTypes('page', array('float'));
|
|
return $optionsResolver;
|
|
}
|
|
/**
|
|
* {@inheritdoc}
|
|
*
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\GetRecordsUnauthorizedException
|
|
* @throws \DigiComp\HetznerDnsApi\Exception\GetRecordsNotAcceptableException
|
|
*
|
|
* @return null|\DigiComp\HetznerDnsApi\Model\RecordsGetResponse200
|
|
*/
|
|
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\\RecordsGetResponse200', 'json');
|
|
}
|
|
if (401 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\GetRecordsUnauthorizedException();
|
|
}
|
|
if (406 === $status) {
|
|
throw new \DigiComp\HetznerDnsApi\Exception\GetRecordsNotAcceptableException();
|
|
}
|
|
}
|
|
public function getAuthenticationScopes() : array
|
|
{
|
|
return array('Auth-API-Token');
|
|
}
|
|
} |