-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFactory.php
36 lines (29 loc) · 1.02 KB
/
Factory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
namespace Jaddek\Fireblocks\Http;
use Jaddek\Fireblocks\Http\Endpoint\Endpoint;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Contracts\HttpClient\HttpClientInterface;
final class Factory
{
public static function buildCollection(string $key, string $secretKey): EndpointCollection
{
$signer = new Signer($key, $secretKey);
$httpClient = self::getHttpClient($key);
return new EndpointCollection($httpClient, $signer);
}
public static function buildEndpoint(string $class, string $key, string $secretKey): Endpoint
{
$signer = new Signer($key, $secretKey);
$httpClient = self::getHttpClient($key);
return new $class($httpClient, $signer);
}
private static function getHttpClient(string $key): HttpClientInterface
{
return HttpClient::createForBaseUri(Fireblocks::HOST_API, [
'headers' => array_merge(
['X-API-Key' => $key],
Fireblocks::DEFAULT_HEADERS,
)
]);
}
}