/** * Generate an Intacct session based on login credentials * * @param LoginCredentials $loginCreds * @return SessionCredentials */ public function fromLoginCredentials(LoginCredentials $loginCreds) { $senderCreds = $loginCreds->getSenderCredentials(); $endpoint = $loginCreds->getEndpoint(); $config = $this->getConfig($senderCreds, $endpoint); $config['company_id'] = $loginCreds->getCompanyId(); $config['user_id'] = $loginCreds->getUserId(); $config['user_password'] = $loginCreds->getPassword(); $config['mock_handler'] = $loginCreds->getMockHandler(); $session = $this->getAPISession($config); return new SessionCredentials($session, $senderCreds); }
/** * @covers Intacct\Credentials\LoginCredentials::__construct * @covers Intacct\Credentials\LoginCredentials::getCompanyId * @covers Intacct\Credentials\LoginCredentials::getUserId * @covers Intacct\Credentials\LoginCredentials::getPassword */ public function testCredsFromProfile() { $dir = $this->clearEnv(); $ini = <<<EOF [unittest] company_id = inicompanyid user_id = iniuserid user_password = iniuserpass EOF; file_put_contents($dir . '/credentials.ini', $ini); putenv('HOME=' . dirname($dir)); $config = ['profile_name' => 'unittest']; $loginCreds = new LoginCredentials($config, $this->senderCreds); $this->assertEquals('inicompanyid', $loginCreds->getCompanyId()); $this->assertEquals('iniuserid', $loginCreds->getUserId()); $this->assertEquals('iniuserpass', $loginCreds->getPassword()); }