hetzner-dns-api/generated/Endpoint/CreateRecord.php

68 lines
2.6 KiB
PHP
Raw Normal View History

2023-01-05 12:55:52 +01:00
<?php
namespace DigiComp\HetznerDnsApi\Endpoint;
class CreateRecord extends \DigiComp\HetznerDnsApi\Runtime\Client\BaseEndpoint implements \DigiComp\HetznerDnsApi\Runtime\Client\Endpoint
{
/**
* Creates a new record.
*
* @param null|\DigiComp\HetznerDnsApi\Model\Record $requestBody
*/
public function __construct(?\DigiComp\HetznerDnsApi\Model\Record $requestBody = null)
{
$this->body = $requestBody;
}
use \DigiComp\HetznerDnsApi\Runtime\Client\EndpointTrait;
public function getMethod() : string
{
return 'POST';
}
public function getUri() : string
{
return '/records';
}
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\CreateRecordUnauthorizedException
* @throws \DigiComp\HetznerDnsApi\Exception\CreateRecordForbiddenException
* @throws \DigiComp\HetznerDnsApi\Exception\CreateRecordNotAcceptableException
* @throws \DigiComp\HetznerDnsApi\Exception\CreateRecordUnprocessableEntityException
*
* @return null|\DigiComp\HetznerDnsApi\Model\RecordsPostResponse200
*/
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\\RecordsPostResponse200', 'json');
}
if (401 === $status) {
throw new \DigiComp\HetznerDnsApi\Exception\CreateRecordUnauthorizedException();
}
if (403 === $status) {
throw new \DigiComp\HetznerDnsApi\Exception\CreateRecordForbiddenException();
}
if (406 === $status) {
throw new \DigiComp\HetznerDnsApi\Exception\CreateRecordNotAcceptableException();
}
if (422 === $status) {
throw new \DigiComp\HetznerDnsApi\Exception\CreateRecordUnprocessableEntityException();
}
}
public function getAuthenticationScopes() : array
{
return array('Auth-API-Token');
}
}