Compare commits

..
Author SHA1 Message Date
dependabot[bot] cd51c513d7 build(deps): bump actions/checkout from 5 to 6
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-24 22:23:04 +00:00
mahdi mansouri 21e94df5ff Merge pull request #11 from mahdimsr/dev
dev: match composer version with release tag
2025-11-23 16:07:53 +03:30
mahdi mansouri ad9acbd410 Merge pull request #8 from mahdimsr/dependabot/github_actions/stefanzweifel/git-auto-commit-action-7
build(deps): bump stefanzweifel/git-auto-commit-action from 6 to 7
2025-11-23 16:05:55 +03:30
mahdi msr f04b685496 dev: match composer version with release tag 2025-11-23 16:04:53 +03:30
mahdi msr 8e5b631dc7 main: match composer version with release tag 2025-11-23 16:03:04 +03:30
mahdi mansouri 4ce40bd4c8 Merge pull request #10 from mahdimsr/dev
Add get trading pair request
2025-11-23 15:54:23 +03:30
mahdi msr 85b677ee0e dev: make instant from GetTradingPairRequestContract 2025-11-23 15:52:19 +03:30
mahdi mansouri 8ccede169c Merge pull request #9 from mahdimsr/get-trading-pairs-requests
Get trading pairs requests
2025-11-23 15:46:55 +03:30
mahdimsr 82a0ac77f4 Fix styling 2025-11-23 12:16:16 +00:00
mahdi msr 5a6e9cca1d dev: add trading pairs request 2025-11-23 15:45:43 +03:30
dependabot[bot] b40852117f build(deps): bump stefanzweifel/git-auto-commit-action from 6 to 7
Bumps [stefanzweifel/git-auto-commit-action](https://github.com/stefanzweifel/git-auto-commit-action) from 6 to 7.
- [Release notes](https://github.com/stefanzweifel/git-auto-commit-action/releases)
- [Changelog](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stefanzweifel/git-auto-commit-action/compare/v6...v7)

---
updated-dependencies:
- dependency-name: stefanzweifel/git-auto-commit-action
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-13 21:39:46 +00:00
mahdi mansouri 67a9344d14 Merge pull request #7 from mahdimsr/dev
Update README.md
2025-09-30 10:36:47 +03:30
mahdi mansouri 0a8ef0280f Update README.md 2025-09-30 10:36:14 +03:30
mahdi mansouri 1c69e169f3 Update README.md 2025-09-29 04:41:47 +03:30
mahdi mansouri 8b416c09e0 Merge pull request #6 from mahdimsr/dev
dev: update run-tests.yml for running test action
2025-09-29 04:17:32 +03:30
mahdi msr 04ecce7bd7 dev: remove laravel 10 test support 2025-09-29 04:14:56 +03:30
mahdi msr 578fac70a0 dev: remove php 8.3 2025-09-29 04:10:55 +03:30
mahdi msr cf59fc1e59 dev: add test bench version 2025-09-29 04:08:28 +03:30
mahdi msr 3846263eb6 dev: update run-tests.yml for running test action 2025-09-29 04:05:56 +03:30
mahdi msr 63a45260c9 Merge remote-tracking branch 'origin/dev' into dev 2025-09-29 04:04:25 +03:30
mahdi msr 27550372df dev: update run-tests.yml for running test action 2025-09-29 04:04:14 +03:30
mahdi mansouri db7f68ada8 Merge branch 'main' into dev 2025-09-29 04:01:53 +03:30
mahdi msr 6059ef32e0 dev: update run-tests.yml for running test action 2025-09-29 04:00:18 +03:30
mahdi msr 60eb009213 main: update run-tests.yml 2025-09-29 03:58:08 +03:30
9 changed files with 164 additions and 16 deletions

No files matched your search

@@ -15,7 +15,7 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
ref: ${{ github.head_ref }}
@@ -23,6 +23,6 @@ jobs:
uses: aglipanci/laravel-pint-action@2.6
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v6
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: Fix styling
+1 -1
View File
@@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
+8 -10
View File
@@ -2,12 +2,9 @@ name: run-tests
on:
push:
paths:
- '**.php'
- '.github/workflows/run-tests.yml'
- 'phpunit.xml.dist'
- 'composer.json'
- 'composer.lock'
branches: [main, dev]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
@@ -15,25 +12,26 @@ concurrency:
jobs:
test:
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.4, 8.3]
php: [8.4]
laravel: [12.*, 11.*]
stability: [prefer-stable]
include:
- laravel: 12.*
testbench: 10.*
- laravel: 11.*
- laravel: 10.*
testbench: 9.*
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v5
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
+10 -1
View File
@@ -2,10 +2,19 @@
A Laravel package for interacting with the Bitunix cryptocurrency exchange API.
---
[![Latest Stable Version](https://poser.pugx.org/mahdimsr/laravel-bitunix-api/v/stable)](https://packagist.org/packages/msr/laravel-bitunix-api)
[![Fix PHP code style issues](https://github.com/mahdimsr/laravel-bitunix-api/actions/workflows/fix-php-code-style-issues.yml/badge.svg)](https://github.com/mahdimsr/laravel-bitunix-api/actions/workflows/fix-php-code-style-issues.yml)
[![PHPStan](https://github.com/mahdimsr/laravel-bitunix-api/actions/workflows/phpstan.yml/badge.svg)](https://github.com/mahdimsr/laravel-bitunix-api/actions/workflows/phpstan.yml)
[![run-tests](https://github.com/mahdimsr/laravel-bitunix-api/actions/workflows/run-tests.yml/badge.svg)](https://github.com/mahdimsr/laravel-bitunix-api/actions/workflows/run-tests.yml)
[![License](https://poser.pugx.org/mahdimsr/laravel-bitunix-api/license)](https://packagist.org/packages/msr/laravel-bitunix-api)
## Installation
```bash
composer require msr/laravel-bitunix-api
composer require mahdimsr/laravel-bitunix-api
```
## Configuration
+1 -1
View File
@@ -69,7 +69,7 @@
}
}
},
"version": "1.0.0",
"version": "1.1.0",
"minimum-stability": "stable",
"prefer-stable": true
}
+17 -1
View File
@@ -9,13 +9,14 @@ use Msr\LaravelBitunixApi\Requests\FlashClosePositionRequestContract;
use Msr\LaravelBitunixApi\Requests\FutureKLineRequestContract;
use Msr\LaravelBitunixApi\Requests\GetPendingPositionsRequestContract;
use Msr\LaravelBitunixApi\Requests\GetSingleAccountRequestContract;
use Msr\LaravelBitunixApi\Requests\GetTradingPairsRequestContract;
use Msr\LaravelBitunixApi\Requests\Header;
use Msr\LaravelBitunixApi\Requests\PlaceOrderRequestContract;
use Msr\LaravelBitunixApi\Requests\PlacePositionTpSlOrderRequestContract;
use Msr\LaravelBitunixApi\Requests\PlaceTpSlOrderRequestContract;
use Psr\Http\Message\ResponseInterface;
class LaravelBitunixApi implements ChangeLeverageRequestContract, ChangeMarginModeRequestContract, FlashClosePositionRequestContract, FutureKLineRequestContract, GetPendingPositionsRequestContract, GetSingleAccountRequestContract, PlaceOrderRequestContract, PlacePositionTpSlOrderRequestContract, PlaceTpSlOrderRequestContract
class LaravelBitunixApi implements ChangeLeverageRequestContract, ChangeMarginModeRequestContract, FlashClosePositionRequestContract, FutureKLineRequestContract, GetPendingPositionsRequestContract, GetSingleAccountRequestContract, GetTradingPairsRequestContract, PlaceOrderRequestContract, PlacePositionTpSlOrderRequestContract, PlaceTpSlOrderRequestContract
{
private Client $publicFutureClient;
@@ -53,6 +54,21 @@ class LaravelBitunixApi implements ChangeLeverageRequestContract, ChangeMarginMo
return $response;
}
public function getTradingPairs(?string $symbols = null): ResponseInterface
{
$queryParams = [];
if ($symbols !== null) {
$queryParams['symbols'] = $symbols;
}
$response = $this->publicFutureClient->get('trading_pairs', [
'query' => $queryParams,
]);
return $response;
}
public function changeLeverage(string $symbol, string $marginCoin, int $leverage): ResponseInterface
{
$body = [
+2
View File
@@ -9,6 +9,7 @@ use Msr\LaravelBitunixApi\Requests\FlashClosePositionRequestContract;
use Msr\LaravelBitunixApi\Requests\FutureKLineRequestContract;
use Msr\LaravelBitunixApi\Requests\GetPendingPositionsRequestContract;
use Msr\LaravelBitunixApi\Requests\GetSingleAccountRequestContract;
use Msr\LaravelBitunixApi\Requests\GetTradingPairsRequestContract;
use Msr\LaravelBitunixApi\Requests\PlaceOrderRequestContract;
use Msr\LaravelBitunixApi\Requests\PlacePositionTpSlOrderRequestContract;
use Msr\LaravelBitunixApi\Requests\PlaceTpSlOrderRequestContract;
@@ -45,5 +46,6 @@ class LaravelBitunixApiServiceProvider extends PackageServiceProvider
$this->app->bind(GetSingleAccountRequestContract::class, LaravelBitunixApi::class);
$this->app->bind(PlaceTpSlOrderRequestContract::class, LaravelBitunixApi::class);
$this->app->bind(PlacePositionTpSlOrderRequestContract::class, LaravelBitunixApi::class);
$this->app->bind(GetTradingPairsRequestContract::class, LaravelBitunixApi::class);
}
}
@@ -0,0 +1,15 @@
<?php
namespace Msr\LaravelBitunixApi\Requests;
use Psr\Http\Message\ResponseInterface;
interface GetTradingPairsRequestContract
{
/**
* Get future trading pair details
*
* @param string|null $symbols Trading pairs, comma-separated (e.g., "BTCUSDT,ETHUSDT,XRPUSDT")
*/
public function getTradingPairs(?string $symbols = null): ResponseInterface;
}
+108
View File
@@ -0,0 +1,108 @@
<?php
use Msr\LaravelBitunixApi\Requests\GetTradingPairsRequestContract;
beforeEach(function () {
config([
'bitunix-api.future_base_uri' => 'https://fapi.bitunix.com/',
'bitunix-api.api_key' => 'test-api-key',
'bitunix-api.api_secret' => 'test-secret-key',
'bitunix-api.language' => 'en-US',
]);
});
it('check trading pairs request response code', function () {
$bootedClass = app(GetTradingPairsRequestContract::class);
$response = $bootedClass->getTradingPairs();
expect($response->getStatusCode())
->toBe(200)
->and(json_decode($response->getBody()->getContents(), true))
->toHaveKeys(['code', 'data', 'msg']);
});
it('can get trading pairs with specific symbols', function () {
$api = app(GetTradingPairsRequestContract::class);
expect(fn () => $api->getTradingPairs('BTCUSDT,ETHUSDT'))
->not->toThrow(Exception::class);
});
it('can get trading pairs without symbols parameter', function () {
$api = app(GetTradingPairsRequestContract::class);
expect(fn () => $api->getTradingPairs())
->not->toThrow(Exception::class);
});
it('validates get trading pairs method exists', function () {
$api = app(GetTradingPairsRequestContract::class);
expect(method_exists($api, 'getTradingPairs'))->toBeTrue();
});
it('can handle single symbol', function () {
$api = app(GetTradingPairsRequestContract::class);
expect(fn () => $api->getTradingPairs('BTCUSDT'))
->not->toThrow(Exception::class);
});
it('can handle multiple symbols', function () {
$api = app(GetTradingPairsRequestContract::class);
$symbols = 'BTCUSDT,ETHUSDT,XRPUSDT';
expect(fn () => $api->getTradingPairs($symbols))
->not->toThrow(Exception::class);
});
it('validates trading pairs response structure', function () {
$api = app(GetTradingPairsRequestContract::class);
$response = $api->getTradingPairs();
$data = json_decode($response->getBody()->getContents(), true);
expect($response->getStatusCode())->toBe(200)
->and($data)->toHaveKeys(['code', 'data', 'msg']);
if (isset($data['data']) && is_array($data['data']) && count($data['data']) > 0) {
$firstPair = $data['data'][0];
expect($firstPair)->toHaveKeys([
'symbol',
'base',
'quote',
'minTradeVolume',
'minBuyPriceOffset',
'maxSellPriceOffset',
'maxLimitOrderVolume',
'maxMarketOrderVolume',
'basePrecision',
'quotePrecision',
'maxLeverage',
'minLeverage',
'defaultLeverage',
'defaultMarginMode',
'priceProtectScope',
'symbolStatus',
]);
}
});
it('can handle different symbol formats', function () {
$api = app(GetTradingPairsRequestContract::class);
// Test with uppercase symbols
expect(fn () => $api->getTradingPairs('BTCUSDT'))
->not->toThrow(Exception::class);
// Test with lowercase symbols
expect(fn () => $api->getTradingPairs('btcusdt'))
->not->toThrow(Exception::class);
});
it('can handle empty symbols parameter', function () {
$api = app(GetTradingPairsRequestContract::class);
// Test with null (should return all trading pairs)
expect(fn () => $api->getTradingPairs(null))
->not->toThrow(Exception::class);
});