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