rocketfellows / tinkoff-invest-v1-operations-rest-client
v1.0.0
2022-06-27 21:43 UTC
Requires
- php: >=7.4
- rocketfellows/tinkoff-invest-v1-rest-client: 1.0.2
Requires (Dev)
- phpstan/phpstan: ^0.12.90
- phpunit/phpunit: ^8.5
- squizlabs/php_codesniffer: 3.6.2
This package is not auto-updated.
Last update: 2024-09-18 06:38:29 UTC
README
对tinkoff invest v1操作服务的简单实现。目前提供了以下方法:
- GetPortfolio - https://tinkoff.github.io/investAPI/swagger-ui/#/OperationsService/OperationsService_GetPortfolio
- GetPositions - https://tinkoff.github.io/investAPI/swagger-ui/#/OperationsService/OperationsService_GetPositions
- GetWithdrawLimits - https://tinkoff.github.io/investAPI/swagger-ui/#/OperationsService/OperationsService_GetWithdrawLimits
方法接口
- rocketfellows\TinkoffInvestV1OperationsRestClient\GetPortfolioInterface
- rocketfellows\TinkoffInvestV1OperationsRestClient\GetPositionsInterface
- rocketfellows\TinkoffInvestV1OperationsRestClient\GetWithdrawLimitsInterface
将方法接口实现聚合到 rocketfellows\TinkoffInvestV1OperationsRestClient\OperationsService。
出于接口分离原则,您应注入特定的接口作为依赖项,并通过容器(DI)定义实现。
安装
composer require rocketfellows/tinkoff-invest-v1-operations-rest-client
方法合约定义
组件方法接受数组作为参数,原始数组也用作输出值。
方法抛出以下类型的异常
- rocketfellows\TinkoffInvestV1RestClient\exceptions\request\ClientException
- rocketfellows\TinkoffInvestV1RestClient\exceptions\request\ServerException
- rocketfellows\TinkoffInvestV1RestClient\exceptions\request\HttpClientException
组件依赖项
"rocketfellows/tinkoff-invest-v1-rest-client": "1.0.2" - 作为通用http客户端。
使用示例
通用http客户端配置
$client = new Client( ( new ClientConfig( 'https://invest-public-api.tinkoff.ru/rest', <your_access_token> ) ), new \GuzzleHttp\Client() );
操作服务配置(或通过DI进行接口特定方法配置)
$operationsService = new OperationsService($client);
获取账户投资组合方法调用示例
$operationsService->getPortfolio([ "accountId" => "<your_account_id>", ]);
您可以在以下位置找到结果方案: https://tinkoff.github.io/investAPI/swagger-ui/#/OperationsService/OperationsService_GetPortfolio
贡献
欢迎提交拉取请求。如果有重大更改,请首先为讨论打开一个问题。
请确保根据需要更新测试。