Fix styling

This commit is contained in:
mahdimsr 2025-09-28 21:02:08 +00:00 committed by github-actions[bot]
parent 38114203a1
commit 526ef64ad8
10 changed files with 151 additions and 154 deletions

View File

@ -28,19 +28,19 @@ try {
// Example 1: Flash close a single position // Example 1: Flash close a single position
echo "1. Flash closing position...\n"; echo "1. Flash closing position...\n";
$positionId = '19848247723672'; $positionId = '19848247723672';
$response = $api->flashClosePosition($positionId); $response = $api->flashClosePosition($positionId);
if ($response->getStatusCode() === 200) { if ($response->getStatusCode() === 200) {
$data = json_decode($response->getBody()->getContents(), true); $data = json_decode($response->getBody()->getContents(), true);
if ($data['code'] === 0) { if ($data['code'] === 0) {
echo "✅ Position flash closed successfully!\n"; echo "✅ Position flash closed successfully!\n";
echo "Position ID: " . $data['data']['positionId'] . "\n"; echo 'Position ID: '.$data['data']['positionId']."\n";
} else { } else {
echo "❌ API Error: " . $data['msg'] . "\n"; echo '❌ API Error: '.$data['msg']."\n";
} }
} else { } else {
echo "❌ HTTP Error: " . $response->getStatusCode() . "\n"; echo '❌ HTTP Error: '.$response->getStatusCode()."\n";
} }
echo "\n"; echo "\n";
@ -50,23 +50,23 @@ try {
$positionIds = [ $positionIds = [
'19848247723672', '19848247723672',
'19848247723673', '19848247723673',
'19848247723674' '19848247723674',
]; ];
foreach ($positionIds as $positionId) { foreach ($positionIds as $positionId) {
echo "Closing position: {$positionId}...\n"; echo "Closing position: {$positionId}...\n";
$response = $api->flashClosePosition($positionId); $response = $api->flashClosePosition($positionId);
if ($response->getStatusCode() === 200) { if ($response->getStatusCode() === 200) {
$data = json_decode($response->getBody()->getContents(), true); $data = json_decode($response->getBody()->getContents(), true);
if ($data['code'] === 0) { if ($data['code'] === 0) {
echo "✅ Position {$positionId} closed successfully!\n"; echo "✅ Position {$positionId} closed successfully!\n";
} else { } else {
echo "❌ Failed to close position {$positionId}: " . $data['msg'] . "\n"; echo "❌ Failed to close position {$positionId}: ".$data['msg']."\n";
} }
} else { } else {
echo "❌ HTTP Error for position {$positionId}: " . $response->getStatusCode() . "\n"; echo "❌ HTTP Error for position {$positionId}: ".$response->getStatusCode()."\n";
} }
} }
@ -75,19 +75,19 @@ try {
// Example 3: Error handling // Example 3: Error handling
echo "3. Error handling example...\n"; echo "3. Error handling example...\n";
$invalidPositionId = 'invalid-position-id'; $invalidPositionId = 'invalid-position-id';
$response = $api->flashClosePosition($invalidPositionId); $response = $api->flashClosePosition($invalidPositionId);
if ($response->getStatusCode() === 200) { if ($response->getStatusCode() === 200) {
$data = json_decode($response->getBody()->getContents(), true); $data = json_decode($response->getBody()->getContents(), true);
if ($data['code'] === 0) { if ($data['code'] === 0) {
echo "✅ Position closed successfully!\n"; echo "✅ Position closed successfully!\n";
} else { } else {
echo "❌ API Error: " . $data['msg'] . "\n"; echo '❌ API Error: '.$data['msg']."\n";
echo "This is expected for invalid position ID\n"; echo "This is expected for invalid position ID\n";
} }
} else { } else {
echo "❌ HTTP Error: " . $response->getStatusCode() . "\n"; echo '❌ HTTP Error: '.$response->getStatusCode()."\n";
} }
} catch (Exception $e) { } catch (Exception $e) {
@ -96,19 +96,19 @@ try {
/** /**
* Flash Close Position Features: * Flash Close Position Features:
* *
* - Closes position by position ID * - Closes position by position ID
* - Rate limit: 5 req/sec/uid * - Rate limit: 5 req/sec/uid
* - Immediate position closure * - Immediate position closure
* - No additional parameters required * - No additional parameters required
* *
* Important Notes: * Important Notes:
* *
* - Position ID must be valid and exist * - Position ID must be valid and exist
* - Position must be open to be closed * - Position must be open to be closed
* - This is an immediate action (flash close) * - This is an immediate action (flash close)
* - Use with caution as it closes positions immediately * - Use with caution as it closes positions immediately
* *
* Environment Variables Required: * Environment Variables Required:
* *
* BITUNIX_API_KEY=your-api-key * BITUNIX_API_KEY=your-api-key

View File

@ -33,23 +33,23 @@ try {
$data = json_decode($response->getBody()->getContents(), true); $data = json_decode($response->getBody()->getContents(), true);
if ($data['code'] === 0) { if ($data['code'] === 0) {
echo "✅ Pending positions retrieved successfully!\n"; echo "✅ Pending positions retrieved successfully!\n";
echo "Number of positions: " . count($data['data']) . "\n"; echo 'Number of positions: '.count($data['data'])."\n";
foreach ($data['data'] as $position) { foreach ($data['data'] as $position) {
echo " - Position ID: " . $position['positionId'] . "\n"; echo ' - Position ID: '.$position['positionId']."\n";
echo " Symbol: " . $position['symbol'] . "\n"; echo ' Symbol: '.$position['symbol']."\n";
echo " Side: " . $position['side'] . "\n"; echo ' Side: '.$position['side']."\n";
echo " Quantity: " . $position['qty'] . "\n"; echo ' Quantity: '.$position['qty']."\n";
echo " Unrealized PnL: " . $position['unrealizedPNL'] . "\n"; echo ' Unrealized PnL: '.$position['unrealizedPNL']."\n";
echo " Margin: " . $position['margin'] . "\n"; echo ' Margin: '.$position['margin']."\n";
echo " Leverage: " . $position['leverage'] . "\n"; echo ' Leverage: '.$position['leverage']."\n";
echo " ---\n"; echo " ---\n";
} }
} else { } else {
echo "❌ API Error: " . $data['msg'] . "\n"; echo '❌ API Error: '.$data['msg']."\n";
} }
} else { } else {
echo "❌ HTTP Error: " . $response->getStatusCode() . "\n"; echo '❌ HTTP Error: '.$response->getStatusCode()."\n";
} }
echo "\n"; echo "\n";
@ -62,21 +62,21 @@ try {
$data = json_decode($response->getBody()->getContents(), true); $data = json_decode($response->getBody()->getContents(), true);
if ($data['code'] === 0) { if ($data['code'] === 0) {
echo "✅ BTCUSDT pending positions retrieved successfully!\n"; echo "✅ BTCUSDT pending positions retrieved successfully!\n";
echo "Number of BTCUSDT positions: " . count($data['data']) . "\n"; echo 'Number of BTCUSDT positions: '.count($data['data'])."\n";
foreach ($data['data'] as $position) { foreach ($data['data'] as $position) {
echo " - Position ID: " . $position['positionId'] . "\n"; echo ' - Position ID: '.$position['positionId']."\n";
echo " Entry Value: " . $position['entryValue'] . "\n"; echo ' Entry Value: '.$position['entryValue']."\n";
echo " Average Open Price: " . $position['avgOpenPrice'] . "\n"; echo ' Average Open Price: '.$position['avgOpenPrice']."\n";
echo " Liquidation Price: " . $position['liqPrice'] . "\n"; echo ' Liquidation Price: '.$position['liqPrice']."\n";
echo " Margin Rate: " . $position['marginRate'] . "\n"; echo ' Margin Rate: '.$position['marginRate']."\n";
echo " ---\n"; echo " ---\n";
} }
} else { } else {
echo "❌ API Error: " . $data['msg'] . "\n"; echo '❌ API Error: '.$data['msg']."\n";
} }
} else { } else {
echo "❌ HTTP Error: " . $response->getStatusCode() . "\n"; echo '❌ HTTP Error: '.$response->getStatusCode()."\n";
} }
echo "\n"; echo "\n";
@ -90,36 +90,36 @@ try {
$data = json_decode($response->getBody()->getContents(), true); $data = json_decode($response->getBody()->getContents(), true);
if ($data['code'] === 0) { if ($data['code'] === 0) {
echo "✅ Position {$positionId} retrieved successfully!\n"; echo "✅ Position {$positionId} retrieved successfully!\n";
if (!empty($data['data'])) { if (! empty($data['data'])) {
$position = $data['data'][0]; $position = $data['data'][0];
echo " Position Details:\n"; echo " Position Details:\n";
echo " Position ID: " . $position['positionId'] . "\n"; echo ' Position ID: '.$position['positionId']."\n";
echo " Symbol: " . $position['symbol'] . "\n"; echo ' Symbol: '.$position['symbol']."\n";
echo " Side: " . $position['side'] . "\n"; echo ' Side: '.$position['side']."\n";
echo " Quantity: " . $position['qty'] . "\n"; echo ' Quantity: '.$position['qty']."\n";
echo " Entry Value: " . $position['entryValue'] . "\n"; echo ' Entry Value: '.$position['entryValue']."\n";
echo " Average Open Price: " . $position['avgOpenPrice'] . "\n"; echo ' Average Open Price: '.$position['avgOpenPrice']."\n";
echo " Unrealized PnL: " . $position['unrealizedPNL'] . "\n"; echo ' Unrealized PnL: '.$position['unrealizedPNL']."\n";
echo " Realized PnL: " . $position['realizedPNL'] . "\n"; echo ' Realized PnL: '.$position['realizedPNL']."\n";
echo " Margin: " . $position['margin'] . "\n"; echo ' Margin: '.$position['margin']."\n";
echo " Leverage: " . $position['leverage'] . "\n"; echo ' Leverage: '.$position['leverage']."\n";
echo " Margin Mode: " . $position['marginMode'] . "\n"; echo ' Margin Mode: '.$position['marginMode']."\n";
echo " Position Mode: " . $position['positionMode'] . "\n"; echo ' Position Mode: '.$position['positionMode']."\n";
echo " Liquidation Price: " . $position['liqPrice'] . "\n"; echo ' Liquidation Price: '.$position['liqPrice']."\n";
echo " Margin Rate: " . $position['marginRate'] . "\n"; echo ' Margin Rate: '.$position['marginRate']."\n";
echo " Fee: " . $position['fee'] . "\n"; echo ' Fee: '.$position['fee']."\n";
echo " Funding: " . $position['funding'] . "\n"; echo ' Funding: '.$position['funding']."\n";
echo " Created: " . date('Y-m-d H:i:s', $position['ctime'] / 1000) . "\n"; echo ' Created: '.date('Y-m-d H:i:s', $position['ctime'] / 1000)."\n";
echo " Modified: " . date('Y-m-d H:i:s', $position['mtime'] / 1000) . "\n"; echo ' Modified: '.date('Y-m-d H:i:s', $position['mtime'] / 1000)."\n";
} else { } else {
echo "No position found with ID: {$positionId}\n"; echo "No position found with ID: {$positionId}\n";
} }
} else { } else {
echo "❌ API Error: " . $data['msg'] . "\n"; echo '❌ API Error: '.$data['msg']."\n";
} }
} else { } else {
echo "❌ HTTP Error: " . $response->getStatusCode() . "\n"; echo '❌ HTTP Error: '.$response->getStatusCode()."\n";
} }
echo "\n"; echo "\n";
@ -132,12 +132,12 @@ try {
$data = json_decode($response->getBody()->getContents(), true); $data = json_decode($response->getBody()->getContents(), true);
if ($data['code'] === 0) { if ($data['code'] === 0) {
echo "✅ Filtered positions retrieved successfully!\n"; echo "✅ Filtered positions retrieved successfully!\n";
echo "Number of filtered positions: " . count($data['data']) . "\n"; echo 'Number of filtered positions: '.count($data['data'])."\n";
} else { } else {
echo "❌ API Error: " . $data['msg'] . "\n"; echo '❌ API Error: '.$data['msg']."\n";
} }
} else { } else {
echo "❌ HTTP Error: " . $response->getStatusCode() . "\n"; echo '❌ HTTP Error: '.$response->getStatusCode()."\n";
} }
} catch (Exception $e) { } catch (Exception $e) {
@ -146,13 +146,13 @@ try {
/** /**
* Get Pending Positions Features: * Get Pending Positions Features:
* *
* - Get all pending positions * - Get all pending positions
* - Filter by trading pair (symbol) * - Filter by trading pair (symbol)
* - Filter by position ID * - Filter by position ID
* - Get detailed position information * - Get detailed position information
* - Rate limit: 10 req/sec/uid * - Rate limit: 10 req/sec/uid
* *
* Response includes: * Response includes:
* - positionId: Position ID * - positionId: Position ID
* - symbol: Trading pair * - symbol: Trading pair
@ -172,7 +172,7 @@ try {
* - avgOpenPrice: Average open price * - avgOpenPrice: Average open price
* - ctime: Create timestamp * - ctime: Create timestamp
* - mtime: Latest modify timestamp * - mtime: Latest modify timestamp
* *
* Environment Variables Required: * Environment Variables Required:
* *
* BITUNIX_API_KEY=your-api-key * BITUNIX_API_KEY=your-api-key

View File

@ -33,23 +33,23 @@ try {
$data = json_decode($response->getBody()->getContents(), true); $data = json_decode($response->getBody()->getContents(), true);
if ($data['code'] === 0) { if ($data['code'] === 0) {
echo "✅ USDT account details retrieved successfully!\n"; echo "✅ USDT account details retrieved successfully!\n";
$account = $data['data'][0]; $account = $data['data'][0];
echo "Account Details:\n"; echo "Account Details:\n";
echo " Margin Coin: " . $account['marginCoin'] . "\n"; echo ' Margin Coin: '.$account['marginCoin']."\n";
echo " Available: " . $account['available'] . "\n"; echo ' Available: '.$account['available']."\n";
echo " Frozen: " . $account['frozen'] . "\n"; echo ' Frozen: '.$account['frozen']."\n";
echo " Margin: " . $account['margin'] . "\n"; echo ' Margin: '.$account['margin']."\n";
echo " Transfer: " . $account['transfer'] . "\n"; echo ' Transfer: '.$account['transfer']."\n";
echo " Position Mode: " . $account['positionMode'] . "\n"; echo ' Position Mode: '.$account['positionMode']."\n";
echo " Cross Unrealized PnL: " . $account['crossUnrealizedPNL'] . "\n"; echo ' Cross Unrealized PnL: '.$account['crossUnrealizedPNL']."\n";
echo " Isolation Unrealized PnL: " . $account['isolationUnrealizedPNL'] . "\n"; echo ' Isolation Unrealized PnL: '.$account['isolationUnrealizedPNL']."\n";
echo " Bonus: " . $account['bonus'] . "\n"; echo ' Bonus: '.$account['bonus']."\n";
} else { } else {
echo "❌ API Error: " . $data['msg'] . "\n"; echo '❌ API Error: '.$data['msg']."\n";
} }
} else { } else {
echo "❌ HTTP Error: " . $response->getStatusCode() . "\n"; echo '❌ HTTP Error: '.$response->getStatusCode()."\n";
} }
echo "\n"; echo "\n";
@ -62,23 +62,23 @@ try {
$data = json_decode($response->getBody()->getContents(), true); $data = json_decode($response->getBody()->getContents(), true);
if ($data['code'] === 0) { if ($data['code'] === 0) {
echo "✅ BTC account details retrieved successfully!\n"; echo "✅ BTC account details retrieved successfully!\n";
$account = $data['data'][0]; $account = $data['data'][0];
echo "Account Details:\n"; echo "Account Details:\n";
echo " Margin Coin: " . $account['marginCoin'] . "\n"; echo ' Margin Coin: '.$account['marginCoin']."\n";
echo " Available: " . $account['available'] . "\n"; echo ' Available: '.$account['available']."\n";
echo " Frozen: " . $account['frozen'] . "\n"; echo ' Frozen: '.$account['frozen']."\n";
echo " Margin: " . $account['margin'] . "\n"; echo ' Margin: '.$account['margin']."\n";
echo " Transfer: " . $account['transfer'] . "\n"; echo ' Transfer: '.$account['transfer']."\n";
echo " Position Mode: " . $account['positionMode'] . "\n"; echo ' Position Mode: '.$account['positionMode']."\n";
echo " Cross Unrealized PnL: " . $account['crossUnrealizedPNL'] . "\n"; echo ' Cross Unrealized PnL: '.$account['crossUnrealizedPNL']."\n";
echo " Isolation Unrealized PnL: " . $account['isolationUnrealizedPNL'] . "\n"; echo ' Isolation Unrealized PnL: '.$account['isolationUnrealizedPNL']."\n";
echo " Bonus: " . $account['bonus'] . "\n"; echo ' Bonus: '.$account['bonus']."\n";
} else { } else {
echo "❌ API Error: " . $data['msg'] . "\n"; echo '❌ API Error: '.$data['msg']."\n";
} }
} else { } else {
echo "❌ HTTP Error: " . $response->getStatusCode() . "\n"; echo '❌ HTTP Error: '.$response->getStatusCode()."\n";
} }
echo "\n"; echo "\n";
@ -89,19 +89,19 @@ try {
foreach ($marginCoins as $marginCoin) { foreach ($marginCoins as $marginCoin) {
echo "Getting {$marginCoin} account details...\n"; echo "Getting {$marginCoin} account details...\n";
$response = $api->getSingleAccount($marginCoin); $response = $api->getSingleAccount($marginCoin);
if ($response->getStatusCode() === 200) { if ($response->getStatusCode() === 200) {
$data = json_decode($response->getBody()->getContents(), true); $data = json_decode($response->getBody()->getContents(), true);
if ($data['code'] === 0) { if ($data['code'] === 0) {
$account = $data['data'][0]; $account = $data['data'][0];
echo "{$marginCoin} account: Available={$account['available']}, Frozen={$account['frozen']}, Margin={$account['margin']}\n"; echo "{$marginCoin} account: Available={$account['available']}, Frozen={$account['frozen']}, Margin={$account['margin']}\n";
} else { } else {
echo "❌ Failed to get {$marginCoin} account: " . $data['msg'] . "\n"; echo "❌ Failed to get {$marginCoin} account: ".$data['msg']."\n";
} }
} else { } else {
echo "❌ HTTP Error for {$marginCoin}: " . $response->getStatusCode() . "\n"; echo "❌ HTTP Error for {$marginCoin}: ".$response->getStatusCode()."\n";
} }
} }
@ -110,19 +110,19 @@ try {
// Example 4: Error handling // Example 4: Error handling
echo "4. Error handling example...\n"; echo "4. Error handling example...\n";
$invalidMarginCoin = 'INVALID'; $invalidMarginCoin = 'INVALID';
$response = $api->getSingleAccount($invalidMarginCoin); $response = $api->getSingleAccount($invalidMarginCoin);
if ($response->getStatusCode() === 200) { if ($response->getStatusCode() === 200) {
$data = json_decode($response->getBody()->getContents(), true); $data = json_decode($response->getBody()->getContents(), true);
if ($data['code'] === 0) { if ($data['code'] === 0) {
echo "✅ Account details retrieved successfully!\n"; echo "✅ Account details retrieved successfully!\n";
} else { } else {
echo "❌ API Error: " . $data['msg'] . "\n"; echo '❌ API Error: '.$data['msg']."\n";
echo "This is expected for invalid margin coin\n"; echo "This is expected for invalid margin coin\n";
} }
} else { } else {
echo "❌ HTTP Error: " . $response->getStatusCode() . "\n"; echo '❌ HTTP Error: '.$response->getStatusCode()."\n";
} }
} catch (Exception $e) { } catch (Exception $e) {
@ -131,12 +131,12 @@ try {
/** /**
* Get Single Account Features: * Get Single Account Features:
* *
* - Get account details for specific margin coin * - Get account details for specific margin coin
* - Rate limit: 10 req/sec/uid * - Rate limit: 10 req/sec/uid
* - Returns comprehensive account information * - Returns comprehensive account information
* - Supports multiple margin coins * - Supports multiple margin coins
* *
* Response includes: * Response includes:
* - marginCoin: Margin Coin * - marginCoin: Margin Coin
* - available: Available quantity in the account * - available: Available quantity in the account
@ -147,7 +147,7 @@ try {
* - crossUnrealizedPNL: Unrealized PnL for cross positions * - crossUnrealizedPNL: Unrealized PnL for cross positions
* - isolationUnrealizedPNL: Unrealized PnL for isolation positions * - isolationUnrealizedPNL: Unrealized PnL for isolation positions
* - bonus: Futures Bonus * - bonus: Futures Bonus
* *
* Environment Variables Required: * Environment Variables Required:
* *
* BITUNIX_API_KEY=your-api-key * BITUNIX_API_KEY=your-api-key

View File

@ -9,8 +9,7 @@ interface FlashClosePositionRequestContract
/** /**
* Flash close position by position ID * Flash close position by position ID
* *
* @param string $positionId Position ID * @param string $positionId Position ID
* @return ResponseInterface
*/ */
public function flashClosePosition(string $positionId): ResponseInterface; public function flashClosePosition(string $positionId): ResponseInterface;
} }

View File

@ -9,9 +9,8 @@ interface GetPendingPositionsRequestContract
/** /**
* Get pending positions * Get pending positions
* *
* @param string|null $symbol Trading pair (optional) * @param string|null $symbol Trading pair (optional)
* @param string|null $positionId Position ID (optional) * @param string|null $positionId Position ID (optional)
* @return ResponseInterface
*/ */
public function getPendingPositions(?string $symbol = null, ?string $positionId = null): ResponseInterface; public function getPendingPositions(?string $symbol = null, ?string $positionId = null): ResponseInterface;
} }

