/** * GuzzleHandler constructor. * * @param ConfigFacade|ConfigInterface $pConfig * @param InternalFactory $pFactory */ public function __construct(ConfigInterface $pConfig, InternalFactory $pFactory) { $this->_config = $pConfig; $this->_factory = $pFactory; $this->_client = $this->_factory->getGuzzleFactory()->getHttpClientObject($this->_configurationOptions()); $this->_client->addSubscriber($this->_factory->getGuzzleFactory()->getCookiePlugin()); }
/** * Each chain needs to fill this function with it's own actions. * This function contains the functionality of each chain. * * @param ConfigInterface $pConfig The configuration which is used to make the request. * @param InternalFactory $pInternalFactory The factory which is responsible for the internal object creation. * @return bool|stdClass true if the request has been processed, false otherwise */ protected function process(ConfigInterface $pConfig, InternalFactory $pInternalFactory) { if ($pConfig->getAuthenticationMethod() !== Authenticate::AUTH_METHOD_TOKEN) { return false; } $token = $pConfig->getAuthenticationCredentials(); return json_decode($pInternalFactory->getGuzzleFactory()->getGuzzleHandler()->get('token/' . $token)->getBody()); }
/** * Each chain needs to fill this function with it's own actions. * This function contains the functionality of each chain. * * @param ConfigInterface $pConfig The configuration which is used to make the request. * @param InternalFactory $pInternalFactory The factory which is responsible for the internal object creation. * @return bool|stdClass true if the request has been processed, false otherwise */ protected function process(ConfigInterface $pConfig, InternalFactory $pInternalFactory) { if ($pConfig->getAuthenticationMethod() !== Authenticate::AUTH_METHOD_USER_CREDENTIALS) { return false; } $userCredentials = $pConfig->getAuthenticationCredentials(); $userSession = $pConfig->getSession(); $response = json_decode($pInternalFactory->getGuzzleFactory()->getGuzzleHandler()->get('user/logout/' . $userCredentials['username'] . '/' . $userSession)->getBody()); return $response; }
/** * Processes the method and calls Guzzle for requesting the URL. */ public function process() { $httpMethod = $this->getHttpMethod(); $this->_response = $this->_factory->getGuzzleFactory()->getGuzzleHandler()->{$httpMethod}($this->getParsedUrl(), $httpMethod === 'POST' || $httpMethod === 'PUT' ? $this->getAdditionalArguments() : null)->getBody(true); }