|
1
|
|
|
<?php |
|
2
|
|
|
namespace Carpenstar\ByBitAPI; |
|
3
|
|
|
|
|
4
|
|
|
use Carpenstar\ByBitAPI\Core\Auth\Credentials; |
|
5
|
|
|
use Carpenstar\ByBitAPI\Core\Enums\EnumOutputMode; |
|
6
|
|
|
use Carpenstar\ByBitAPI\Core\Exceptions\ApiException; |
|
7
|
|
|
use Carpenstar\ByBitAPI\Core\Exceptions\SDKException; |
|
8
|
|
|
use Carpenstar\ByBitAPI\Core\Builders\RestBuilder; |
|
9
|
|
|
use Carpenstar\ByBitAPI\Core\Interfaces\IResponseInterface; |
|
10
|
|
|
use Carpenstar\ByBitAPI\Core\Interfaces\ISuccessCurlResponseDtoInterface; |
|
11
|
|
|
use Carpenstar\ByBitAPI\Core\Interfaces\IParametersInterface; |
|
12
|
|
|
use Carpenstar\ByBitAPI\WebSockets\Builders\WebSocketsBuilder; |
|
|
|
|
|
|
13
|
|
|
use Carpenstar\ByBitAPI\WebSockets\Objects\Channels\Interfaces\IChannelHandlerInterface; |
|
|
|
|
|
|
14
|
|
|
use Carpenstar\ByBitAPI\WebSockets\Objects\WebSockets\Interfaces\IWebSocketArgumentInterface; |
|
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
class BybitAPI |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* @param string $host |
|
20
|
|
|
* @param string $apiKey |
|
21
|
|
|
* @param string $secret |
|
22
|
|
|
*/ |
|
23
|
|
|
public function __construct(string $host = null, string $apiKey = null, string $secret = null) |
|
24
|
|
|
{ |
|
25
|
|
|
if (!empty($host)) { |
|
26
|
|
|
Credentials::setHost($host); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
if (!empty($apiKey)) { |
|
30
|
|
|
Credentials::setApiKey($apiKey); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
if (!empty($secret)) { |
|
34
|
|
|
Credentials::setSecret($secret); |
|
35
|
|
|
} |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param string $endpointClassName |
|
40
|
|
|
* @param IParametersInterface|null $parameters |
|
41
|
|
|
* @param int|null $resultMode |
|
42
|
|
|
* @return ISuccessCurlResponseDtoInterface |
|
43
|
|
|
* @throws SDKException |
|
44
|
|
|
*/ |
|
45
|
|
|
public function rest(string $endpointClassName, ?IParametersInterface $parameters = null): IResponseInterface |
|
46
|
|
|
{ |
|
47
|
|
|
return RestBuilder::make($endpointClassName, $parameters)->execute(); |
|
|
|
|
|
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @param string $host |
|
52
|
|
|
* @param string $endpointClassName |
|
53
|
|
|
* @param IParametersInterface|null $parameters |
|
54
|
|
|
* @return IResponseInterface |
|
55
|
|
|
* @throws SDKException |
|
56
|
|
|
*/ |
|
57
|
|
|
public function publicEndpoint(string $host, string $endpointClassName, ?IParametersInterface $parameters = null): IResponseInterface |
|
58
|
|
|
{ |
|
59
|
|
|
Credentials::setHost($host); |
|
60
|
|
|
return $this->rest($endpointClassName, $parameters); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @param string $host |
|
65
|
|
|
* @param string $apiKey |
|
66
|
|
|
* @param string $secret |
|
67
|
|
|
* @param string $endpointClassName |
|
68
|
|
|
* @param IParametersInterface|null $parameters |
|
69
|
|
|
* @return IResponseInterface |
|
70
|
|
|
* @throws SDKException |
|
71
|
|
|
*/ |
|
72
|
|
|
public function privateEndpoint(string $host, string $apiKey, string $secret, string $endpointClassName, ?IParametersInterface $parameters = null): IResponseInterface |
|
73
|
|
|
{ |
|
74
|
|
|
Credentials::setHost($host); |
|
75
|
|
|
Credentials::setApiKey($apiKey); |
|
76
|
|
|
Credentials::setSecret($secret); |
|
77
|
|
|
return $this->rest($endpointClassName, $parameters); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @param string $webSocketChannelClassName |
|
82
|
|
|
* @param array $data |
|
83
|
|
|
* @return void |
|
84
|
|
|
* @throws \Exception |
|
85
|
|
|
*/ |
|
86
|
|
|
public function websocket(string $webSocketChannelClassName, IWebSocketArgumentInterface $data, IChannelHandlerInterface $channelHandler, int $mode = EnumOutputMode::MODE_ENTITY, int $wsClientTimeout = IWebSocketArgumentInterface::DEFAULT_SOCKET_CLIENT_TIMEOUT): void |
|
87
|
|
|
{ |
|
88
|
|
|
WebSocketsBuilder::make($webSocketChannelClassName, $data, $channelHandler, $mode, $wsClientTimeout)->execute(); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths