1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Carpenstar\ByBitAPI\Core\Response; |
4
|
|
|
|
5
|
|
|
use Carpenstar\ByBitAPI\Core\Helpers\DateTimeHelper; |
6
|
|
|
use Carpenstar\ByBitAPI\Core\Interfaces\ICollectionInterface; |
7
|
|
|
use Carpenstar\ByBitAPI\Core\Interfaces\ISuccessCurlResponseDtoInterface; |
8
|
|
|
|
9
|
|
|
class SuccessCurlResponseDto implements ISuccessCurlResponseDtoInterface |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @var \DateTime $time |
13
|
|
|
*/ |
14
|
|
|
private \DateTime $time; |
15
|
|
|
/** |
16
|
|
|
* @var int $retCode |
17
|
|
|
*/ |
18
|
|
|
private int $retCode; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var string $retMsg |
22
|
|
|
*/ |
23
|
|
|
private string $retMsg; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var array $retExtInfo |
27
|
|
|
*/ |
28
|
|
|
private array $retExtInfo = []; |
29
|
|
|
|
30
|
|
|
private string $nextPageCursor; |
31
|
|
|
|
32
|
|
|
private ICollectionInterface $body; |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param int $code |
37
|
|
|
* @return SuccessCurlResponseDto |
38
|
|
|
*/ |
39
|
|
|
public function setReturnCode(int $code): self |
40
|
|
|
{ |
41
|
|
|
$this->retCode = $code; |
42
|
|
|
return $this; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return int |
47
|
|
|
*/ |
48
|
|
|
public function getReturnCode(): int |
49
|
|
|
{ |
50
|
|
|
return $this->retCode; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param string $message |
55
|
|
|
* @return SuccessCurlResponseDto |
56
|
|
|
*/ |
57
|
|
|
public function setReturnMessage(string $message): self |
58
|
|
|
{ |
59
|
|
|
$this->retMsg = $message; |
60
|
|
|
return $this; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return string |
65
|
|
|
*/ |
66
|
|
|
public function getReturnMessage(): string |
67
|
|
|
{ |
68
|
|
|
return $this->retMsg; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param array $extInfo |
73
|
|
|
* @return SuccessCurlResponseDto |
74
|
|
|
*/ |
75
|
|
|
public function setReturnExtendedInfo(array $extInfo): self |
76
|
|
|
{ |
77
|
|
|
$this->retExtInfo = $extInfo; |
78
|
|
|
return $this; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return array |
83
|
|
|
*/ |
84
|
|
|
public function getReturnExtendedInfo(): array |
85
|
|
|
{ |
86
|
|
|
return $this->retExtInfo; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @param int $time |
91
|
|
|
* @return SuccessCurlResponseDto |
92
|
|
|
*/ |
93
|
|
|
public function setTime(int $time): self |
94
|
|
|
{ |
95
|
|
|
$this->time = DateTimeHelper::makeFromTimestamp($time); |
96
|
|
|
return $this; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @return \DateTime |
101
|
|
|
*/ |
102
|
|
|
public function getTime(): \DateTime |
103
|
|
|
{ |
104
|
|
|
return $this->time; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @param $collection |
109
|
|
|
* @return $this |
110
|
|
|
*/ |
111
|
|
|
public function setBody($collection): self |
112
|
|
|
{ |
113
|
|
|
$this->body = $collection; |
114
|
|
|
return $this; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @return array|null |
119
|
|
|
*/ |
120
|
|
|
public function getResult(): ICollectionInterface |
121
|
|
|
{ |
122
|
|
|
return $this->body; |
|
|
|
|
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
public function setNextPageCursor(string $cursor): self |
126
|
|
|
{ |
127
|
|
|
$this->nextPageCursor = $cursor; |
128
|
|
|
return $this; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
public function getNextPageCursor(): ?string |
132
|
|
|
{ |
133
|
|
|
return $this->nextPageCursor; |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
|