1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Starweb\Api\Generated\Endpoint; |
4
|
|
|
|
5
|
|
|
class PutProductUnit extends \Jane\OpenApiRuntime\Client\BaseEndpoint implements \Jane\OpenApiRuntime\Client\Psr7Endpoint |
6
|
|
|
{ |
7
|
|
|
protected $unitId; |
8
|
|
|
/** |
9
|
|
|
* Updates the `ProductUnit` object. |
10
|
|
|
* |
11
|
|
|
* @param int $unitId The units id |
12
|
|
|
* @param \Starweb\Api\Generated\Model\ProductUnitModelUpdatable $requestBody |
13
|
|
|
*/ |
14
|
|
|
public function __construct(int $unitId, \Starweb\Api\Generated\Model\ProductUnitModelUpdatable $requestBody) |
15
|
|
|
{ |
16
|
|
|
$this->unitId = $unitId; |
17
|
|
|
$this->body = $requestBody; |
18
|
|
|
} |
19
|
|
|
use \Jane\OpenApiRuntime\Client\Psr7EndpointTrait; |
20
|
|
|
public function getMethod() : string |
21
|
|
|
{ |
22
|
|
|
return 'PUT'; |
23
|
|
|
} |
24
|
|
|
public function getUri() : string |
25
|
|
|
{ |
26
|
|
|
return str_replace(array('{unitId}'), array($this->unitId), '/product-units/{unitId}'); |
27
|
|
|
} |
28
|
|
|
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null) : array |
29
|
|
|
{ |
30
|
|
|
if ($this->body instanceof \Starweb\Api\Generated\Model\ProductUnitModelUpdatable) { |
31
|
|
|
return array(array('Content-Type' => array('application/json')), $serializer->serialize($this->body, 'json')); |
32
|
|
|
} |
33
|
|
|
return array(array(), null); |
34
|
|
|
} |
35
|
|
|
public function getExtraHeaders() : array |
36
|
|
|
{ |
37
|
|
|
return array('Accept' => array('application/json')); |
38
|
|
|
} |
39
|
|
|
/** |
40
|
|
|
* {@inheritdoc} |
41
|
|
|
* |
42
|
|
|
* @throws \Starweb\Api\Generated\Exception\PutProductUnitNotFoundException |
43
|
|
|
* |
44
|
|
|
* @return null|\Starweb\Api\Generated\Model\ProductUnitModelItem |
45
|
|
|
*/ |
46
|
|
|
protected function transformResponseBody(string $body, int $status, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null) |
47
|
|
|
{ |
48
|
|
|
if (200 === $status && mb_strpos($contentType, 'application/json') !== false) { |
|
|
|
|
49
|
|
|
return $serializer->deserialize($body, 'Starweb\\Api\\Generated\\Model\\ProductUnitModelItem', 'json'); |
50
|
|
|
} |
51
|
|
|
if (404 === $status && mb_strpos($contentType, 'application/json') !== false) { |
52
|
|
|
throw new \Starweb\Api\Generated\Exception\PutProductUnitNotFoundException($serializer->deserialize($body, 'Starweb\\Api\\Generated\\Model\\ErrorModel', 'json')); |
|
|
|
|
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
} |