Skip to content

Commit 1c23b5f

Browse files
authored
Merge pull request #134 from fieyum/master
phpsdk api upgrade update
2 parents 48e0f57 + ea662a2 commit 1c23b5f

File tree

11 files changed

+1263
-78
lines changed

11 files changed

+1263
-78
lines changed

README.md

Lines changed: 104 additions & 67 deletions
Large diffs are not rendered by default.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"monolog/monolog": "~1.0|~2.0|~3.0"
2828
},
2929
"require-dev": {
30-
"phpunit/phpunit": ">=5.7"
30+
"phpunit/phpunit": "^5.7"
3131
},
3232
"autoload": {
3333
"psr-4": {

phpunit.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
<env name="API_KEY" value="key" force="false"/>
2525
<env name="API_SECRET" value="secret" force="false"/>
2626
<env name="API_PASSPHRASE" value="passphrase" force="false"/>
27-
<env name="API_BASE_URI" value="https://openapi-v2.kucoin.com" force="false"/>
27+
<env name="API_BASE_URI" value="https://api.kucoin.com" force="false"/>
2828
<env name="API_SKIP_VERIFY_TLS" value="0" force="false"/>
2929
<env name="API_DEBUG_MODE" value="1" force="false"/>
30-
<env name="API_KEY_VERSION" value="1" force="false"/>
30+
<env name="API_KEY_VERSION" value="2" force="false"/>
3131
</php>
3232
</phpunit>

src/Api.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ abstract class Api
1616
/**
1717
* @var string SDK Version
1818
*/
19-
const VERSION = '1.1.29';
19+
const VERSION = '1.1.30';
2020

2121
/**
2222
* @var string SDK update date
2323
*/
24-
const UPDATE_DATE = '2024.01.05';
24+
const UPDATE_DATE = '2024.05.28';
2525

2626
/**
2727
* @var string

src/PrivateApi/IsolatedMargin.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public function getAccountDetail($symbol)
6161
* @throws \KuCoin\SDK\Exceptions\BusinessException
6262
* @throws \KuCoin\SDK\Exceptions\HttpException
6363
* @throws \KuCoin\SDK\Exceptions\InvalidApiUriException
64+
*
65+
* @deprecated Call Margin::borrowV3 instead.
6466
*/
6567
public function borrow(array $params)
6668
{
@@ -76,6 +78,8 @@ public function borrow(array $params)
7678
* @throws \KuCoin\SDK\Exceptions\BusinessException
7779
* @throws \KuCoin\SDK\Exceptions\HttpException
7880
* @throws \KuCoin\SDK\Exceptions\InvalidApiUriException
81+
*
82+
* @deprecated Call getAccountDetail instead.
7983
*/
8084
public function getOutstanding(array $params)
8185
{
@@ -90,6 +94,8 @@ public function getOutstanding(array $params)
9094
* @throws \KuCoin\SDK\Exceptions\BusinessException
9195
* @throws \KuCoin\SDK\Exceptions\HttpException
9296
* @throws \KuCoin\SDK\Exceptions\InvalidApiUriException
97+
*
98+
* @deprecated
9399
*/
94100
public function getRepaid(array $params)
95101
{
@@ -104,6 +110,8 @@ public function getRepaid(array $params)
104110
* @throws \KuCoin\SDK\Exceptions\BusinessException
105111
* @throws \KuCoin\SDK\Exceptions\HttpException
106112
* @throws \KuCoin\SDK\Exceptions\InvalidApiUriException
113+
*
114+
* @deprecated Call Margin::repayV3 instead.
107115
*/
108116
public function repayAll(array $params)
109117
{
@@ -118,6 +126,8 @@ public function repayAll(array $params)
118126
* @throws \KuCoin\SDK\Exceptions\BusinessException
119127
* @throws \KuCoin\SDK\Exceptions\HttpException
120128
* @throws \KuCoin\SDK\Exceptions\InvalidApiUriException
129+
*
130+
* @deprecated Call Margin::repayV3 instead.
121131
*/
122132
public function repaySingle(array $params)
123133
{

src/PrivateApi/Lend.php

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?php
2+
3+
namespace KuCoin\SDK\PrivateApi;
4+
5+
use KuCoin\SDK\Http\Request;
6+
use KuCoin\SDK\KuCoinApi;
7+
8+
/**
9+
* Class Lend
10+
* @package KuCoin\SDK\PrivateApi
11+
*
12+
* @see https://www.kucoin.com/docs/rest/margin-trading/lending-market-v3-/get-currency-information
13+
*/
14+
class Lend extends KuCoinApi
15+
{
16+
/**
17+
* This API endpoint is used to get the information about the currencies available for lending.
18+
*
19+
* @param string $currency
20+
* @return mixed|null
21+
* @throws \KuCoin\SDK\Exceptions\BusinessException
22+
* @throws \KuCoin\SDK\Exceptions\HttpException
23+
* @throws \KuCoin\SDK\Exceptions\InvalidApiUriException
24+
*/
25+
public function getCurrencies($currency = '')
26+
{
27+
$params = $currency ? ['currency' => $currency] : [];
28+
$response = $this->call(Request::METHOD_GET, '/api/v3/project/list', $params);
29+
return $response->getApiData();
30+
}
31+
32+
/**
33+
* This API endpoint is used to get the interest rates of the margin lending market over the past 7 days.
34+
*
35+
* @param $currency
36+
* @return mixed|null
37+
* @throws \KuCoin\SDK\Exceptions\BusinessException
38+
* @throws \KuCoin\SDK\Exceptions\HttpException
39+
* @throws \KuCoin\SDK\Exceptions\InvalidApiUriException
40+
*/
41+
public function getMarketInterestRate($currency)
42+
{
43+
$params = ['currency' => $currency];
44+
$response = $this->call(Request::METHOD_GET, '/api/v3/project/marketInterestRate', $params);
45+
return $response->getApiData();
46+
}
47+
48+
/**
49+
* Initiate subscriptions of margin lending.
50+
*
51+
* @param array $params
52+
* @return mixed|null
53+
* @throws \KuCoin\SDK\Exceptions\BusinessException
54+
* @throws \KuCoin\SDK\Exceptions\HttpException
55+
* @throws \KuCoin\SDK\Exceptions\InvalidApiUriException
56+
*/
57+
public function purchase(array $params)
58+
{
59+
$response = $this->call(Request::METHOD_POST, '/api/v3/purchase', $params);
60+
return $response->getApiData();
61+
}
62+
63+
/**
64+
* Initiate redemptions of margin lending.
65+
*
66+
* @param array $params
67+
* @return mixed|null
68+
* @throws \KuCoin\SDK\Exceptions\BusinessException
69+
* @throws \KuCoin\SDK\Exceptions\HttpException
70+
* @throws \KuCoin\SDK\Exceptions\InvalidApiUriException
71+
*/
72+
public function redeem(array $params)
73+
{
74+
$response = $this->call(Request::METHOD_POST, '/api/v3/redeem', $params);
75+
return $response->getApiData();
76+
}
77+
78+
/**
79+
* This API endpoint is used to update the interest rates of subscription orders, which will take effect at the beginning of the next hour.
80+
*
81+
* @param array $params
82+
* @return mixed|null
83+
* @throws \KuCoin\SDK\Exceptions\BusinessException
84+
* @throws \KuCoin\SDK\Exceptions\HttpException
85+
* @throws \KuCoin\SDK\Exceptions\InvalidApiUriException
86+
*/
87+
public function purchaseUpdate(array $params)
88+
{
89+
$response = $this->call(Request::METHOD_POST, '/api/v3/lend/purchase/update', $params);
90+
return $response->getApiData();
91+
}
92+
93+
/**
94+
* This API endpoint provides pagination query for the redemption orders.
95+
*
96+
* @param array $params
97+
* @param array $pagination
98+
* @return mixed|null
99+
* @throws \KuCoin\SDK\Exceptions\BusinessException
100+
* @throws \KuCoin\SDK\Exceptions\HttpException
101+
* @throws \KuCoin\SDK\Exceptions\InvalidApiUriException
102+
*/
103+
public function getRedeemOrders(array $params, array $pagination = [])
104+
{
105+
$response = $this->call(Request::METHOD_GET, '/api/v3/redeem/orders', $params + $pagination);
106+
return $response->getApiData();
107+
}
108+
109+
/**
110+
* This API endpoint provides pagination query for the subscription orders.
111+
*
112+
* @param array $params
113+
* @param array $pagination
114+
* @return mixed|null
115+
* @throws \KuCoin\SDK\Exceptions\BusinessException
116+
* @throws \KuCoin\SDK\Exceptions\HttpException
117+
* @throws \KuCoin\SDK\Exceptions\InvalidApiUriException
118+
*/
119+
public function getPurchaseOrders(array $params, array $pagination = [])
120+
{
121+
$response = $this->call(Request::METHOD_GET, '/api/v3/purchase/orders', $params + $pagination);
122+
return $response->getApiData();
123+
}
124+
}

0 commit comments

Comments
 (0)