Passed
Push — master ( faa4ac...572ea2 )
by Vladislav
06:35 queued 04:06
created

OpenOrdersResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 20
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 22
rs 9.6
1
<?php
2
namespace Carpenstar\ByBitAPI\Spot\Trade\OpenOrders\Response;
3
4
use Carpenstar\ByBitAPI\Core\Helpers\DateTimeHelper;
5
use Carpenstar\ByBitAPI\Core\Objects\AbstractResponse;
6
use Carpenstar\ByBitAPI\Spot\Trade\OpenOrders\Interfaces\IOpenOrdersResponseInterface;
7
8
class OpenOrdersResponse extends AbstractResponse implements IOpenOrdersResponseInterface
9
{
10
    /**
11
     * Account ID
12
     * @var int accountId
13
     */
14
    private int $accountId;
15
16
    /**
17
     * Name of the trading pair
18
     * @var string $symbol
19
     */
20
    private string $symbol;
21
22
    /**
23
     * User-generated order ID
24
     * @var string $orderLinkId
25
     */
26
    private string $orderLinkId;
27
28
    /**
29
     * Order ID
30
     * @var int $orderId
31
     */
32
    private int $orderId;
33
34
    /**
35
     * Order price
36
     * @var float $orderPrice
37
     */
38
    private float $orderPrice;
39
40
    /**
41
     * Order quantity
42
     * @var float $orderQty
43
     */
44
    private float $orderQty;
45
46
    /**
47
     * Executed quantity
48
     * @var float $execQty
49
     */
50
    private float $execQty;
51
52
    /**
53
     * Total order quantity. For some historical data, it might less than 0, and that means it is not applicable
54
     * @var float $cummulativeQuoteQty
55
     */
56
    private float $cummulativeQuoteQty;
57
58
    /**
59
     * Average filled price
60
     * @var float $avgPrice
61
     */
62
    private float $avgPrice;
63
64
    /**
65
     * Order status
66
     * @var string $status
67
     */
68
    private string $status;
69
70
    /**
71
     * Time in force
72
     * @var string $timeInForce
73
     */
74
    private string $timeInForce;
75
76
    /**
77
     * Order type
78
     * @var string $orderType
79
     */
80
    private string $orderType;
81
82
    /**
83
     * Side. BUY, SELL
84
     * @var string $side
85
     */
86
    private string $side;
87
88
    /**
89
     * Stop price
90
     * @var float $stopPrice
91
     */
92
    private float $stopPrice;
93
94
    /**
95
     * Order created time in the match engine
96
     * @var \DateTime $createTime
97
     */
98
    private \DateTime $createTime;
99
100
    /**
101
     * Last time order was updated
102
     * @var \DateTime $updateTime
103
     */
104
    private \DateTime $updateTime;
105
106
    /**
107
     * Is working. 0:valid, 1:invalid
108
     * @var int $isWorking
109
     */
110
    private int $isWorking;
111
112
    /**
113
     * Order category. 0:normal order; 1:TP/SL order. TP/SL order has this field
114
     * @var int $orderCategory
115
     */
116
    private int $orderCategory;
117
118
    /**
119
     * Trigger price. TP/SL order has this field
120
     * @var float $triggerPrice
121
     */
122
    private ?float $triggerPrice;
123
124
    public function __construct(array $data)
125
    {
126
        $this
127
            ->setAccountId($data['accountId'])
128
            ->setSymbol($data['symbol'])
129
            ->setOrderLinkId($data['orderLinkId'])
130
            ->setOrderId($data['orderId'])
131
            ->setOrderPrice($data['orderPrice'])
132
            ->setOrderQty($data['orderQty'])
133
            ->setExecQty($data['execQty'])
134
            ->setCummulativeQuoteQty($data['cummulativeQuoteQty'])
135
            ->setAvgPrice($data['avgPrice'])
136
            ->setStatus($data['status'])
137
            ->setTimeInForce($data['timeInForce'])
138
            ->setOrderType($data['orderType'])
139
            ->setSide($data['side'])
140
            ->setStopPrice($data['stopPrice'])
141
            ->setCreateTime($data['createTime'])
142
            ->setUpdateTime($data['updateTime'])
143
            ->setIsWorking($data['isWorking'])
144
            ->setOrderCategory($data['orderCategory'] ?? 0)
145
            ->setTriggerPrice($data['triggerPrice'] ?? null);
146
    }
147
148
    /**
149
     * @param int $accountId
150
     * @return OpenOrdersResponse
151
     */
152
    public function setAccountId(int $accountId): self
153
    {
154
        $this->accountId = $accountId;
155
        return $this;
156
    }
157
158
    /**
159
     * @return int
160
     */
161
    public function getAccountId(): int
162
    {
163
        return $this->accountId;
164
    }
165
166
    /**
167
     * @param string $symbol
168
     * @return OpenOrdersResponse
169
     */
170
    public function setSymbol(string $symbol): self
171
    {
172
        $this->symbol = $symbol;
173
        return $this;
174
    }
175
176
    /**
177
     * @return string
178
     */
179
    public function getSymbol(): string
180
    {
181
        return $this->symbol;
182
    }
183
184
    /**
185
     * @param string $orderLinkId
186
     * @return OpenOrdersResponse
187
     */
188
    public function setOrderLinkId(string $orderLinkId): self
189
    {
190
        $this->orderLinkId = $orderLinkId;
191
        return $this;
192
    }
193
194
    /**
195
     * @return string
196
     */
197
    public function getOrderLinkId(): string
198
    {
199
        return $this->orderLinkId;
200
    }
201
202
    /**
203
     * @param int $orderId
204
     * @return OpenOrdersResponse
205
     */
206
    public function setOrderId(int $orderId): self
207
    {
208
        $this->orderId = $orderId;
209
        return $this;
210
    }
211
212
    /**
213
     * @return int
214
     */
215
    public function getOrderId(): int
216
    {
217
        return $this->orderId;
218
    }
219
220
    /**
221
     * @param float $orderPrice
222
     */
223
    public function setOrderPrice(float $orderPrice): self
224
    {
225
        $this->orderPrice = $orderPrice;
226
        return $this;
227
    }
228
229
    /**
230
     * @return float
231
     */
232
    public function getOrderPrice(): float
233
    {
234
        return $this->orderPrice;
235
    }
236
237
    /**
238
     * @param float $orderQty
239
     * @return OpenOrdersResponse
240
     */
241
    public function setOrderQty(float $orderQty): self
242
    {
243
        $this->orderQty = $orderQty;
244
        return $this;
245
    }
246
247
    /**
248
     * @return float
249
     */
250
    public function getOrderQty(): float
251
    {
252
        return $this->orderQty;
253
    }
254
255
    /**
256
     * @param float $execQty
257
     * @return OpenOrdersResponse
258
     */
259
    public function setExecQty(float $execQty): self
260
    {
261
        $this->execQty = $execQty;
262
        return $this;
263
    }
264
265
    /**
266
     * @return float
267
     */
268
    public function getExecQty(): float
269
    {
270
        return $this->execQty;
271
    }
272
273
    /**
274
     * @param float $cummulativeQuoteQty
275
     * @return OpenOrdersResponse
276
     */
277
    public function setCummulativeQuoteQty(float $cummulativeQuoteQty): self
278
    {
279
        $this->cummulativeQuoteQty = $cummulativeQuoteQty;
280
        return $this;
281
    }
282
283
    /**
284
     * @return float
285
     */
286
    public function getCummulativeQuoteQty(): float
287
    {
288
        return $this->cummulativeQuoteQty;
289
    }
290
291
    /**
292
     * @param float $avgPrice
293
     * @return OpenOrdersResponse
294
     */
295
    public function setAvgPrice(float $avgPrice): self
296
    {
297
        $this->avgPrice = $avgPrice;
298
        return $this;
299
    }
300
301
    /**
302
     * @return float
303
     */
304
    public function getAvgPrice(): float
305
    {
306
        return $this->avgPrice;
307
    }
308
309
    /**
310
     * @param string $status
311
     * @return OpenOrdersResponse
312
     */
313
    public function setStatus(string $status): self
314
    {
315
        $this->status = $status;
316
        return $this;
317
    }
318
319
    /**
320
     * @return string
321
     */
322
    public function getStatus(): string
323
    {
324
        return $this->status;
325
    }
326
327
    /**
328
     * @param string $timeInForce
329
     * @return OpenOrdersResponse
330
     */
331
    public function setTimeInForce(string $timeInForce): self
332
    {
333
        $this->timeInForce = $timeInForce;
334
        return $this;
335
    }
336
337
    /**
338
     * @return string
339
     */
340
    public function getTimeInForce(): string
341
    {
342
        return $this->timeInForce;
343
    }
344
345
    /**
346
     * @param string $orderType
347
     * @return OpenOrdersResponse
348
     */
349
    public function setOrderType(string $orderType): self
350
    {
351
        $this->orderType = $orderType;
352
        return $this;
353
    }
354
355
    /**
356
     * @return string
357
     */
358
    public function getOrderType(): string
359
    {
360
        return $this->orderType;
361
    }
362
363
    /**
364
     * @param string $side
365
     * @return OpenOrdersResponse
366
     */
367
    public function setSide(string $side): self
368
    {
369
        $this->side = $side;
370
        return $this;
371
    }
372
373
    /**
374
     * @return string
375
     */
376
    public function getSide(): string
377
    {
378
        return $this->side;
379
    }
380
381
    /**
382
     * @param float $stopPrice
383
     * @return OpenOrdersResponse
384
     */
385
    public function setStopPrice(float $stopPrice): self
386
    {
387
        $this->stopPrice = $stopPrice;
388
        return $this;
389
    }
390
391
    /**
392
     * @return float
393
     */
394
    public function getStopPrice(): float
395
    {
396
        return $this->stopPrice;
397
    }
398
399
    /**
400
     * @param string $createTime
401
     * @return OpenOrdersResponse
402
     */
403
    public function setCreateTime(string $createTime): self
404
    {
405
        $this->createTime = DateTimeHelper::makeFromTimestamp($createTime);
0 ignored issues
show
Bug introduced by
$createTime of type string is incompatible with the type integer expected by parameter $timestamp of Carpenstar\ByBitAPI\Core...er::makeFromTimestamp(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

405
        $this->createTime = DateTimeHelper::makeFromTimestamp(/** @scrutinizer ignore-type */ $createTime);
Loading history...
406
        return $this;
407
    }
408
409
    /**
410
     * @return \DateTime
411
     */
412
    public function getCreateTime(): \DateTime
413
    {
414
        return $this->createTime;
415
    }
416
417
    /**
418
     * @param string $updateTime
419
     * @return OpenOrdersResponse
420
     */
421
    public function setUpdateTime(string $updateTime): self
422
    {
423
        $this->updateTime = DateTimeHelper::makeFromTimestamp($updateTime);
0 ignored issues
show
Bug introduced by
$updateTime of type string is incompatible with the type integer expected by parameter $timestamp of Carpenstar\ByBitAPI\Core...er::makeFromTimestamp(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

423
        $this->updateTime = DateTimeHelper::makeFromTimestamp(/** @scrutinizer ignore-type */ $updateTime);
Loading history...
424
        return $this;
425
    }
426
427
    /**
428
     * @return \DateTime
429
     */
430
    public function getUpdateTime(): \DateTime
431
    {
432
        return $this->updateTime;
433
    }
434
435
    /**
436
     * @param int $isWorking
437
     * @return OpenOrdersResponse
438
     */
439
    public function setIsWorking(int $isWorking): self
440
    {
441
        $this->isWorking = $isWorking;
442
        return $this;
443
    }
444
445
    /**
446
     * @return int
447
     */
448
    public function getIsWorking(): int
449
    {
450
        return $this->isWorking;
451
    }
452
453
    /**
454
     * @param int $orderCategory
455
     * @return OpenOrdersResponse
456
     */
457
    public function setOrderCategory(int $orderCategory): self
458
    {
459
        $this->orderCategory = $orderCategory;
460
        return $this;
461
    }
462
463
    /**
464
     * @return int
465
     */
466
    public function getOrderCategory(): int
467
    {
468
        return $this->orderCategory;
469
    }
470
471
    /**
472
     * @param float $triggerPrice
473
     * @return OpenOrdersResponse
474
     */
475
    public function setTriggerPrice(?float $triggerPrice): self
476
    {
477
        $this->triggerPrice = $triggerPrice;
478
        return $this;
479
    }
480
481
    /**
482
     * @return float
483
     */
484
    public function getTriggerPrice(): ?float
485
    {
486
        return $this->triggerPrice;
487
    }
488
}