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\Webhooks; |
12: | |
13: | class Client extends \NxSys\Library\Clients\Brex\API\Webhooks\Runtime\Client\Client |
14: | { |
15: | /** |
16: | * List the webhooks you have registered. |
17: | * |
18: | * @param array $queryParameters { |
19: | * |
20: | * @var string $cursor |
21: | * @var int $limit |
22: | * } |
23: | * |
24: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
25: | * |
26: | * @return \NxSys\Library\Clients\Brex\API\Webhooks\Model\PageWebhookSubscription|\Psr\Http\Message\ResponseInterface|null |
27: | * |
28: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\ListSubscriptionBadRequestException |
29: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\ListSubscriptionUnauthorizedException |
30: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\ListSubscriptionForbiddenException |
31: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\ListSubscriptionInternalServerErrorException |
32: | */ |
33: | public function listSubscription(array $queryParameters = [], string $fetch = self::FETCH_OBJECT) |
34: | { |
35: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Webhooks\Endpoint\ListSubscription($queryParameters), $fetch); |
36: | } |
37: | |
38: | /** |
39: | * Register an endpoint to start receiving selected webhook events. |
40: | * |
41: | * @param \NxSys\Library\Clients\Brex\API\Webhooks\Model\CreateWebhookSubscriptionRequest $requestBody |
42: | * @param array $headerParameters { |
43: | * |
44: | * @var string $Idempotency-Key |
45: | * } |
46: | * |
47: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
48: | * |
49: | * @return \NxSys\Library\Clients\Brex\API\Webhooks\Model\WebhookSubscription|\Psr\Http\Message\ResponseInterface|null |
50: | * |
51: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\CreateSubscriptionBadRequestException |
52: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\CreateSubscriptionUnauthorizedException |
53: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\CreateSubscriptionForbiddenException |
54: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\CreateSubscriptionInternalServerErrorException |
55: | */ |
56: | public function createSubscription(Model\CreateWebhookSubscriptionRequest $requestBody, array $headerParameters = [], string $fetch = self::FETCH_OBJECT) |
57: | { |
58: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Webhooks\Endpoint\CreateSubscription($requestBody, $headerParameters), $fetch); |
59: | } |
60: | |
61: | /** |
62: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
63: | * |
64: | * @return \NxSys\Library\Clients\Brex\API\Webhooks\Model\WebhookSecret[]|\Psr\Http\Message\ResponseInterface|null |
65: | * |
66: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\ListSecretsBadRequestException |
67: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\ListSecretsUnauthorizedException |
68: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\ListSecretsForbiddenException |
69: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\ListSecretsInternalServerErrorException |
70: | */ |
71: | public function listSecrets(string $fetch = self::FETCH_OBJECT) |
72: | { |
73: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Webhooks\Endpoint\ListSecrets(), $fetch); |
74: | } |
75: | |
76: | /** |
77: | * Unregister a webhook if you want to stop receiving webhook events. |
78: | * |
79: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
80: | * |
81: | * @return \Psr\Http\Message\ResponseInterface|null |
82: | * |
83: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\DeleteSubscriptionBadRequestException |
84: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\DeleteSubscriptionUnauthorizedException |
85: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\DeleteSubscriptionForbiddenException |
86: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\DeleteSubscriptionInternalServerErrorException |
87: | */ |
88: | public function deleteSubscription(string $id, string $fetch = self::FETCH_OBJECT) |
89: | { |
90: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Webhooks\Endpoint\DeleteSubscription($id), $fetch); |
91: | } |
92: | |
93: | /** |
94: | * Get details of a webhook. |
95: | * |
96: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
97: | * |
98: | * @return \NxSys\Library\Clients\Brex\API\Webhooks\Model\WebhookSubscription|\Psr\Http\Message\ResponseInterface|null |
99: | * |
100: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\GetSubscriptionByIdBadRequestException |
101: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\GetSubscriptionByIdUnauthorizedException |
102: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\GetSubscriptionByIdForbiddenException |
103: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\GetSubscriptionByIdInternalServerErrorException |
104: | */ |
105: | public function getSubscriptionById(string $id, string $fetch = self::FETCH_OBJECT) |
106: | { |
107: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Webhooks\Endpoint\GetSubscriptionById($id), $fetch); |
108: | } |
109: | |
110: | /** |
111: | * Update a webhook. |
112: | * |
113: | * @param \NxSys\Library\Clients\Brex\API\Webhooks\Model\UpdateWebhookSubscriptionRequest $requestBody |
114: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
115: | * |
116: | * @return \NxSys\Library\Clients\Brex\API\Webhooks\Model\WebhookSubscription|\Psr\Http\Message\ResponseInterface|null |
117: | * |
118: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\UpdateSubscriptionBadRequestException |
119: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\UpdateSubscriptionUnauthorizedException |
120: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\UpdateSubscriptionForbiddenException |
121: | * @throws \NxSys\Library\Clients\Brex\API\Webhooks\Exception\UpdateSubscriptionInternalServerErrorException |
122: | */ |
123: | public function updateSubscription(string $id, Model\UpdateWebhookSubscriptionRequest $requestBody, string $fetch = self::FETCH_OBJECT) |
124: | { |
125: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Webhooks\Endpoint\UpdateSubscription($id, $requestBody), $fetch); |
126: | } |
127: | |
128: | public static function create($httpClient = null, array $additionalPlugins = [], array $additionalNormalizers = []) |
129: | { |
130: | if (null === $httpClient) { |
131: | $httpClient = \Http\Discovery\Psr18ClientDiscovery::find(); |
132: | $plugins = []; |
133: | $uri = \Http\Discovery\Psr17FactoryDiscovery::findUrlFactory()->createUri('https://platform.brexapis.com'); |
134: | $plugins[] = new \Http\Client\Common\Plugin\AddHostPlugin($uri); |
135: | if (count($additionalPlugins) > 0) { |
136: | $plugins = array_merge($plugins, $additionalPlugins); |
137: | } |
138: | $httpClient = new \Http\Client\Common\PluginClient($httpClient, $plugins); |
139: | } |
140: | $requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory(); |
141: | $streamFactory = \Http\Discovery\Psr17FactoryDiscovery::findStreamFactory(); |
142: | $normalizers = [new \Symfony\Component\Serializer\Normalizer\ArrayDenormalizer(), new \NxSys\Library\Clients\Brex\API\Webhooks\Normalizer\JaneObjectNormalizer()]; |
143: | if (count($additionalNormalizers) > 0) { |
144: | $normalizers = array_merge($normalizers, $additionalNormalizers); |
145: | } |
146: | $serializer = new \Symfony\Component\Serializer\Serializer($normalizers, [new \Symfony\Component\Serializer\Encoder\JsonEncoder(new \Symfony\Component\Serializer\Encoder\JsonEncode(), new \Symfony\Component\Serializer\Encoder\JsonDecode(['json_decode_associative' => true]))]); |
147: | |
148: | return new static($httpClient, $requestFactory, $serializer, $streamFactory); |
149: | } |
150: | } |
151: |