Skip to content

Commit 8ecb4d3

Browse files
authored
Merge pull request #11 from Bubblyworld/master
Add sequence number to trades
2 parents 9f0c74f + 3c54e13 commit 8ecb4d3

File tree

6 files changed

+125
-5
lines changed

6 files changed

+125
-5
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "luno/luno-php",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"type": "library",
55
"description": "PHP SDK for the Luno API",
66
"keywords": ["luno", "bitcoin", "ethereum"],

src/Luno/AbstractClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
abstract class AbstractClient
1313
{
14-
private static $version = "0.0.3";
14+
private static $version = "0.0.4";
1515
private static $defaultBaseURL = 'https://api.mybitx.com/';
1616
private static $defaultTimeoutSeconds = 10.0;
1717

src/Luno/Client.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ public function ListTransactions(Request\ListTransactions $req): Response\ListTr
345345
* ListUserTrades makes a call to GET /api/1/listtrades.
346346
*
347347
* Returns a list of your recent trades for a given pair, sorted by oldest
348-
* first.
348+
* first. If <code>before</code> is specified, then the trades are returned
349+
* sorted by most-recent first.
349350
*
350351
* <code>type</code> in the response indicates the type of order that you placed
351352
* in order to participate in the trade. Possible types: <code>BID</code>,
@@ -435,7 +436,7 @@ public function PostMarketOrder(Request\PostMarketOrder $req): Response\PostMark
435436
* If the email address is not associated with an existing Luno account, an
436437
* invitation to create an account and claim the funds will be sent.
437438
*
438-
* Warning! Digital currency transactions are irreversible. Please ensure your
439+
* Warning! Cryptocurrency transactions are irreversible. Please ensure your
439440
* program has been thoroughly tested before using this call.
440441
*
441442
* Permissions required: <code>Perm_W_Send</code>

src/Luno/Request/ListUserTrades.php

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@ class ListUserTrades extends AbstractRequest
99
*/
1010
protected $pair;
1111

12+
/**
13+
* Filter to trades from (including) this sequence number.
14+
* Default behaviour is not to include this filter.
15+
*/
16+
protected $after_seq;
17+
18+
/**
19+
* Filter to trades before this timestamp.
20+
*/
21+
protected $before;
22+
23+
/**
24+
* Filter to trades before (excluding) this sequence number.
25+
* Default behaviour is not to include this filter.
26+
*/
27+
protected $before_seq;
28+
1229
/**
1330
* Limit to this number of trades (default 100).
1431
*/
@@ -18,6 +35,12 @@ class ListUserTrades extends AbstractRequest
1835
* Filter to trades on or after this timestamp.
1936
*/
2037
protected $since;
38+
39+
/**
40+
* If set to true, sorts trades in descending order, otherwise ascending
41+
* order will be assumed.
42+
*/
43+
protected $sort_desc;
2144

2245
/**
2346
* @return string
@@ -38,6 +61,63 @@ public function setPair(string $pair)
3861
$this->pair = $pair;
3962
}
4063

64+
/**
65+
* @return int
66+
*/
67+
public function getAfterSeq(): int
68+
{
69+
if (!isset($this->after_seq)) {
70+
return 0;
71+
}
72+
return $this->after_seq;
73+
}
74+
75+
/**
76+
* @param int $afterSeq
77+
*/
78+
public function setAfterSeq(int $afterSeq)
79+
{
80+
$this->after_seq = $afterSeq;
81+
}
82+
83+
/**
84+
* @return int
85+
*/
86+
public function getBefore(): int
87+
{
88+
if (!isset($this->before)) {
89+
return 0;
90+
}
91+
return $this->before;
92+
}
93+
94+
/**
95+
* @param int $before
96+
*/
97+
public function setBefore(int $before)
98+
{
99+
$this->before = $before;
100+
}
101+
102+
/**
103+
* @return int
104+
*/
105+
public function getBeforeSeq(): int
106+
{
107+
if (!isset($this->before_seq)) {
108+
return 0;
109+
}
110+
return $this->before_seq;
111+
}
112+
113+
/**
114+
* @param int $beforeSeq
115+
*/
116+
public function setBeforeSeq(int $beforeSeq)
117+
{
118+
$this->before_seq = $beforeSeq;
119+
}
120+
41121
/**
42122
* @return int
43123
*/
@@ -75,6 +155,25 @@ public function setSince(int $since)
75155
{
76156
$this->since = $since;
77157
}
158+
159+
/**
160+
* @return bool
161+
*/
162+
public function getSortDesc(): bool
163+
{
164+
if (!isset($this->sort_desc)) {
165+
return false;
166+
}
167+
return $this->sort_desc;
168+
}
169+
170+
/**
171+
* @param bool $sortDesc
172+
*/
173+
public function setSortDesc(bool $sortDesc)
174+
{
175+
$this->sort_desc = $sortDesc;
176+
}
78177
}
79178

80179
// vi: ft=php

src/Luno/Types/OrderState.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
class OrderState
66
{
7-
const PENDING = "PENDING";
87
const COMPLETE = "COMPLETE";
8+
const PENDING = "PENDING";
99
}
1010

1111
// vi: ft=php

src/Luno/Types/Trade.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class Trade
1212
protected $order_id;
1313
protected $pair;
1414
protected $price;
15+
protected $sequence;
1516
protected $timestamp;
1617
protected $type;
1718
protected $volume;
@@ -168,6 +169,25 @@ public function setPrice(float $price)
168169
$this->price = $price;
169170
}
170171

172+
/**
173+
* @return int
174+
*/
175+
public function getSequence(): int
176+
{
177+
if (!isset($this->sequence)) {
178+
return 0;
179+
}
180+
return $this->sequence;
181+
}
182+
183+
/**
184+
* @param int $sequence
185+
*/
186+
public function setSequence(int $sequence)
187+
{
188+
$this->sequence = $sequence;
189+
}
190+
171191
/**
172192
* @return int
173193
*/

0 commit comments

Comments
 (0)