Completed
Push — master ( cc2b64...3127a8 )
by
unknown
28:00 queued 12:57
created

DeletePricelist   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 47
rs 10
wmc 11

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getExtraHeaders() 0 3 1
A transformResponseBody() 0 10 6
A getMethod() 0 3 1
A getBody() 0 3 1
A getUri() 0 3 1
1
<?php
2
3
namespace Starweb\Api\Generated\Endpoint;
4
5
class DeletePricelist extends \Jane\OpenApiRuntime\Client\BaseEndpoint implements \Jane\OpenApiRuntime\Client\Psr7HttplugEndpoint
6
{
7
    protected $pricelistId;
8
    /**
9
     * Delete a pricelist permanently. The master pricelist can not be deleted and will return an error `403`
10
     *
11
     * @param int $pricelistId The pricelist id
12
     */
13
    public function __construct(int $pricelistId)
14
    {
15
        $this->pricelistId = $pricelistId;
16
    }
17
    use \Jane\OpenApiRuntime\Client\Psr7HttplugEndpointTrait;
18
    public function getMethod() : string
19
    {
20
        return 'DELETE';
21
    }
22
    public function getUri() : string
23
    {
24
        return str_replace(array('{pricelistId}'), array($this->pricelistId), '/pricelists/{pricelistId}');
25
    }
26
    public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, \Http\Message\StreamFactory $streamFactory = null) : array
27
    {
28
        return array(array(), null);
29
    }
30
    public function getExtraHeaders() : array
31
    {
32
        return array('Accept' => array('application/json'));
33
    }
34
    /**
35
     * {@inheritdoc}
36
     *
37
     * @throws \Starweb\Api\Generated\Exception\DeletePricelistNotFoundException
38
     * @throws \Starweb\Api\Generated\Exception\DeletePricelistForbiddenException
39
     *
40
     * @return null
41
     */
42
    protected function transformResponseBody(string $body, int $status, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
43
    {
44
        if (204 === $status) {
45
            return null;
46
        }
47
        if (404 === $status && 'application/json' === $contentType) {
48
            throw new \Starweb\Api\Generated\Exception\DeletePricelistNotFoundException($serializer->deserialize($body, 'Starweb\\Api\\Generated\\Model\\ErrorModel', 'json'));
0 ignored issues
show
Bug introduced by
It seems like $serializer->deserialize...el\ErrorModel', 'json') can also be of type array; however, parameter $errorModel of Starweb\Api\Generated\Ex...xception::__construct() does only seem to accept Starweb\Api\Generated\Model\ErrorModel, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

48
            throw new \Starweb\Api\Generated\Exception\DeletePricelistNotFoundException(/** @scrutinizer ignore-type */ $serializer->deserialize($body, 'Starweb\\Api\\Generated\\Model\\ErrorModel', 'json'));
Loading history...
49
        }
50
        if (403 === $status && 'application/json' === $contentType) {
51
            throw new \Starweb\Api\Generated\Exception\DeletePricelistForbiddenException($serializer->deserialize($body, 'Starweb\\Api\\Generated\\Model\\ErrorModel', 'json'));
0 ignored issues
show
Bug introduced by
It seems like $serializer->deserialize...el\ErrorModel', 'json') can also be of type array; however, parameter $errorModel of Starweb\Api\Generated\Ex...xception::__construct() does only seem to accept Starweb\Api\Generated\Model\ErrorModel, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

51
            throw new \Starweb\Api\Generated\Exception\DeletePricelistForbiddenException(/** @scrutinizer ignore-type */ $serializer->deserialize($body, 'Starweb\\Api\\Generated\\Model\\ErrorModel', 'json'));
Loading history...
52
        }
53
    }
54
}