login(); } /** * @throws TransportExceptionInterface */ public function login(): void { $response = $this->httpClient->request('POST', $this->udsAPIurl . '/auth/login', [ 'json' => [ 'login' => $this->udsAuthLogin, 'username' => $this->udsAuthUsername, 'password' => $this->udsAuthPassword ] ]); $data = json_decode($response->getContent(), true); $this->token = $data['token']; $this->scrambler = $data['scrambler']; } /** * @throws TransportExceptionInterface */ public function getServicePools(): array { $response = $this->httpClient->request('GET', $this->udsAPIurl . '/servicespools/overview', [ 'headers' => [ 'X-Auth-Token' => $this->token, 'Content-Type' => 'application/json', 'Scrambler' => $this->scrambler ] ]); } public function getServicePool(string $providerId, string $serviceId): array { $response = $this->httpClient->request('GET', $this->udsAPIurl . '/providers/' . $providerId .'/services/'. $serviceId, [ 'headers' => [ 'X-Auth-Token' => $this->token, 'Content-Type' => 'application/json', 'Scrambler' => $this->scrambler ] ]); } public function setServicePool(string $serviceId, array $payload): void { $response = $this->httpClient->request('PUT', $this->udsAPIurl . '/servicespools/' . $serviceId, [ 'headers' => [ 'X-Auth-Token' => $this->token, 'Content-Type' => 'application/json', 'Scrambler' => $this->scrambler ], 'json' => $payload ]); } }