/
Matej.php
86 lines (69 loc) · 2.02 KB
/
Matej.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php declare(strict_types=1);
namespace Lmc\Matej;
use Lmc\Matej\Http\RequestManager;
use Lmc\Matej\Http\ResponseDecoderInterface;
use Lmc\Matej\RequestBuilder\RequestBuilderFactory;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
class Matej
{
public const CLIENT_ID = 'php-client';
public const VERSION = '4.1.0';
/** @var RequestManager */
private $requestManager;
public function __construct(string $accountId, string $apiKey)
{
$this->requestManager = new RequestManager($accountId, $apiKey);
}
public function request(): RequestBuilderFactory
{
return new RequestBuilderFactory($this->getRequestManager());
}
/** @return $this */
public function setHttpClient(ClientInterface $client): self
{
$this->getRequestManager()->setHttpClient($client);
return $this;
}
/**
* @internal used mainly in integration tests
* @return $this
*/
public function setBaseUrl(string $baseUrl): self
{
$this->getRequestManager()->setBaseUrl($baseUrl);
return $this;
}
/**
* @codeCoverageIgnore
* @return $this
*/
public function setHttpMessageFactory(RequestFactoryInterface $messageFactory): self
{
$this->getRequestManager()->setMessageFactory($messageFactory);
return $this;
}
/**
* @codeCoverageIgnore
* @return $this
*/
public function setHttpResponseDecoder(ResponseDecoderInterface $responseDecoder): self
{
$this->getRequestManager()->setResponseDecoder($responseDecoder);
return $this;
}
/**
* @codeCoverageIgnore
* @return $this
*/
public function setStreamFactory(StreamFactoryInterface $streamFactory): self
{
$this->getRequestManager()->setStreamFactory($streamFactory);
return $this;
}
protected function getRequestManager(): RequestManager
{
return $this->requestManager;
}
}