Save api credentioals.

@param string $apiUser
@param string $apiPass

@return bool
495447
public function saveApiCreds($apiUser, $apiPass)
    {
        $this->helper->saveConfigData(
            Config::XML_PATH_CONNECTOR_API_ENABLED,
            '1',
            'default',
            0
        );
        $this->helper->saveConfigData(
            Config::XML_PATH_CONNECTOR_API_USERNAME,
            $apiUser,
            'default',
            0
        );

        //Save encrypted password
        $this->helper->saveConfigData(
            Config::XML_PATH_CONNECTOR_API_PASSWORD,
            $this->helper->encryptor->encrypt($apiPass),
            'default',
            0
        );

        //Clear config cache
        $this->config->reinit();

        return true;
    }
41256
public function onSave(ArrayAccess $parameters, $namespace = null)
    {

        $exception = false;
        if (is_null($namespace)) {
            return true;
        }
        try {
            $fieldsCollection = $this->field->query()->where('namespace', $namespace)->get();
            if ($fieldsCollection->isEmpty()) {
                return true;
            }
            $collection = [];

            $fieldsCollection->each(function($field) use(&$collection) {

                if (array_key_exists($field->name, $this->input)) {
                    $collection[$field->id] = $this->input[$field->name];
                }
            });
            call_user_func_array([$this, 'save'], [$collection, $parameters->id, $namespace]);
        } catch (\Exception $e) {

            $exception = $e;
        }

        return $exception === false;
    }
970533
public static function create_and_buy($params = null, $apiKey = null)
    {
        $class = get_class();
        if (!isset($params['batch']) || !is_array($params['batch'])) {
            $clone = $params;
            unset($params);
            $params['batch'] = $clone;
        }

        $requestor = new Requestor($apiKey);
        $url = self::classUrl($class);
        list($response, $apiKey) = $requestor->request('post', $url.'/create_and_buy', $params);

        return Util::convertToEasyPostObject($response, $apiKey);
    }
1285098
public function setApiUri(string $apiUri): Client
    {
        $this->apiUri = $apiUri;
        $this->setUris();

        return $this;
    }
95661
public static function all_api_keys($apiKey = null)
    {
        $requestor = new Requestor($apiKey);
        list($response, $apiKey) = $requestor->request('get', '/api_keys');
        return Util::convertToEasyPostObject($response, $apiKey);
    }
558161
public function save($sendEmail = false)
    {
        // If the parent form saved and validated
        if (parent::save($sendEmail))
        {
            // Then bind the identity to this user permanently
	    $meta = UserMetadata::model()->generatePrototype('UserMetadata', array(
		'user_id' => $this->_user->id,
		'key' => $this->provider.'Provider',
	    ));

	    $meta->value = $this->adapter->identifier;

            // Save the associative object
            return $meta->save();
        }

        return false;
    }
49764
public function save($userid, $apikey, $scope, $name, $args, $xml)
    {
        $filename = $this->filename($userid, $apikey, $scope, $name, $args);
        file_put_contents($filename, $xml);
        chmod($filename, $this->options['umask']);
    }
199613
public function save($userid, $apikey, $scope, $name, $args, $xml)
    {
        $this->prepareStatements();

        $argumentString = $this->serializeArguments($args);

        /* @var $deleteStatement \PDOStatement */
        $deleteStatement = $this->statements['delete'];

        if ($userid === null) {
            // Fix for null value userids
            // e. g. for global calls to /eve/
            $userid = 0;
        }

        try {
            $deleteStatement->execute(
                array(
                    ':userId' => $userid,
                    ':scope'  => $scope,
                    ':name'   => $name,
                    ':args'   => $argumentString,
                )
            );
        } catch (\PDOException $e) {
            throw new PhealException('Deleting old cache entries failed!', null, $e);
        }

        /* @var $statement \PDOStatement */
        $statement = $this->statements['save'];

        try {
            $xml = new \SimpleXMLElement($xml);

            $statement->execute(
                array(
                    ':userId' => $userid,
                    ':scope'  => $scope,
                    ':name'   => $name,
                    ':args'   => $argumentString,
                    ':cachedUntil' => $xml->cachedUntil,
                    ':xml'    => $xml->asXML(),
                )
            );
        } catch (\PDOException $e) {
            throw new PhealException('Saving to cache failed!', null, $e);
        }
    }
613005
public function save($userid, $apikey, $scope, $name, $args, $xml)
    {
        $key = $this->getKey($userid, $apikey, $scope, $name, $args);
        $ttl = $this->getTimeout($xml);
        $time = time();
        $timeout = $time + $ttl;

        $replace = $this->memcached->replace($key, $xml, $timeout);

        $set = $set_age = false;

        if (!$replace) {
            $set = $this->memcached->set($key, $xml, $timeout);
        }

        $replace_age = $this->memcached->replace($key.'_age', array('age' => $time, 'ttl' => $ttl), $timeout);

        if (!$replace_age) {
            $set_age = $this->memcached->set($key.'_age', array('age' => $time, 'ttl' => $ttl), $timeout);
        }

        return (($replace || $set) && ($replace_age || $set_age));
    }
