1: | <?php |
2: | |
3: | declare(strict_types=1); |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | namespace NxSys\Library\Clients\Brex\API\Payments\Endpoint; |
12: | |
13: | class CreateVendor extends \NxSys\Library\Clients\Brex\API\Payments\Runtime\Client\BaseEndpoint implements \NxSys\Library\Clients\Brex\API\Payments\Runtime\Client\Endpoint |
14: | { |
15: | use \NxSys\Library\Clients\Brex\API\Payments\Runtime\Client\EndpointTrait; |
16: | |
17: | |
18: | |
19: | |
20: | |
21: | |
22: | |
23: | |
24: | |
25: | |
26: | public function __construct(\NxSys\Library\Clients\Brex\API\Payments\Model\CreateVendorRequest $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 '/v1/vendors'; |
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\Payments\Model\CreateVendorRequest) { |
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(['Idempotency-Key']); |
61: | $optionsResolver->setDefaults([]); |
62: | $optionsResolver->addAllowedTypes('Idempotency-Key', ['string']); |
63: | |
64: | return $optionsResolver; |
65: | } |
66: | |
67: | |
68: | |
69: | |
70: | |
71: | |
72: | protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null) |
73: | { |
74: | $status = $response->getStatusCode(); |
75: | $body = (string) $response->getBody(); |
76: | if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) { |
77: | return $serializer->deserialize($body, 'NxSys\\Library\\Clients\\Brex\\API\\Payments\\Model\\VendorResponse', 'json'); |
78: | } |
79: | } |
80: | |
81: | public function getAuthenticationScopes(): array |
82: | { |
83: | return ['OAuth2']; |
84: | } |
85: | } |
86: | |