79 lines
3.3 KiB
PHP
79 lines
3.3 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace DigiComp\HetznerDnsApi\Endpoint;
|
||
|
|
||
|
class UpdateRecord extends \DigiComp\HetznerDnsApi\Runtime\Client\BaseEndpoint implements \DigiComp\HetznerDnsApi\Runtime\Client\Endpoint
|
||
|
{
|
||
|
protected $RecordID;
|
||
|
/**
|
||
|
* Updates a record.
|
||
|
*
|
||
|
* @param string $recordID ID of record to be updated
|
||
|
* @param null|\DigiComp\HetznerDnsApi\Model\Record $requestBody
|
||
|
*/
|
||
|
public function __construct(string $recordID, ?\DigiComp\HetznerDnsApi\Model\Record $requestBody = null)
|
||
|
{
|
||
|
$this->RecordID = $recordID;
|
||
|
$this->body = $requestBody;
|
||
|
}
|
||
|
use \DigiComp\HetznerDnsApi\Runtime\Client\EndpointTrait;
|
||
|
public function getMethod() : string
|
||
|
{
|
||
|
return 'PUT';
|
||
|
}
|
||
|
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
|
||
|
{
|
||
|
if ($this->body instanceof \DigiComp\HetznerDnsApi\Model\Record) {
|
||
|
return array(array('Content-Type' => array('application/json')), $serializer->serialize($this->body, 'json'));
|
||
|
}
|
||
|
return array(array(), null);
|
||
|
}
|
||
|
public function getExtraHeaders() : array
|
||
|
{
|
||
|
return array('Accept' => array('application/json'));
|
||
|
}
|
||
|
/**
|
||
|
* {@inheritdoc}
|
||
|
*
|
||
|
* @throws \DigiComp\HetznerDnsApi\Exception\UpdateRecordUnauthorizedException
|
||
|
* @throws \DigiComp\HetznerDnsApi\Exception\UpdateRecordForbiddenException
|
||
|
* @throws \DigiComp\HetznerDnsApi\Exception\UpdateRecordNotFoundException
|
||
|
* @throws \DigiComp\HetznerDnsApi\Exception\UpdateRecordNotAcceptableException
|
||
|
* @throws \DigiComp\HetznerDnsApi\Exception\UpdateRecordConflictException
|
||
|
* @throws \DigiComp\HetznerDnsApi\Exception\UpdateRecordUnprocessableEntityException
|
||
|
*
|
||
|
* @return null|\DigiComp\HetznerDnsApi\Model\RecordsRecordIDPutResponse200
|
||
|
*/
|
||
|
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\\RecordsRecordIDPutResponse200', 'json');
|
||
|
}
|
||
|
if (401 === $status) {
|
||
|
throw new \DigiComp\HetznerDnsApi\Exception\UpdateRecordUnauthorizedException();
|
||
|
}
|
||
|
if (403 === $status) {
|
||
|
throw new \DigiComp\HetznerDnsApi\Exception\UpdateRecordForbiddenException();
|
||
|
}
|
||
|
if (404 === $status) {
|
||
|
throw new \DigiComp\HetznerDnsApi\Exception\UpdateRecordNotFoundException();
|
||
|
}
|
||
|
if (406 === $status) {
|
||
|
throw new \DigiComp\HetznerDnsApi\Exception\UpdateRecordNotAcceptableException();
|
||
|
}
|
||
|
if (409 === $status) {
|
||
|
throw new \DigiComp\HetznerDnsApi\Exception\UpdateRecordConflictException();
|
||
|
}
|
||
|
if (422 === $status) {
|
||
|
throw new \DigiComp\HetznerDnsApi\Exception\UpdateRecordUnprocessableEntityException();
|
||
|
}
|
||
|
}
|
||
|
public function getAuthenticationScopes() : array
|
||
|
{
|
||
|
return array('Auth-API-Token');
|
||
|
}
|
||
|
}
|