1: | <?php |
2: | |
3: | declare(strict_types=1); |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | namespace NxSys\Library\Clients\Brex\API\Webhooks\Endpoint; |
12: | |
13: | class DeleteSubscription extends \NxSys\Library\Clients\Brex\API\Webhooks\Runtime\Client\BaseEndpoint implements \NxSys\Library\Clients\Brex\API\Webhooks\Runtime\Client\Endpoint |
14: | { |
15: | use \NxSys\Library\Clients\Brex\API\Webhooks\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 'DELETE'; |
29: | } |
30: | |
31: | public function getUri(): string |
32: | { |
33: | return str_replace(['{id}'], [$this->id], '/v1/webhooks/{id}'); |
34: | } |
35: | |
36: | public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array |
37: | { |
38: | return [[], null]; |
39: | } |
40: | |
41: | |
42: | |
43: | |
44: | |
45: | |
46: | |
47: | |
48: | |
49: | |
50: | |
51: | protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null) |
52: | { |
53: | $status = $response->getStatusCode(); |
54: | $body = (string) $response->getBody(); |
55: | if (200 === $status) { |
56: | return null; |
57: | } |
58: | if (400 === $status) { |
59: | throw new \NxSys\Library\Clients\Brex\API\Webhooks\Exception\DeleteSubscriptionBadRequestException($response); |
60: | } |
61: | if (401 === $status) { |
62: | throw new \NxSys\Library\Clients\Brex\API\Webhooks\Exception\DeleteSubscriptionUnauthorizedException($response); |
63: | } |
64: | if (403 === $status) { |
65: | throw new \NxSys\Library\Clients\Brex\API\Webhooks\Exception\DeleteSubscriptionForbiddenException($response); |
66: | } |
67: | if (500 === $status) { |
68: | throw new \NxSys\Library\Clients\Brex\API\Webhooks\Exception\DeleteSubscriptionInternalServerErrorException($response); |
69: | } |
70: | } |
71: | |
72: | public function getAuthenticationScopes(): array |
73: | { |
74: | return ['OAuth2']; |
75: | } |
76: | } |
77: | |