src/CasRestClient.php
private function callRestService($method, $service, $headers = [], $body = '', $form_params = [])
    {
        // Make sure a TGT exists
        $this->checkTgtExists();

        $serviceTicket = $this->getServiceTicket($service);

        // Append the ticket to the end of the service's parameters
        if (strpos($service, '?') === false) {
            $finalService = $service . '?ticket=' . $serviceTicket;
        } else {
            $finalService = $service . '&ticket=' . $serviceTicket;
        }

        $jar = new \GuzzleHttp\Cookie\CookieJar;

        $options = [
            'cookies' => $jar,
            'body' => $body,
            'form_params' => $form_params,
            'headers' => $this->setGuzzleHeaders($headers),
            'verify' => $this->verifySSL
        ];

        switch ($method) {
            case 'GET':
                $result = $this->guzzleClient->get($finalService, $options);
                break;

            case 'HEAD':
                $result = $this->guzzleClient->head($finalService, $options);
                break;

            case 'POST':
                $result = $this->guzzleClient->post($finalService, $options);
                break;

            case 'PUT':
                $result = $this->guzzleClient->put($finalService, $options);
                break;

            case 'PATCH':
                $result = $this->guzzleClient->patch($finalService, $options);
                break;

            case 'DELETE':
                $result = $this->guzzleClient->delete($finalService, $options);
                break;

            default:
                throw new \Exception('Unsupported HTTP method: ' . $method, 500);
        }

        return $result;
    }
private function callRestService($method, $service, $headers = [], $body = '', $form_params = [])
    {
        // Make sure a TGT exists
        $this->checkTgtExists();

        $serviceTicket = $this->getServiceTicket($service);

        // Append the ticket to the end of the service's parameters
        if (strpos($service, '?') === false) {
            $finalService = $service . '?ticket=' . $serviceTicket;
        } else {
            $finalService = $service . '&ticket=' . $serviceTicket;
        }

        $jar = new \GuzzleHttp\Cookie\CookieJar;

        $options = [
            'cookies' => $jar,
            'body' => $body,
            'form_params' => $form_params,
            'headers' => $this->setGuzzleHeaders($headers),
            'verify' => $this->verifySSL
        ];

        switch ($method) {
            case 'GET':
                $result = $this->guzzleClient->get($finalService, $options);
                break;

            case 'HEAD':
                $result = $this->guzzleClient->head($finalService, $options);
                break;

            case 'POST':
                $result = $this->guzzleClient->post($finalService, $options);
                break;

            case 'PUT':
                $result = $this->guzzleClient->put($finalService, $options);
                break;

            case 'PATCH':
                $result = $this->guzzleClient->patch($finalService, $options);
                break;

            case 'DELETE':
                $result = $this->guzzleClient->delete($finalService, $options);
                break;

            default:
                throw new \Exception('Unsupported HTTP method: ' . $method, 500);
        }

        return $result;
    }
private function callRestService ( $ method , $ service , $ headers = [ ] , $ body = '' , $ form_params = [ ] ) { // Make sure a TGT exists $ this -> checkTgtExists ( ) ; $ serviceTicket = $ this -> getServiceTicket ( $ service ) ; // Append the ticket to the end of the service's parameters if ( strpos ( $ service , '?' ) === false ) { $ finalService = $ service . '?ticket=' . $ serviceTicket ; } else { $ finalService = $ service . '&ticket=' . $ serviceTicket ; } $ jar = new \ GuzzleHttp \ Cookie \ CookieJar ; $ options = [ 'cookies' => $ jar , 'body' => $ body , 'form_params' => $ form_params , 'headers' => $ this -> setGuzzleHeaders ( $ headers ) , 'verify' => $ this -> verifySSL ] ; switch ( $ method ) { case 'GET' : $ result = $ this -> guzzleClient -> get ( $ finalService , $ options ) ; break ; case 'HEAD' : $ result = $ this -> guzzleClient -> head ( $ finalService , $ options ) ; break ; case 'POST' : $ result = $ this -> guzzleClient -> post ( $ finalService , $ options ) ; break ; case 'PUT' : $ result = $ this -> guzzleClient -> put ( $ finalService , $ options ) ; break ; case 'PATCH' : $ result = $ this -> guzzleClient -> patch ( $ finalService , $ options ) ; break ; case 'DELETE' : $ result = $ this -> guzzleClient -> delete ( $ finalService , $ options ) ; break ; default : throw new \ Exception ( 'Unsupported HTTP method: ' . $ method , 500 ) ; } return $ result ; }
Set up and execute a REST request.

@param $method
@param $service
@param array $headers
@param array $body
@return mixed|null
@throws \Exception
Set up and execute a REST request .