View File

@ -9,8 +9,7 @@ interface GetSingleAccountRequestContract
/** /**
* Get account details with the given margin coin * Get account details with the given margin coin
* *
* @param string $marginCoin Margin coin (e.g., 'USDT') * @param string $marginCoin Margin coin (e.g., 'USDT')
* @return ResponseInterface
*/ */
public function getSingleAccount(string $marginCoin): ResponseInterface; public function getSingleAccount(string $marginCoin): ResponseInterface;
} }

View File

@ -33,7 +33,7 @@ class Header
$result = ''; $result = '';
foreach ($sortedParameters as $key => $value) { foreach ($sortedParameters as $key => $value) {
$result .= $key . $value; $result .= $key.$value;
} }
return $result; return $result;
@ -82,7 +82,7 @@ class Header
// Step 3: Create digest: SHA256(nonce + timestamp + api-key + queryParams + body (if not empty)) // Step 3: Create digest: SHA256(nonce + timestamp + api-key + queryParams + body (if not empty))
if (strlen($bodyString) == 0) { if (strlen($bodyString) == 0) {
$digestInput = $nonce.$timestamp.$apiKey.$queryParamsString; $digestInput = $nonce.$timestamp.$apiKey.$queryParamsString;
}else{ } else {
$digestInput = $nonce.$timestamp.$apiKey.$queryParamsString.$bodyString; $digestInput = $nonce.$timestamp.$apiKey.$queryParamsString.$bodyString;
} }
$digest = hash('sha256', $digestInput); $digest = hash('sha256', $digestInput);

