Make a client.

@param string  $apiKey
@param string|null $signatureKey

@return $this
972617
public static function make(string $apiKey, ?string $signatureKey = null)
    {
        return new static(Discovery::client(), $apiKey, $signatureKey);
    }
578033
public function sendRequest(ApiKey $apiKey, RestRequest $request)
    {
        $hmac = $this->generateHmac($apiKey->getPrivateKey(), $request->getEndpoint(), array_merge($request->getQueryData(), $request->getPostData()));

        $client = new Client([
            'base_uri' => $request->getHost()
        ]);
        
        $args = [
            'auth' => [$apiKey->getPublicKey(), $hmac],
            'headers' => [
                'Accept' => 'application/json'
            ]
        ];
        
        if ($request->getRequestMethod() === 'POST') {
            $args['form_params'] = $request->getPostData();
        } else {
            $args['query'] = $request->getQueryData();
        }
        
        try {
            $responseRaw = $client->request($request->getRequestMethod(), $request->getEndpoint(), $args);
        } catch (RequestException $e) {
            if (!$e->hasResponse()) {
                throw new Exception('Cannot send REST request.', 0, $e);
            }
            
            $responseRaw = $e->getResponse();
        }
        
        return $this->prepareResponse($responseRaw, $request);
    }
319284
public function doCall($serverKey, $request) {
    $client = $this->getClient($serverKey);
    if ($client) {
      $response = $client->call($request);
      return $response;
    }
    return ObjectFactory::getNewInstance('response');
  }
884744
public static function generateSignature($apiUser, $apiKey)
    {
        $serverTimezone = date_default_timezone_get();
        date_default_timezone_set('UTC');

        $nonce = self::generateNonce(self::NONCE_LENGTH);
        $time = time();
        $signature = hash_hmac('sha1', $apiUser . $nonce . $time, $apiKey);

        $data = [
            'REB-APIUSER' => $apiUser,
            'REB-NONCE' => $nonce,
            'REB-TIMESTAMP' => $time,
            'REB-SIGNATURE' => $signature,
        ];

        date_default_timezone_set($serverTimezone);

        return base64_encode(json_encode($data));
    }
651113
public static function setKey($key, ClientInterface $client = null)
	{
		self::$api = new Api($key, $client);

		return self::$api;
	}
1053114
public function sign(Signer $signer, $key)
    {
        $signer->modifyHeader($this->headers);

        $this->signature = $signer->sign(
            $this->getToken()->getPayload(),
            $key
        );

        return $this;
    }
773079
public function setClient(ClientInterface $client = null): self
    {
        if (null === $client) {
            $this->client = new Client();

            return $this;
        }

        $this->client = $client;

        return $this;
    }
415984
protected function createAuthCode($userkey, $applicationkey) {
        $payload = $userkey . "@" . strtolower($this->serverhostname) . "|" . strtolower($applicationkey);
        return strtoupper(sha1($payload));
    }
841520
public ReplicationClientFactory usingApiKey(String apiKey) {
        if (Objects.equal(_apiKey, apiKey)) {
            return this;
        }
        return new ReplicationClientFactory(_jerseyClient, apiKey);
    }
704289
protected function createClient()
    {
        $client = new MultiCurl();

        $credentials     = $this->getCredentials();
        $isAuthenticated = $credentials instanceof SSLCertificate;

        $client->setVerifyPeer($isAuthenticated);

        if ($isAuthenticated) {
            $client->setOption(CURLOPT_SSLCERT, $credentials->getCertificatePassPhrase());
            $client->setOption(CURLOPT_SSLCERTPASSWD, $credentials->getCertificatePassPhrase());
        }

        $this->serviceClient = new Browser($client);

        return $this;
    }
1071845
public function setClient(\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Client\Client $client = null)
    {
        $this->client = $client;

        return $this;
    }
171461
public function api_keys($apiKey = null)
    {
        $api_keys = self::all_api_keys();
        $my_api_keys = null;

        if ($api_keys->id == $this->id) {
            $my_api_keys = $api_keys->keys;
        }
        if (is_null($my_api_keys)) {
            foreach($api_keys->children as $children_keys) {
                if ($children_keys->id == $this->id) {
                    $my_api_keys = $children_keys->keys;
                }
            }
        }

        if (is_null($my_api_keys)) {
            return null;
        } else {
            $response = array();
            foreach($my_api_keys as $key) {
                $response[$key->mode] = $key->key;
            }
            return $response;
        }
    }
994388
public function setApiKey($apiKey)
    {
        $key = base64_decode($apiKey, true);
        if ($key === false) {
            throw new \InvalidArgumentException('Invalid API key');
        }

        $this->apiKey = $key;
        return $this;
    }
45499
public static function create($params = null, $apiKey = null)
    {
        $class = get_class();
        return self::_scopedCreate($class, $params, $apiKey);
    }
771338
public static function create($baseUrl, $signKey = null)
    {
        $httpSignature = null;

        if (!is_null($signKey)) {
            $httpSignature = SignatureFactory::create($signKey);
        }

        return new UrlBuilder($baseUrl, $httpSignature);
    }
1234041
protected function client()
    {
        $apiKey = $this->config('apiKey');
        if (!$apiKey) {
            return null;
        }

        $endpoint = $this->config('endpoint');
        $defaults = $this->config('defaults');
        if ($defaults === null) {
            $defaults = true;
        }
        $client = Client::make($apiKey, $endpoint, $defaults);

        return $client;
    }
196129
public static function make($key, $resource, $version = 'v2')
    {
        $client = new Client($key, $version);

        $namespace = 'Rule\\ApiWrapper\\Api\\' . strtoupper($version) . '\\' . ucfirst($resource) . '\\';
        $classname = $namespace . ucfirst($resource);

        if (!class_exists($classname)) {
            throw new InvalidResourceException("Invalid resource name providen or api version not supported");
        }

        return new $classname($client);
    }