1: | <?php |
2: | |
3: | declare(strict_types=1); |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | namespace NxSys\Library\Clients\Brex\API\Expenses\Endpoint; |
12: | |
13: | class ReceiptMatch extends \NxSys\Library\Clients\Brex\API\Expenses\Runtime\Client\BaseEndpoint implements \NxSys\Library\Clients\Brex\API\Expenses\Runtime\Client\Endpoint |
14: | { |
15: | use \NxSys\Library\Clients\Brex\API\Expenses\Runtime\Client\EndpointTrait; |
16: | |
17: | |
18: | |
19: | |
20: | |
21: | |
22: | public function __construct(\NxSys\Library\Clients\Brex\API\Expenses\Model\ReceiptMatchRequest $requestBody) |
23: | { |
24: | $this->body = $requestBody; |
25: | } |
26: | |
27: | public function getMethod(): string |
28: | { |
29: | return 'POST'; |
30: | } |
31: | |
32: | public function getUri(): string |
33: | { |
34: | return '/v1/expenses/card/receipt_match'; |
35: | } |
36: | |
37: | public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array |
38: | { |
39: | if ($this->body instanceof \NxSys\Library\Clients\Brex\API\Expenses\Model\ReceiptMatchRequest) { |
40: | return [['Content-Type' => ['application/json']], $serializer->serialize($this->body, 'json')]; |
41: | } |
42: | |
43: | return [[], null]; |
44: | } |
45: | |
46: | public function getExtraHeaders(): array |
47: | { |
48: | return ['Accept' => ['application/json']]; |
49: | } |
50: | |
51: | |
52: | |
53: | |
54: | |
55: | |
56: | |
57: | |
58: | |
59: | protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null) |
60: | { |
61: | $status = $response->getStatusCode(); |
62: | $body = (string) $response->getBody(); |
63: | if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) { |
64: | return $serializer->deserialize($body, 'NxSys\\Library\\Clients\\Brex\\API\\Expenses\\Model\\CreateAsyncFileUploadResponse', 'json'); |
65: | } |
66: | if (400 === $status) { |
67: | throw new \NxSys\Library\Clients\Brex\API\Expenses\Exception\ReceiptMatchBadRequestException($response); |
68: | } |
69: | if (401 === $status) { |
70: | throw new \NxSys\Library\Clients\Brex\API\Expenses\Exception\ReceiptMatchUnauthorizedException($response); |
71: | } |
72: | } |
73: | |
74: | public function getAuthenticationScopes(): array |
75: | { |
76: | return ['oAuth2ClientCredentials']; |
77: | } |
78: | } |
79: | |