public function setUp() { $configuration = (include __DIR__ . '/config.php'); $client = new Client($configuration['contacts_login']); $client->setPasswordHash($configuration['contacts_password']); if ($this->proxy instanceof Native) { $proxy = new Native($configuration['contacts_host']); } else { $proxy = new Curl($configuration['contacts_host']); } $this->contactsFactory = new ContactsFactory($proxy, $this->getClient()); }
/** * Login * * @return SMSApi\Api\SmsFactory; */ public function login() { $client = new Client($this->config['login']); $client->setPasswordHash(md5($this->config['password'])); $proxy = null; if ($this->config['second_channel']) { $proxy = new Native('https://api2.smsapi.pl'); } $smsapi = new SmsFactory($proxy); $smsapi->setClient($client); return $smsapi; }
/** * Prepare client configuration * @return SMSApi\Client * @throws ConfigurationException */ private function getClient() { $login = $this->getParam('login'); $passwordHash = $this->getParam('passwd_hash'); $token = $this->getParam('token'); if (empty($token) && (empty($login) || empty($passwordHash))) { throw new ConfigurationException(__CLASS__ . ' is not configured properly. Please set "token" or "login" and "passwd_pash" parameters properly.'); } $client = null; if (!empty($token)) { $client = Client::createFromToken($token); } else { $client = new Client($login); $client->setPasswordHash($passwordHash); } return $client; }