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\SDKException; |
7
|
|
|
use Carpenstar\ByBitAPI\Core\Builders\RestBuilder; |
8
|
|
|
use Carpenstar\ByBitAPI\Core\Interfaces\IResponseInterface; |
9
|
|
|
use Carpenstar\ByBitAPI\Core\Interfaces\ISuccessCurlResponseDtoInterface; |
10
|
|
|
use Carpenstar\ByBitAPI\Core\Interfaces\IParametersInterface; |
11
|
|
|
use Carpenstar\ByBitAPI\WebSockets\Builders\WebSocketsBuilder; |
|
|
|
|
12
|
|
|
|
13
|
|
|
class BybitAPI |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @param string $host |
17
|
|
|
* @return $this |
18
|
|
|
*/ |
19
|
|
|
public function setHost(string $host): self |
20
|
|
|
{ |
21
|
|
|
Credentials::setHost($host); |
22
|
|
|
return $this; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param string $apiKey |
27
|
|
|
* @return $this |
28
|
|
|
*/ |
29
|
|
|
public function setApiKey(string $apiKey): self |
30
|
|
|
{ |
31
|
|
|
Credentials::setApiKey($apiKey); |
32
|
|
|
return $this; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param string $secret |
37
|
|
|
* @return $this |
38
|
|
|
*/ |
39
|
|
|
public function setSecret(string $secret): self |
40
|
|
|
{ |
41
|
|
|
Credentials::setSecret($secret); |
42
|
|
|
return $this; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param string $endpointClassName |
47
|
|
|
* @param IParametersInterface|null $parameters |
48
|
|
|
* @return IResponseInterface |
49
|
|
|
* @throws \Exception |
50
|
|
|
*/ |
51
|
|
|
public function rest(string $endpointClassName, ?IParametersInterface $parameters = null): IResponseInterface |
52
|
|
|
{ |
53
|
|
|
return RestBuilder::make($endpointClassName, $parameters)->execute(); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param string $host |
58
|
|
|
* @param string $endpointClassName |
59
|
|
|
* @param IParametersInterface|null $parameters |
60
|
|
|
* @return IResponseInterface |
61
|
|
|
* @throws SDKException |
62
|
|
|
*/ |
63
|
|
|
public function publicEndpoint(string $endpointClassName, ?IParametersInterface $parameters = null): IResponseInterface |
64
|
|
|
{ |
65
|
|
|
if (empty(Credentials::getHost())) { |
66
|
|
|
throw new SDKException("Host must be specified"); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
return $this->rest($endpointClassName, $parameters); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param string $host |
74
|
|
|
* @param string $apiKey |
75
|
|
|
* @param string $secret |
76
|
|
|
* @param string $endpointClassName |
77
|
|
|
* @param IParametersInterface|null $parameters |
78
|
|
|
* @return IResponseInterface |
79
|
|
|
* @throws SDKException |
80
|
|
|
*/ |
81
|
|
|
public function privateEndpoint(string $endpointClassName, ?IParametersInterface $parameters = null): IResponseInterface |
82
|
|
|
{ |
83
|
|
|
if (empty(Credentials::getHost())) { |
84
|
|
|
throw new SDKException("Host must be specified"); |
85
|
|
|
} |
86
|
|
|
if (empty(Credentials::getApiKey())) { |
87
|
|
|
throw new SDKException("Api key must be specified"); |
88
|
|
|
} |
89
|
|
|
if (empty(Credentials::getSecret())) { |
90
|
|
|
throw new SDKException("Client secret must be specified"); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
return $this->rest($endpointClassName, $parameters); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @param string $webSocketChannelClassName |
98
|
|
|
* @param array $data |
99
|
|
|
* @return void |
100
|
|
|
* @throws \Exception |
101
|
|
|
*/ |
102
|
|
|
public function websocket(string $webSocketChannelClassName, IWebSocketArgumentInterface $data, IChannelHandlerInterface $channelHandler, int $mode = EnumOutputMode::MODE_ENTITY, int $wsClientTimeout = IWebSocketArgumentInterface::DEFAULT_SOCKET_CLIENT_TIMEOUT): void |
|
|
|
|
103
|
|
|
{ |
104
|
|
|
WebSocketsBuilder::make($webSocketChannelClassName, $data, $channelHandler, $mode, $wsClientTimeout)->execute(); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
|
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