Fix styling
This commit is contained in:
parent
0996c5fc27
commit
49c1633f52
|
|
@ -38,18 +38,18 @@ try {
|
|||
|
||||
if ($data['code'] === 0) {
|
||||
echo "✅ Leverage changed successfully!\n";
|
||||
echo "Symbol: " . $data['data'][0]['symbol'] . "\n";
|
||||
echo "Margin Coin: " . $data['data'][0]['marginCoin'] . "\n";
|
||||
echo "New Leverage: " . $data['data'][0]['leverage'] . "\n";
|
||||
echo 'Symbol: '.$data['data'][0]['symbol']."\n";
|
||||
echo 'Margin Coin: '.$data['data'][0]['marginCoin']."\n";
|
||||
echo 'New Leverage: '.$data['data'][0]['leverage']."\n";
|
||||
} else {
|
||||
echo "❌ API Error: " . $data['msg'] . "\n";
|
||||
echo '❌ API Error: '.$data['msg']."\n";
|
||||
}
|
||||
} else {
|
||||
echo "❌ HTTP Error: " . $response->getStatusCode() . "\n";
|
||||
echo '❌ HTTP Error: '.$response->getStatusCode()."\n";
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo "❌ Exception: " . $e->getMessage() . "\n";
|
||||
echo '❌ Exception: '.$e->getMessage()."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
namespace Msr\LaravelBitunixApi;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Msr\LaravelBitunixApi\Requests\FutureKLineRequestContract;
|
||||
use Msr\LaravelBitunixApi\Requests\ChangeLeverageRequestContract;
|
||||
use Msr\LaravelBitunixApi\Requests\FutureKLineRequestContract;
|
||||
use Msr\LaravelBitunixApi\Requests\Header;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class LaravelBitunixApi implements FutureKLineRequestContract, ChangeLeverageRequestContract
|
||||
class LaravelBitunixApi implements ChangeLeverageRequestContract, FutureKLineRequestContract
|
||||
{
|
||||
private Client $publicFutureClient;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ interface ChangeLeverageRequestContract
|
|||
* @param string $symbol Trading pair (e.g., 'BTCUSDT')
|
||||
* @param string $marginCoin Margin coin (e.g., 'USDT')
|
||||
* @param int $leverage Leverage value
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function changeLeverage(string $symbol, string $marginCoin, int $leverage): ResponseInterface;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,6 @@ class Header
|
|||
{
|
||||
/**
|
||||
* Sort query parameters in ascending ASCII order by Key
|
||||
*
|
||||
* @param array $parameters
|
||||
* @return array
|
||||
*/
|
||||
public static function sortQueryParameters(array $parameters): array
|
||||
{
|
||||
|
|
@ -17,15 +14,13 @@ class Header
|
|||
}
|
||||
|
||||
ksort($parameters, SORT_STRING);
|
||||
|
||||
return $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert sorted parameters to string format
|
||||
* Example: ["id" => "1", "uid" => "200"] becomes "id1uid200"
|
||||
*
|
||||
* @param array $parameters
|
||||
* @return string
|
||||
*/
|
||||
public static function digestQueryParameters(array $parameters): string
|
||||
{
|
||||
|
|
@ -45,8 +40,6 @@ class Header
|
|||
|
||||
/**
|
||||
* Generate a random 32-bit nonce string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function generateNonce(): string
|
||||
{
|
||||
|
|
@ -55,8 +48,6 @@ class Header
|
|||
|
||||
/**
|
||||
* Generate current timestamp in milliseconds
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function generateTimestamp(): string
|
||||
{
|
||||
|
|
@ -71,12 +62,6 @@ class Header
|
|||
* 2. Remove all spaces from body string
|
||||
* 3. Create digest: SHA256(nonce + timestamp + api-key + queryParams + body)
|
||||
* 4. Create sign: SHA256(digest + secretKey)
|
||||
*
|
||||
* @param array $queryParams
|
||||
* @param string $body
|
||||
* @param string $nonce
|
||||
* @param string $timestamp
|
||||
* @return string
|
||||
*/
|
||||
public static function generateSignValue(array $queryParams = [], string $body = '', string $nonce = '', string $timestamp = ''): string
|
||||
{
|
||||
|
|
@ -106,10 +91,6 @@ class Header
|
|||
|
||||
/**
|
||||
* Generate complete headers for authenticated requests
|
||||
*
|
||||
* @param array $queryParams
|
||||
* @param string $body
|
||||
* @return array
|
||||
*/
|
||||
public static function generateHeaders(array $queryParams = [], string $body = ''): array
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Msr\LaravelBitunixApi\Requests\ChangeLeverageRequestContract;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Handler\MockHandler;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
|
||||
it('can change leverage successfully', function () {
|
||||
$api = app(ChangeLeverageRequestContract::class);
|
||||
|
|
@ -22,4 +18,3 @@ it('validates required parameters for change leverage', function () {
|
|||
->and(fn () => $api->changeLeverage('BTCUSDT', 'USDT', 0))
|
||||
->not->toThrow(Exception::class);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ it('can sort query parameters in ascending ASCII order', function () {
|
|||
$parameters = [
|
||||
'uid' => '200',
|
||||
'id' => '1',
|
||||
'name' => 'test'
|
||||
'name' => 'test',
|
||||
];
|
||||
|
||||
$sorted = Header::sortQueryParameters($parameters);
|
||||
|
|
@ -23,14 +23,14 @@ it('can sort query parameters in ascending ASCII order', function () {
|
|||
expect($sorted)->toBe([
|
||||
'id' => '1',
|
||||
'name' => 'test',
|
||||
'uid' => '200'
|
||||
'uid' => '200',
|
||||
]);
|
||||
});
|
||||
|
||||
it('can digest query parameters to string format', function () {
|
||||
$parameters = [
|
||||
'id' => '1',
|
||||
'uid' => '200'
|
||||
'uid' => '200',
|
||||
];
|
||||
|
||||
$result = Header::digestQueryParameters($parameters);
|
||||
|
|
|
|||
Loading…
Reference in New Issue