Skip to content

Commit 1e44c71

Browse files
authored
Merge pull request #24 from natercioluno/master
sync with api updates
2 parents c96d274 + dd670f8 commit 1e44c71

19 files changed

+1602
-56
lines changed

src/Luno/Client.php

Lines changed: 47 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -166,23 +166,6 @@ public function GetFundingAddress(Request\GetFundingAddress $req): Response\GetF
166166
return $mapper->map($res, new Response\GetFundingAddress);
167167
}
168168

169-
/**
170-
* GetLightningReceive makes a call to GET /api/1/lightning/receive/{id}.
171-
*
172-
* <b>Alpha warning!</b> The Lightning API is still in Alpha stage.
173-
* The risks are limited api availability and channel capacity.
174-
*
175-
* Lookup the status of a Lightning Receive Invoice.
176-
*
177-
* Permissions required: <code>Perm_W_Send</code>
178-
*/
179-
public function GetLightningReceive(Request\GetLightningReceive $req): Response\GetLightningReceive
180-
{
181-
$res = $this->do("GET", "/api/1/lightning/receive/{id}", $req, true);
182-
$mapper = new \JsonMapper();
183-
return $mapper->map($res, new Response\GetLightningReceive);
184-
}
185-
186169
/**
187170
* GetOrder makes a call to GET /api/1/orders/{id}.
188171
*
@@ -237,6 +220,22 @@ public function GetOrderBookFull(Request\GetOrderBookFull $req): Response\GetOrd
237220
return $mapper->map($res, new Response\GetOrderBookFull);
238221
}
239222

223+
/**
224+
* GetOrderV2 makes a call to GET /api/exchange/2/orders/{id}.
225+
*
226+
* Get the details for an order.<br>
227+
* This endpoint is in BETA, behaviour and specification may change without
228+
* any previous notice.
229+
*
230+
* Permissions required: <code>Perm_R_Orders</code>
231+
*/
232+
public function GetOrderV2(Request\GetOrderV2 $req): Response\GetOrderV2
233+
{
234+
$res = $this->do("GET", "/api/exchange/2/orders/{id}", $req, true);
235+
$mapper = new \JsonMapper();
236+
return $mapper->map($res, new Response\GetOrderV2);
237+
}
238+
240239
/**
241240
* GetQuote makes a call to GET /api/1/quotes/{id}.
242241
*
@@ -324,6 +323,23 @@ public function ListOrders(Request\ListOrders $req): Response\ListOrders
324323
return $mapper->map($res, new Response\ListOrders);
325324
}
326325

326+
/**
327+
* ListOrdersV2 makes a call to GET /api/exchange/2/listorders.
328+
*
329+
* Returns a list of the most recently placed orders. This endpoint will list
330+
* up to 100 open orders by default.<br>
331+
* This endpoint is in BETA, behaviour and specification may change without
332+
* any previous notice.
333+
*
334+
* Permissions required: <Code>Perm_R_Orders</Code>
335+
*/
336+
public function ListOrdersV2(Request\ListOrdersV2 $req): Response\ListOrdersV2
337+
{
338+
$res = $this->do("GET", "/api/exchange/2/listorders", $req, true);
339+
$mapper = new \JsonMapper();
340+
return $mapper->map($res, new Response\ListOrdersV2);
341+
}
342+
327343
/**
328344
* ListPendingTransactions makes a call to GET /api/1/accounts/{id}/pending.
329345
*
@@ -414,6 +430,19 @@ public function ListWithdrawals(Request\ListWithdrawals $req): Response\ListWith
414430
return $mapper->map($res, new Response\ListWithdrawals);
415431
}
416432

433+
/**
434+
* Markets makes a call to GET /api/exchange/1/markets.
435+
*
436+
* Get all supported markets parameter information like price scale, min and
437+
* max volumes and market ID.
438+
*/
439+
public function Markets(Request\Markets $req): Response\Markets
440+
{
441+
$res = $this->do("GET", "/api/exchange/1/markets", $req, false);
442+
$mapper = new \JsonMapper();
443+
return $mapper->map($res, new Response\Markets);
444+
}
445+
417446
/**
418447
* PostLimitOrder makes a call to POST /api/1/postorder.
419448
*
@@ -457,24 +486,6 @@ public function PostMarketOrder(Request\PostMarketOrder $req): Response\PostMark
457486
return $mapper->map($res, new Response\PostMarketOrder);
458487
}
459488

460-
/**
461-
* ReceiveLightning makes a call to POST /api/1/lightning/receive.
462-
*
463-
* <b>Alpha warning!</b> The Lightning API is still in Alpha stage.
464-
* The risks are limited api availability and channel capacity.
465-
*
466-
* Create a lightning invoice which can be used to receive
467-
* BTC payments over the lightning network.
468-
*
469-
* Permissions required: <code>Perm_W_Send</code>
470-
*/
471-
public function ReceiveLightning(Request\ReceiveLightning $req): Response\ReceiveLightning
472-
{
473-
$res = $this->do("POST", "/api/1/lightning/receive", $req, true);
474-
$mapper = new \JsonMapper();
475-
return $mapper->map($res, new Response\ReceiveLightning);
476-
}
477-
478489
/**
479490
* Send makes a call to POST /api/1/send.
480491
*
@@ -491,32 +502,12 @@ public function Send(Request\Send $req): Response\Send
491502
return $mapper->map($res, new Response\Send);
492503
}
493504

494-
/**
495-
* SendLightning makes a call to POST /api/1/lightning/send.
496-
*
497-
* <b>Alpha warning!</b> The Lightning API is still in Alpha stage.
498-
* The risks are limited api availability and channel capacity.
499-
*
500-
* Send Bitcoin over the Lightning network from your Bitcoin Account.
501-
*
502-
* Warning! Cryptocurrency transactions are irreversible. Please ensure your
503-
* program has been thoroughly tested before using this call.
504-
*
505-
* Permissions required: <code>Perm_W_Send</code>
506-
*/
507-
public function SendLightning(Request\SendLightning $req): Response\SendLightning
508-
{
509-
$res = $this->do("POST", "/api/1/lightning/send", $req, true);
510-
$mapper = new \JsonMapper();
511-
return $mapper->map($res, new Response\SendLightning);
512-
}
513-
514505
/**
515506
* StopOrder makes a call to POST /api/1/stoporder.
516507
*
517508
* Request to stop an Order.
518509
*
519-
* <b>Note!</b>: Once as Order has been completed, it can not be reversed.
510+
* <b>Note!</b>: Once an Order has been completed, it can not be reversed.
520511
* The return value from this request will indicate if the Stop request was successful or not.
521512
*
522513
* Permissions required: <code>Perm_W_Orders</code>

src/Luno/Request/GetOrderV2.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Luno\Request;
4+
5+
class GetOrderV2 extends AbstractRequest
6+
{
7+
/**
8+
* Order reference
9+
*/
10+
protected $id;
11+
12+
/**
13+
* @return string
14+
*/
15+
public function getId(): string
16+
{
17+
if (!isset($this->id)) {
18+
return "";
19+
}
20+
return $this->id;
21+
}
22+
23+
/**
24+
* @param string $id
25+
*/
26+
public function setId(string $id)
27+
{
28+
$this->id = $id;
29+
}
30+
}
31+
32+
// vi: ft=php

