1: | <?php |
2: | |
3: | declare(strict_types=1); |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | namespace NxSys\Library\Clients\Brex\API\Budgets; |
12: | |
13: | class Client extends \NxSys\Library\Clients\Brex\API\Budgets\Runtime\Client\Client |
14: | { |
15: | |
16: | |
17: | |
18: | |
19: | |
20: | |
21: | |
22: | |
23: | |
24: | |
25: | |
26: | |
27: | |
28: | |
29: | |
30: | |
31: | |
32: | |
33: | public function listBudgets(array $queryParameters = [], string $fetch = self::FETCH_OBJECT) |
34: | { |
35: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Budgets\Endpoint\ListBudgets($queryParameters), $fetch); |
36: | } |
37: | |
38: | |
39: | |
40: | |
41: | |
42: | |
43: | |
44: | |
45: | |
46: | |
47: | |
48: | |
49: | |
50: | |
51: | |
52: | |
53: | |
54: | |
55: | |
56: | public function createBudget(Model\CreateBudgetRequest $requestBody, array $headerParameters = [], string $fetch = self::FETCH_OBJECT) |
57: | { |
58: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Budgets\Endpoint\CreateBudget($requestBody, $headerParameters), $fetch); |
59: | } |
60: | |
61: | |
62: | |
63: | |
64: | |
65: | |
66: | |
67: | |
68: | |
69: | |
70: | |
71: | |
72: | |
73: | |
74: | public function getBudgetById(string $id, string $fetch = self::FETCH_OBJECT) |
75: | { |
76: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Budgets\Endpoint\GetBudgetById($id), $fetch); |
77: | } |
78: | |
79: | |
80: | |
81: | |
82: | |
83: | |
84: | |
85: | |
86: | |
87: | |
88: | |
89: | |
90: | |
91: | |
92: | |
93: | |
94: | |
95: | |
96: | |
97: | |
98: | public function updateBudget(string $id, Model\UpdateBudgetRequest $requestBody, array $headerParameters = [], string $fetch = self::FETCH_OBJECT) |
99: | { |
100: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Budgets\Endpoint\UpdateBudget($id, $requestBody, $headerParameters), $fetch); |
101: | } |
102: | |
103: | public static function create($httpClient = null, array $additionalPlugins = [], array $additionalNormalizers = []) |
104: | { |
105: | if (null === $httpClient) { |
106: | $httpClient = \Http\Discovery\Psr18ClientDiscovery::find(); |
107: | $plugins = []; |
108: | $uri = \Http\Discovery\Psr17FactoryDiscovery::findUrlFactory()->createUri('https://platform.brexapis.com'); |
109: | $plugins[] = new \Http\Client\Common\Plugin\AddHostPlugin($uri); |
110: | if (count($additionalPlugins) > 0) { |
111: | $plugins = array_merge($plugins, $additionalPlugins); |
112: | } |
113: | $httpClient = new \Http\Client\Common\PluginClient($httpClient, $plugins); |
114: | } |
115: | $requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory(); |
116: | $streamFactory = \Http\Discovery\Psr17FactoryDiscovery::findStreamFactory(); |
117: | $normalizers = [new \Symfony\Component\Serializer\Normalizer\ArrayDenormalizer(), new \NxSys\Library\Clients\Brex\API\Budgets\Normalizer\JaneObjectNormalizer()]; |
118: | if (count($additionalNormalizers) > 0) { |
119: | $normalizers = array_merge($normalizers, $additionalNormalizers); |
120: | } |
121: | $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]))]); |
122: | |
123: | return new static($httpClient, $requestFactory, $serializer, $streamFactory); |
124: | } |
125: | } |
126: | |