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 GetVendorById 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: | protected $id; |
17: | |
18: | |
19: | |
20: | |
21: | public function __construct(string $id) |
22: | { |
23: | $this->id = $id; |
24: | } |
25: | |
26: | public function getMethod(): string |
27: | { |
28: | return 'GET'; |
29: | } |
30: | |
31: | public function getUri(): string |
32: | { |
33: | return str_replace(['{id}'], [$this->id], '/v1/vendors/{id}'); |
34: | } |
35: | |
36: | public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array |
37: | { |
38: | return [[], null]; |
39: | } |
40: | |
41: | public function getExtraHeaders(): array |
42: | { |
43: | return ['Accept' => ['application/json']]; |
44: | } |
45: | |
46: | |
47: | |
48: | |
49: | |
50: | |
51: | |
52: | |
53: | |
54: | |
55: | |
56: | protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null) |
57: | { |
58: | $status = $response->getStatusCode(); |
59: | $body = (string) $response->getBody(); |
60: | if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) { |
61: | return $serializer->deserialize($body, 'NxSys\\Library\\Clients\\Brex\\API\\Payments\\Model\\VendorResponse', 'json'); |
62: | } |
63: | if (400 === $status) { |
64: | throw new \NxSys\Library\Clients\Brex\API\Payments\Exception\GetVendorByIdBadRequestException($response); |
65: | } |
66: | if (401 === $status) { |
67: | throw new \NxSys\Library\Clients\Brex\API\Payments\Exception\GetVendorByIdUnauthorizedException($response); |
68: | } |
69: | if (403 === $status) { |
70: | throw new \NxSys\Library\Clients\Brex\API\Payments\Exception\GetVendorByIdForbiddenException($response); |
71: | } |
72: | if (500 === $status) { |
73: | throw new \NxSys\Library\Clients\Brex\API\Payments\Exception\GetVendorByIdInternalServerErrorException($response); |
74: | } |
75: | } |
76: | |
77: | public function getAuthenticationScopes(): array |
78: | { |
79: | return ['OAuth2']; |
80: | } |
81: | } |
82: | |