src/Luno/Request/ListOrdersV2.php

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Luno\Request;
4+
5+
class ListOrdersV2 extends AbstractRequest
6+
{
7+
/**
8+
* If true, will return closed orders instead of open orders.
9+
*/
10+
protected $closed;
11+
12+
/**
13+
* Filter to orders created before this timestamp (Unix milliseconds)
14+
*/
15+
protected $created_before;
16+
17+
/**
18+
* Limit to this many orders
19+
*/
20+
protected $limit;
21+
22+
/**
23+
* Filter to only orders of this currency pair.
24+
*/
25+
protected $pair;
26+
27+
/**
28+
* @return bool
29+
*/
30+
public function getClosed(): bool
31+
{
32+
if (!isset($this->closed)) {
33+
return false;
34+
}
35+
return $this->closed;
36+
}
37+
38+
/**
39+
* @param bool $closed
40+
*/
41+
public function setClosed(bool $closed)
42+
{
43+
$this->closed = $closed;
44+
}
45+
46+
/**
47+
* @return int
48+
*/
49+
public function getCreatedBefore(): int
50+
{
51+
if (!isset($this->created_before)) {
52+
return 0;
53+
}
54+
return $this->created_before;
55+
}
56+
57+
/**
58+
* @param int $createdBefore
59+
*/
60+
public function setCreatedBefore(int $createdBefore)
61+
{
62+
$this->created_before = $createdBefore;
63+
}
64+
65+
/**
66+
* @return int
67+
*/
68+
public function getLimit(): int
69+
{
70+
if (!isset($this->limit)) {
71+
return 0;
72+
}
73+
return $this->limit;
74+
}
75+
76+
/**
77+
* @param int $limit
78+
*/
79+
public function setLimit(int $limit)
80+
{
81+
$this->limit = $limit;
82+
}
83+
84+
/**
85+
* @return string
86+
*/
87+
public function getPair(): string
88+
{
89+
if (!isset($this->pair)) {
90+
return "";
91+
}
92+
return $this->pair;
93+
}
94+
95+
/**
96+
* @param string $pair
97+
*/
98+
public function setPair(string $pair)
99+
{
100+
$this->pair = $pair;
101+
}
102+
}
103+
104+
// vi: ft=php

