1
|
|
|
<?php |
2
|
|
|
namespace Carpenstar\ByBitAPI\Core\Endpoints; |
3
|
|
|
|
4
|
|
|
use Carpenstar\ByBitAPI\Core\Enums\EnumHttpMethods; |
5
|
|
|
use Carpenstar\ByBitAPI\Core\Enums\EnumOutputMode; |
6
|
|
|
use Carpenstar\ByBitAPI\Core\Exceptions\ApiException; |
7
|
|
|
use Carpenstar\ByBitAPI\Core\Interfaces\IEndpointInterface; |
8
|
|
|
use Carpenstar\ByBitAPI\Core\Interfaces\IOptionsInterface; |
9
|
|
|
use Carpenstar\ByBitAPI\Core\Interfaces\IResponseInterface; |
10
|
|
|
use Carpenstar\ByBitAPI\Core\Objects\ResponseEntity; |
11
|
|
|
use Carpenstar\ByBitAPI\Core\Objects\StubQueryBag; |
12
|
|
|
use Carpenstar\ByBitAPI\Core\Request\Curl; |
13
|
|
|
use Carpenstar\ByBitAPI\Core\Request\GetRequest; |
14
|
|
|
use Carpenstar\ByBitAPI\Core\Request\PostRequest; |
15
|
|
|
use Carpenstar\ByBitAPI\Spot\Trade\PlaceOrder\PlaceOrder; |
|
|
|
|
16
|
|
|
|
17
|
|
|
abstract class Endpoint implements IEndpointInterface |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var string HTTP-метод GET, POST и т.д |
21
|
|
|
*/ |
22
|
|
|
protected string $method; |
23
|
|
|
protected string $url; |
24
|
|
|
protected int $outputMode; |
25
|
|
|
protected IOptionsInterface $options; |
26
|
|
|
|
27
|
|
|
abstract protected function getResponseClassname(): string; |
28
|
|
|
abstract protected function getOptionsClassname(): string; |
29
|
|
|
abstract protected function getEndpointUrl(): string; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @return string |
33
|
|
|
*/ |
34
|
|
|
public function getMethod(): string |
35
|
|
|
{ |
36
|
|
|
return $this->method; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function setOutputMode(int $outputMode): self |
40
|
|
|
{ |
41
|
|
|
$this->outputMode = $outputMode; |
42
|
|
|
return $this; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function getOutputMode(): int |
46
|
|
|
{ |
47
|
|
|
return $this->outputMode; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param IOptionsInterface $options |
52
|
|
|
* @return $this |
53
|
|
|
* @throws ApiException |
54
|
|
|
*/ |
55
|
|
|
public function bindRequestOptions(?IOptionsInterface $options): self |
56
|
|
|
{ |
57
|
|
|
if (get_class($options ?? new StubQueryBag()) != $this->getOptionsClassname()) { |
58
|
|
|
throw new ApiException(get_class($options) . " must be instance of " . $this->getOptionsClassname()); |
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
$this->options = $options ?? new StubQueryBag(); |
62
|
|
|
return $this; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return IOptionsInterface |
67
|
|
|
*/ |
68
|
|
|
public function getRequestOptions(): IOptionsInterface |
69
|
|
|
{ |
70
|
|
|
return $this->options; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function execute(): IResponseInterface |
74
|
|
|
{ |
75
|
|
|
switch (static::HTTP_METHOD) { |
|
|
|
|
76
|
|
|
case EnumHttpMethods::GET: |
77
|
|
|
$request = GetRequest::getInstance(static::IS_NEED_AUTHORIZATION); |
|
|
|
|
78
|
|
|
break; |
79
|
|
|
case EnumHttpMethods::POST: |
80
|
|
|
$request = PostRequest::getInstance(static::IS_NEED_AUTHORIZATION); |
81
|
|
|
break; |
82
|
|
|
default: |
83
|
|
|
throw new \Exception("Http Method not detected"); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
$response = $request |
87
|
|
|
->exec($this->getEndpointUrl(), $this->getRequestOptions()->fetchArray()) |
88
|
|
|
->bindEntity(static::getResponseClassname()); |
|
|
|
|
89
|
|
|
|
90
|
|
|
return $response->handle($this->getOutputMode()); |
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