633755
public function login($username, $password, $scope = 'user_info')
	{
		$response = $this->http->post($this->getUrl('oauth/token'), array(
			'grant_type'	=>	'password',
			'username'		=>	$username,
			'password'		=>	$password,
			'client_id'		=>	$this->appid,
			'client_secret'	=>	$this->appSecret,
			'scope'			=>	$scope,
		));
		$this->result = $response->json(true);
		if(!isset($this->result['error']))
		{
			return $this->accessToken = $this->result['access_token'];
		}
		else
		{
			throw new ApiException(isset($this->result['error_description']) ? $this->result['error_description'] : '', $response->httpCode());
		}
	}
489793
protected function queryXml($apiUrl, $apiServiceFilter = null)
    {
        $useCache = self::$useCache;

        if ($apiServiceFilter) {
            $url = $apiUrl . $apiServiceFilter->getURLQuery();
        } else {
            $url = $apiUrl;
        }

        // no cache, so query from server
        if (!$useCache || $this->cacheManager->has(md5($url)) == false) {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_HEADER, true);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

            // additional headers
            $headers = [
          'User-Agent: ' . \RGU\Dvoconnector\Utility\EmConfiguration::getSettings()->getHttpUserAgent(),
      ];
            if (!$useCache) {
                $headers[] = 'Cache-Control: no-cache';
            }
            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

            $response = curl_exec($ch);

            // separate response into header and body
            list($header, $body) = explode("\r\n\r\n", $response, 2);

            // check for response-code 200
            $headers = explode("\r\n", $header);
            $responseCode = preg_replace('/HTTP\/.* ([0-9]+) .*/', '${1}', $headers[0]);
            if ($responseCode{0} != '2') {
                throw new \Exception('Unexpected HTTP response code: ' . $responseCode . '|' . $url);
            }

            // caching
            if (!preg_match('/.*Cache-Control: .*no-cache.*/sm', $header)) {
                // check for Cache-Control max-age param
                $maxAge = preg_replace('/.*Cache-Control: .*max-age=(\d+).*/sm', '${1}', $header);

                // cache response
                $this->writeCache(md5($url), $body, ($maxAge == '') ? \RGU\Dvoconnector\Utility\EmConfiguration::getSettings()->getCachetime() : (int)$maxAge);
            }
        } elseif ($useCache && $this->cacheManager->has(md5($url)) == true) {
            $body = $this->readCache(md5($url));
        }

        try {
            $xml = new \SimpleXMLElement($body);
        } catch (\Exception $e) {
            throw $e;
        }

        return $xml;
    }
896828
public function post($apiQuery, $options = array())
    {
        if (!RequestApi::isPost($apiQuery)) {
            throw new \InvalidArgumentException('Unsupported API query for POST method: ' . $apiQuery);
        }

        $request = $this->getApi()->post($apiQuery, null, $options);

        $this->prepareRequest($request, $options);

        $response = $request->send();

        return $this->processResponse($response);
    }
878596
private function getRoles(ApiUserInterface $user)
    {
        $roles = $user->getRoles();
        if ($user->getApiKeyEnabled()) {
            $roles[] = $this->apiUserRole;
        }

        return $roles;
    }
1109646
public function login($apiUser = null, $apiKey = null)
    {
        if (null === $apiUser) {
            $apiUser = $this->apiUser;
        }

        if (null === $apiKey) {
            $apiKey = $this->apiKey;
        }

        if ($this->sessionId = $this->soapClient->login($apiUser, $apiKey)) {
            return true;
        }

        return false;
    }
867757
public function bind($bindUser = null, $bindPass = null)
    {
        if (false === ldap_bind($this->ldapResource, $bindUser, $bindPass)) {
            throw new LdapClientException(
                sprintf(
                    'LDAP error: (%d) %s',
                    ldap_errno($this->ldapResource),
                    ldap_error($this->ldapResource)
                )
            );
        }
    }
343154
public static function create(ApiClientInterface $client, UserInterface $user = null)
    {
        $accessToken = new self();
        $accessToken->setUser($user);
        $accessToken->setClient($client);

        return $accessToken;
    }
901372
public function save(User $user, Request $request)
    {
        $permissions = $request->get('permissions', []);
        $roles = $request->input('user.roles', []);

        foreach ($permissions as $key => $value) {
            unset($permissions[$key]);
            $permissions[base64_decode($key)] = $value;
        }

        $user
            ->fill($request->get('user'))
            ->replaceRoles($roles)
            ->fill([
                'permissions' => $permissions,
            ])
            ->save();

        Alert::info(__('User was saved'));

        return redirect()->route('platform.systems.users');
    }