Beispiel #1
0
 /**
  * @param $inputs
  * @return string
  */
 private function getRequestMode($inputs)
 {
     $grantType = ProxyAux::getQueryValue($inputs, ProxyAux::GRANT_TYPE);
     $skip = ProxyAux::getQueryValue($inputs, $this->skipParam);
     $mode = ProxyAux::MODE_TOKEN;
     if (isset($grantType)) {
         if ($grantType === ProxyAux::PASSWORD_GRANT) {
             $mode = ProxyAux::MODE_LOGIN;
         }
     } else {
         if (isset($skip) && strtolower($skip) === 'true') {
             $mode = ProxyAux::MODE_SKIP;
         }
     }
     return $mode;
 }
 /**
  * @param $method
  * @param $uriVal
  * @param $inputs
  * @return \GuzzleHttp\Message\ResponseInterface
  */
 private function sendGuzzleRequest($method, $uriVal, $inputs)
 {
     $options = array();
     $client = new Client();
     if ($this->callMode === ProxyAux::MODE_TOKEN && $this->useHeader === true) {
         $accessToken = ProxyAux::getQueryValue($inputs, ProxyAux::ACCESS_TOKEN);
         $inputs = ProxyAux::removeQueryValue($inputs, ProxyAux::ACCESS_TOKEN);
         $options = array_add($options, 'headers', [ProxyAux::HEADER_AUTH => 'Bearer ' . $accessToken]);
     }
     if ($method === 'GET') {
         $options = array_add($options, 'query', $inputs);
     } else {
         $options = array_add($options, 'body', $inputs);
     }
     $request = $client->createRequest($method, $uriVal, $options);
     try {
         $response = $client->send($request);
     } catch (ClientException $ex) {
         $response = $ex->getResponse();
     }
     return $response;
 }