View File

@ -14,7 +14,7 @@ beforeEach(function () {
it('can flash close position successfully', function () { it('can flash close position successfully', function () {
$api = app(FlashClosePositionRequestContract::class); $api = app(FlashClosePositionRequestContract::class);
expect(fn() => $api->flashClosePosition('19848247723672')) expect(fn () => $api->flashClosePosition('19848247723672'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });
@ -22,9 +22,9 @@ it('validates required position ID parameter', function () {
$api = app(FlashClosePositionRequestContract::class); $api = app(FlashClosePositionRequestContract::class);
// Test with valid position ID // Test with valid position ID
expect(fn() => $api->flashClosePosition('19848247723672')) expect(fn () => $api->flashClosePosition('19848247723672'))
->not->toThrow(Exception::class) ->not->toThrow(Exception::class)
->and(fn() => $api->flashClosePosition('123456789')) ->and(fn () => $api->flashClosePosition('123456789'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });
@ -36,11 +36,11 @@ it('can handle different position ID formats', function () {
'123456789', '123456789',
'987654321', '987654321',
'position-123', 'position-123',
'pos_456' 'pos_456',
]; ];
foreach ($positionIds as $positionId) { foreach ($positionIds as $positionId) {
expect(fn() => $api->flashClosePosition($positionId)) expect(fn () => $api->flashClosePosition($positionId))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
} }
}); });
@ -49,9 +49,9 @@ it('validates position ID parameter type', function () {
$api = app(FlashClosePositionRequestContract::class); $api = app(FlashClosePositionRequestContract::class);
// Test with string position ID // Test with string position ID
expect(fn() => $api->flashClosePosition('19848247723672')) expect(fn () => $api->flashClosePosition('19848247723672'))
->not->toThrow(Exception::class) ->not->toThrow(Exception::class)
->and(fn() => $api->flashClosePosition('123456789')) ->and(fn () => $api->flashClosePosition('123456789'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });
@ -59,9 +59,9 @@ it('can handle edge cases for position ID', function () {
$api = app(FlashClosePositionRequestContract::class); $api = app(FlashClosePositionRequestContract::class);
// Test with long position ID // Test with long position ID
expect(fn() => $api->flashClosePosition('198482477236721234567890')) expect(fn () => $api->flashClosePosition('198482477236721234567890'))
->not->toThrow(Exception::class) ->not->toThrow(Exception::class)
->and(fn() => $api->flashClosePosition('123')) ->and(fn () => $api->flashClosePosition('123'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });
@ -77,7 +77,7 @@ it('can handle multiple flash close position calls', function () {
$positionIds = ['19848247723672', '19848247723673', '19848247723674']; $positionIds = ['19848247723672', '19848247723673', '19848247723674'];
foreach ($positionIds as $positionId) { foreach ($positionIds as $positionId) {
expect(fn() => $api->flashClosePosition($positionId)) expect(fn () => $api->flashClosePosition($positionId))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
} }
}); });
@ -87,7 +87,7 @@ it('validates flash close position response structure', function () {
// This test verifies the method can be called without throwing exceptions // This test verifies the method can be called without throwing exceptions
// The actual response structure will be validated by the API // The actual response structure will be validated by the API
expect(fn() => $api->flashClosePosition('19848247723672')) expect(fn () => $api->flashClosePosition('19848247723672'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });
@ -95,9 +95,9 @@ it('can handle special characters in position ID', function () {
$api = app(FlashClosePositionRequestContract::class); $api = app(FlashClosePositionRequestContract::class);
// Test with position ID containing special characters // Test with position ID containing special characters
expect(fn() => $api->flashClosePosition('pos-123_456')) expect(fn () => $api->flashClosePosition('pos-123_456'))
->not->toThrow(Exception::class) ->not->toThrow(Exception::class)
->and(fn() => $api->flashClosePosition('pos.123.456')) ->and(fn () => $api->flashClosePosition('pos.123.456'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });
@ -106,6 +106,6 @@ it('validates flash close position with empty string', function () {
// This should not throw an exception at the method level // This should not throw an exception at the method level
// The API will handle validation // The API will handle validation
expect(fn() => $api->flashClosePosition('')) expect(fn () => $api->flashClosePosition(''))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });

View File

@ -14,28 +14,28 @@ beforeEach(function () {
it('can get all pending positions', function () { it('can get all pending positions', function () {
$api = app(GetPendingPositionsRequestContract::class); $api = app(GetPendingPositionsRequestContract::class);
expect(fn() => $api->getPendingPositions()) expect(fn () => $api->getPendingPositions())
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });
it('can get pending positions by symbol', function () { it('can get pending positions by symbol', function () {
$api = app(GetPendingPositionsRequestContract::class); $api = app(GetPendingPositionsRequestContract::class);
expect(fn() => $api->getPendingPositions('BTCUSDT')) expect(fn () => $api->getPendingPositions('BTCUSDT'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });
it('can get pending positions by position ID', function () { it('can get pending positions by position ID', function () {
$api = app(GetPendingPositionsRequestContract::class); $api = app(GetPendingPositionsRequestContract::class);
expect(fn() => $api->getPendingPositions(null, '19848247723672')) expect(fn () => $api->getPendingPositions(null, '19848247723672'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });
it('can get pending positions with both symbol and position ID', function () { it('can get pending positions with both symbol and position ID', function () {
$api = app(GetPendingPositionsRequestContract::class); $api = app(GetPendingPositionsRequestContract::class);
expect(fn() => $api->getPendingPositions('BTCUSDT', '19848247723672')) expect(fn () => $api->getPendingPositions('BTCUSDT', '19848247723672'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });
@ -43,15 +43,15 @@ it('validates required parameters for get pending positions', function () {
$api = app(GetPendingPositionsRequestContract::class); $api = app(GetPendingPositionsRequestContract::class);
// Test without parameters // Test without parameters
expect(fn() => $api->getPendingPositions()) expect(fn () => $api->getPendingPositions())
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
// Test with symbol only // Test with symbol only
expect(fn() => $api->getPendingPositions('BTCUSDT')) expect(fn () => $api->getPendingPositions('BTCUSDT'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
// Test with position ID only // Test with position ID only
expect(fn() => $api->getPendingPositions(null, '19848247723672')) expect(fn () => $api->getPendingPositions(null, '19848247723672'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });
@ -61,7 +61,7 @@ it('can handle different trading pairs', function () {
$tradingPairs = ['BTCUSDT', 'ETHUSDT', 'ADAUSDT']; $tradingPairs = ['BTCUSDT', 'ETHUSDT', 'ADAUSDT'];
foreach ($tradingPairs as $symbol) { foreach ($tradingPairs as $symbol) {
expect(fn() => $api->getPendingPositions($symbol)) expect(fn () => $api->getPendingPositions($symbol))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
} }
}); });
@ -74,11 +74,11 @@ it('can handle different position ID formats', function () {
'123456789', '123456789',
'987654321', '987654321',
'position-123', 'position-123',
'pos_456' 'pos_456',
]; ];
foreach ($positionIds as $positionId) { foreach ($positionIds as $positionId) {
expect(fn() => $api->getPendingPositions(null, $positionId)) expect(fn () => $api->getPendingPositions(null, $positionId))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
} }
}); });
@ -93,11 +93,11 @@ it('can handle edge cases for parameters', function () {
$api = app(GetPendingPositionsRequestContract::class); $api = app(GetPendingPositionsRequestContract::class);
// Test with empty string symbol // Test with empty string symbol
expect(fn() => $api->getPendingPositions('')) expect(fn () => $api->getPendingPositions(''))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
// Test with empty string position ID // Test with empty string position ID
expect(fn() => $api->getPendingPositions(null, '')) expect(fn () => $api->getPendingPositions(null, ''))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });
@ -105,11 +105,11 @@ it('can handle special characters in parameters', function () {
$api = app(GetPendingPositionsRequestContract::class); $api = app(GetPendingPositionsRequestContract::class);
// Test with special characters in symbol // Test with special characters in symbol
expect(fn() => $api->getPendingPositions('BTC-USDT')) expect(fn () => $api->getPendingPositions('BTC-USDT'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
// Test with special characters in position ID // Test with special characters in position ID
expect(fn() => $api->getPendingPositions(null, 'pos-123_456')) expect(fn () => $api->getPendingPositions(null, 'pos-123_456'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });
@ -118,7 +118,7 @@ it('validates get pending positions response structure', function () {
// This test verifies the method can be called without throwing exceptions // This test verifies the method can be called without throwing exceptions
// The actual response structure will be validated by the API // The actual response structure will be validated by the API
expect(fn() => $api->getPendingPositions()) expect(fn () => $api->getPendingPositions())
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });
@ -128,7 +128,7 @@ it('can handle multiple get pending positions calls', function () {
$symbols = ['BTCUSDT', 'ETHUSDT', 'ADAUSDT']; $symbols = ['BTCUSDT', 'ETHUSDT', 'ADAUSDT'];
foreach ($symbols as $symbol) { foreach ($symbols as $symbol) {
expect(fn() => $api->getPendingPositions($symbol)) expect(fn () => $api->getPendingPositions($symbol))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
} }
}); });
@ -139,11 +139,11 @@ it('can handle combination of symbol and position ID', function () {
$combinations = [ $combinations = [
['BTCUSDT', '19848247723672'], ['BTCUSDT', '19848247723672'],
['ETHUSDT', '19848247723673'], ['ETHUSDT', '19848247723673'],
['ADAUSDT', '19848247723674'] ['ADAUSDT', '19848247723674'],
]; ];
foreach ($combinations as [$symbol, $positionId]) { foreach ($combinations as [$symbol, $positionId]) {
expect(fn() => $api->getPendingPositions($symbol, $positionId)) expect(fn () => $api->getPendingPositions($symbol, $positionId))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
} }
}); });

View File

@ -14,7 +14,7 @@ beforeEach(function () {
it('can get single account successfully', function () { it('can get single account successfully', function () {
$api = app(GetSingleAccountRequestContract::class); $api = app(GetSingleAccountRequestContract::class);
expect(fn() => $api->getSingleAccount('USDT')) expect(fn () => $api->getSingleAccount('USDT'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });
@ -22,11 +22,11 @@ it('validates required margin coin parameter', function () {
$api = app(GetSingleAccountRequestContract::class); $api = app(GetSingleAccountRequestContract::class);
// Test with valid margin coin // Test with valid margin coin
expect(fn() => $api->getSingleAccount('USDT')) expect(fn () => $api->getSingleAccount('USDT'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
// Test with different margin coins // Test with different margin coins
expect(fn() => $api->getSingleAccount('BTC')) expect(fn () => $api->getSingleAccount('BTC'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });
@ -36,7 +36,7 @@ it('can handle different margin coins', function () {
$marginCoins = ['USDT', 'BTC', 'ETH', 'BNB', 'ADA']; $marginCoins = ['USDT', 'BTC', 'ETH', 'BNB', 'ADA'];
foreach ($marginCoins as $marginCoin) { foreach ($marginCoins as $marginCoin) {
expect(fn() => $api->getSingleAccount($marginCoin)) expect(fn () => $api->getSingleAccount($marginCoin))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
} }
}); });
@ -51,11 +51,11 @@ it('can handle edge cases for margin coin', function () {
$api = app(GetSingleAccountRequestContract::class); $api = app(GetSingleAccountRequestContract::class);
// Test with uppercase margin coin // Test with uppercase margin coin
expect(fn() => $api->getSingleAccount('USDT')) expect(fn () => $api->getSingleAccount('USDT'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
// Test with lowercase margin coin // Test with lowercase margin coin
expect(fn() => $api->getSingleAccount('usdt')) expect(fn () => $api->getSingleAccount('usdt'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });
@ -64,7 +64,7 @@ it('validates get single account response structure', function () {
// This test verifies the method can be called without throwing exceptions // This test verifies the method can be called without throwing exceptions
// The actual response structure will be validated by the API // The actual response structure will be validated by the API
expect(fn() => $api->getSingleAccount('USDT')) expect(fn () => $api->getSingleAccount('USDT'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });
@ -74,7 +74,7 @@ it('can handle multiple get single account calls', function () {
$marginCoins = ['USDT', 'BTC', 'ETH']; $marginCoins = ['USDT', 'BTC', 'ETH'];
foreach ($marginCoins as $marginCoin) { foreach ($marginCoins as $marginCoin) {
expect(fn() => $api->getSingleAccount($marginCoin)) expect(fn () => $api->getSingleAccount($marginCoin))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
} }
}); });
@ -83,11 +83,11 @@ it('validates margin coin parameter type', function () {
$api = app(GetSingleAccountRequestContract::class); $api = app(GetSingleAccountRequestContract::class);
// Test with string margin coin // Test with string margin coin
expect(fn() => $api->getSingleAccount('USDT')) expect(fn () => $api->getSingleAccount('USDT'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
// Test with different string formats // Test with different string formats
expect(fn() => $api->getSingleAccount('BTC')) expect(fn () => $api->getSingleAccount('BTC'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });
@ -95,11 +95,11 @@ it('can handle special characters in margin coin', function () {
$api = app(GetSingleAccountRequestContract::class); $api = app(GetSingleAccountRequestContract::class);
// Test with margin coin containing special characters // Test with margin coin containing special characters
expect(fn() => $api->getSingleAccount('USDT')) expect(fn () => $api->getSingleAccount('USDT'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
// Test with margin coin containing numbers // Test with margin coin containing numbers
expect(fn() => $api->getSingleAccount('USDT')) expect(fn () => $api->getSingleAccount('USDT'))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });
@ -108,6 +108,6 @@ it('validates get single account with empty string', function () {
// This should not throw an exception at the method level // This should not throw an exception at the method level
// The API will handle validation // The API will handle validation
expect(fn() => $api->getSingleAccount('')) expect(fn () => $api->getSingleAccount(''))
->not->toThrow(Exception::class); ->not->toThrow(Exception::class);
}); });