src/Luno/Request/Markets.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Luno\Request;
4+
5+
class Markets extends AbstractRequest
6+
{
7+
}
8+
9+
// vi: ft=php

src/Luno/Request/PostLimitOrder.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,23 @@ class PostLimitOrder extends AbstractRequest
4444
* your order won't trade but will go into the order book.
4545
*/
4646
protected $post_only;
47+
48+
/**
49+
* Side of the trigger price to activate the order. This should be set if `stop_price` is also
50+
* set.
51+
*
52+
* `RELATIVE_LAST_TRADE` will automatically infer the direction based on the last
53+
* trade price and the stop price. If last trade price is less than stop price then stop
54+
* direction is ABOVE otherwise is BELOW.
55+
*/
56+
protected $stop_direction;
57+
58+
/**
59+
* Trigger trade price to activate this order as a decimal string. If this
60+
* is set then this is treated as a Stop Limit Order and `stop_direction`
61+
* is expected to be set too.
62+
*/
63+
protected $stop_price;
4764

4865
/**
4966
* @return string
@@ -177,6 +194,44 @@ public function setPostOnly(bool $postOnly)
177194
{
178195
$this->post_only = $postOnly;
179196
}
197+
198+
/**
199+
* @return string
200+
*/
201+
public function getStopDirection(): string
202+
{
203+
if (!isset($this->stop_direction)) {
204+
return "";
205+
}
206+
return $this->stop_direction;
207+
}
208+
209+
/**
210+
* @param string $stopDirection
211+
*/
212+
public function setStopDirection(string $stopDirection)
213+
{
214+
$this->stop_direction = $stopDirection;
215+
}
216+
217+
/**
218+
* @return float
219+
*/
220+
public function getStopPrice(): float
221+
{
222+
if (!isset($this->stop_price)) {
223+
return 0;
224+
}
225+
return $this->stop_price;
226+
}
227+
228+
/**
229+
* @param float $stopPrice
230+
*/
231+
public function setStopPrice(float $stopPrice)
232+
{
233+
$this->stop_price = $stopPrice;
234+
}
180235
}
181236

182237
// vi: ft=php

0 commit comments

Comments
 (0)