|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author Fabian Hanisch |
|
4
|
|
|
* @since 16.07.2017 18:24 |
|
5
|
|
|
* @version 1.0 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace HanischIt\KrakenApi\Call\AddOrder; |
|
9
|
|
|
|
|
10
|
|
|
use HanischIt\KrakenApi\Enum\VisibilityEnum; |
|
11
|
|
|
use HanischIt\KrakenApi\Model\RequestInterface; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class AddOrderRequest |
|
15
|
|
|
* @package HanischIt\KrakenApi\Call\AddOrder |
|
16
|
|
|
*/ |
|
17
|
|
|
class AddOrderRequest implements RequestInterface |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var string |
|
21
|
|
|
*/ |
|
22
|
|
|
private $pair; |
|
23
|
|
|
/** |
|
24
|
|
|
* @var string |
|
25
|
|
|
*/ |
|
26
|
|
|
private $type; |
|
27
|
|
|
/** |
|
28
|
|
|
* @var string |
|
29
|
|
|
*/ |
|
30
|
|
|
private $orderType; |
|
31
|
|
|
/** |
|
32
|
|
|
* @var float |
|
33
|
|
|
*/ |
|
34
|
|
|
private $price; |
|
35
|
|
|
/** |
|
36
|
|
|
* @var float |
|
37
|
|
|
*/ |
|
38
|
|
|
private $volume; |
|
39
|
|
|
/** |
|
40
|
|
|
* @var bool |
|
41
|
|
|
*/ |
|
42
|
|
|
private $validateOnly; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* AddOrderRequest constructor. |
|
46
|
|
|
* |
|
47
|
|
|
* @param string $pair |
|
48
|
|
|
* @param string $type |
|
49
|
|
|
* @param string $orderType |
|
50
|
|
|
* @param float $price |
|
51
|
|
|
* @param float $volume |
|
52
|
|
|
* @param bool $validateOnly |
|
53
|
|
|
*/ |
|
54
|
3 |
|
public function __construct($pair, $type, $orderType, $price, $volume, $validateOnly = false) |
|
55
|
|
|
{ |
|
56
|
3 |
|
$this->pair = $pair; |
|
57
|
3 |
|
$this->type = $type; |
|
58
|
3 |
|
$this->orderType = $orderType; |
|
59
|
3 |
|
$this->price = $price; |
|
60
|
3 |
|
$this->volume = $volume; |
|
61
|
3 |
|
$this->validateOnly = $validateOnly; |
|
62
|
3 |
|
} |
|
63
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Returns the api request name |
|
67
|
|
|
* |
|
68
|
|
|
* @return string |
|
69
|
|
|
*/ |
|
70
|
2 |
|
public function getMethod() |
|
71
|
|
|
{ |
|
72
|
2 |
|
return 'AddOrder'; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @return string |
|
77
|
|
|
*/ |
|
78
|
2 |
|
public function getVisibility() |
|
79
|
|
|
{ |
|
80
|
2 |
|
return VisibilityEnum::VISIBILITY_PRIVATE; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @return array |
|
85
|
|
|
*/ |
|
86
|
2 |
|
public function getRequestData() |
|
87
|
|
|
{ |
|
88
|
2 |
|
$ret = []; |
|
89
|
2 |
|
$ret["pair"] = $this->pair; |
|
90
|
2 |
|
$ret["type"] = $this->type; |
|
91
|
2 |
|
$ret["ordertype"] = $this->orderType; |
|
92
|
2 |
|
if ($this->price) { |
|
93
|
1 |
|
$ret["price"] = $this->price; |
|
94
|
1 |
|
} |
|
95
|
2 |
|
if ($this->volume) { |
|
96
|
1 |
|
$ret["volume"] = $this->volume; |
|
97
|
1 |
|
} |
|
98
|
2 |
|
if (false !== $this->validateOnly) { |
|
99
|
1 |
|
$ret["validate"] = $this->validateOnly; |
|
100
|
1 |
|
} |
|
101
|
|
|
|
|
102
|
2 |
|
return $ret; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* @return string |
|
107
|
|
|
*/ |
|
108
|
2 |
|
public function getResponseClassName() |
|
109
|
|
|
{ |
|
110
|
2 |
|
return AddOrderResponse::class; |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|