|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Starweb\Api\Generated\Endpoint; |
|
4
|
|
|
|
|
5
|
|
|
class CreateStockLocation extends \Jane\OpenApiRuntime\Client\BaseEndpoint implements \Jane\OpenApiRuntime\Client\Psr7HttplugEndpoint |
|
6
|
|
|
{ |
|
7
|
|
|
/** |
|
8
|
|
|
* Create a stock location. Retrieves the created `StockLocation` object |
|
9
|
|
|
* |
|
10
|
|
|
* @param \Starweb\Api\Generated\Model\StockLocationPostRequestModel $requestBody |
|
11
|
|
|
*/ |
|
12
|
|
|
public function __construct(\Starweb\Api\Generated\Model\StockLocationPostRequestModel $requestBody) |
|
13
|
|
|
{ |
|
14
|
|
|
$this->body = $requestBody; |
|
15
|
|
|
} |
|
16
|
|
|
use \Jane\OpenApiRuntime\Client\Psr7HttplugEndpointTrait; |
|
17
|
|
|
public function getMethod() : string |
|
18
|
|
|
{ |
|
19
|
|
|
return 'POST'; |
|
20
|
|
|
} |
|
21
|
|
|
public function getUri() : string |
|
22
|
|
|
{ |
|
23
|
|
|
return '/stock-locations'; |
|
24
|
|
|
} |
|
25
|
|
|
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, \Http\Message\StreamFactory $streamFactory = null) : array |
|
26
|
|
|
{ |
|
27
|
|
|
if ($this->body instanceof \Starweb\Api\Generated\Model\StockLocationPostRequestModel) { |
|
28
|
|
|
return array(array('Content-Type' => array('application/json')), $serializer->serialize($this->body, 'json')); |
|
29
|
|
|
} |
|
30
|
|
|
return array(array(), null); |
|
31
|
|
|
} |
|
32
|
|
|
public function getExtraHeaders() : array |
|
33
|
|
|
{ |
|
34
|
|
|
return array('Accept' => array('application/json')); |
|
35
|
|
|
} |
|
36
|
|
|
/** |
|
37
|
|
|
* {@inheritdoc} |
|
38
|
|
|
* |
|
39
|
|
|
* @throws \Starweb\Api\Generated\Exception\CreateStockLocationBadRequestException |
|
40
|
|
|
* @throws \Starweb\Api\Generated\Exception\CreateStockLocationForbiddenException |
|
41
|
|
|
* |
|
42
|
|
|
* @return null|\Starweb\Api\Generated\Model\StockLocationModelItem |
|
43
|
|
|
*/ |
|
44
|
|
|
protected function transformResponseBody(string $body, int $status, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null) |
|
45
|
|
|
{ |
|
46
|
|
|
if (201 === $status && 'application/json' === $contentType) { |
|
47
|
|
|
return $serializer->deserialize($body, 'Starweb\\Api\\Generated\\Model\\StockLocationModelItem', 'json'); |
|
48
|
|
|
} |
|
49
|
|
|
if (400 === $status && 'application/json' === $contentType) { |
|
50
|
|
|
throw new \Starweb\Api\Generated\Exception\CreateStockLocationBadRequestException($serializer->deserialize($body, 'Starweb\\Api\\Generated\\Model\\ErrorModel', 'json')); |
|
51
|
|
|
} |
|
52
|
|
|
if (403 === $status && 'application/json' === $contentType) { |
|
53
|
|
|
throw new \Starweb\Api\Generated\Exception\CreateStockLocationForbiddenException($serializer->deserialize($body, 'Starweb\\Api\\Generated\\Model\\ErrorModel', 'json')); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
} |