/** * @return Response */ public function send() { if ($this->autologin) { $this->client->checkLogin(); } $this->options['query'] = $this->query->toArray(); return new Response($this->internalClient->request($this->method, $this->getAbsoluteUri(), $this->options)); }
protected function loadConfig() { $configFile = $this->getConfigPath(); if (!file_exists($configFile)) { return; } $config = json_decode(file_get_contents($configFile), true); $testConfig = function ($keys) use($config) { $result = true; foreach ($keys as $key) { if (!array_key_exists($key, $config)) { $result = false; } } return $result; }; $result = $testConfig(['email', 'password', 'user.agent', 'proxy.http']); if ($result) { $client = new Client(); $client->setEmail($config['email']); $client->setPassword($config['password']); $client->setUserAgent($config['user.agent']); if ($config['user.agent'] !== null) { $client->setUserAgent($config['user.agent']); } if ($config['proxy.http'] !== null) { $ex = explode(':', $config['proxy.http']); $proxy = new HttpProxy($ex[0], $ex[1], isset($ex[2]) ? $ex[2] : null, isset($ex[3]) ? $ex[3] : null); $client->setProxy($proxy); } $this->erpkClient = $client; } }
/** * @return Session */ public function getSession() { return $this->client->getSession(); }