1: <?php
2:
3: declare(strict_types=1);
4:
5: /*
6: * This file has been auto generated by Jane,
7: *
8: * Do no edit it directly.
9: */
10:
11: namespace NxSys\Library\Clients\Brex\API\Team\Endpoint;
12:
13: class CreateLocation extends \NxSys\Library\Clients\Brex\API\Team\Runtime\Client\BaseEndpoint implements \NxSys\Library\Clients\Brex\API\Team\Runtime\Client\Endpoint
14: {
15: use \NxSys\Library\Clients\Brex\API\Team\Runtime\Client\EndpointTrait;
16:
17: /**
18: This endpoint creates a new location.
19:
20: *
21: * @param array $headerParameters {
22: *
23: * @var string $Idempotency-Key
24: * }
25: */
26: public function __construct(\NxSys\Library\Clients\Brex\API\Team\Model\CreateLocationRequest $requestBody, array $headerParameters = [])
27: {
28: $this->body = $requestBody;
29: $this->headerParameters = $headerParameters;
30: }
31:
32: public function getMethod(): string
33: {
34: return 'POST';
35: }
36:
37: public function getUri(): string
38: {
39: return '/v2/locations';
40: }
41:
42: public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array
43: {
44: if ($this->body instanceof \NxSys\Library\Clients\Brex\API\Team\Model\CreateLocationRequest) {
45: return [['Content-Type' => ['application/json']], $serializer->serialize($this->body, 'json')];
46: }
47:
48: return [[], null];
49: }
50:
51: public function getExtraHeaders(): array
52: {
53: return ['Accept' => ['application/json']];
54: }
55:
56: protected function getHeadersOptionsResolver(): \Symfony\Component\OptionsResolver\OptionsResolver
57: {
58: $optionsResolver = parent::getHeadersOptionsResolver();
59: $optionsResolver->setDefined(['Idempotency-Key']);
60: $optionsResolver->setRequired([]);
61: $optionsResolver->setDefaults([]);
62: $optionsResolver->addAllowedTypes('Idempotency-Key', ['string', 'null']);
63:
64: return $optionsResolver;
65: }
66:
67: /**
68: * {@inheritdoc}
69: *
70: * @return \NxSys\Library\Clients\Brex\API\Team\Model\LocationResponse|null
71: *
72: * @throws \NxSys\Library\Clients\Brex\API\Team\Exception\CreateLocationBadRequestException
73: * @throws \NxSys\Library\Clients\Brex\API\Team\Exception\CreateLocationUnauthorizedException
74: * @throws \NxSys\Library\Clients\Brex\API\Team\Exception\CreateLocationForbiddenException
75: */
76: protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
77: {
78: $status = $response->getStatusCode();
79: $body = (string) $response->getBody();
80: if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) {
81: return $serializer->deserialize($body, 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\LocationResponse', 'json');
82: }
83: if (400 === $status) {
84: throw new \NxSys\Library\Clients\Brex\API\Team\Exception\CreateLocationBadRequestException($response);
85: }
86: if (401 === $status) {
87: throw new \NxSys\Library\Clients\Brex\API\Team\Exception\CreateLocationUnauthorizedException($response);
88: }
89: if (403 === $status) {
90: throw new \NxSys\Library\Clients\Brex\API\Team\Exception\CreateLocationForbiddenException($response);
91: }
92: }
93:
94: public function getAuthenticationScopes(): array
95: {
96: return ['OAuth2'];
97: }
98: }
99: