rocketfellows/tinkoff-invest-v1-users-rest-client

v1.0.0 2022-06-30 21:30 UTC

This package is not auto-updated.

Last update: 2024-09-21 06:28:33 UTC


README

Code Coverage Badge

tinkoff invest v1 用户服务简单实现。目前提供以下方法

方法接口

  • rocketfellows\TinkoffInvestV1UsersRestClient\GetUserTariffInterface
  • rocketfellows\TinkoffInvestV1UsersRestClient\GetMarginAttributesInterface
  • rocketfellows\TinkoffInvestV1UsersRestClient\GetInfoInterface
  • rocketfellows\TinkoffInvestV1UsersRestClient\GetAccountsInterface

将方法接口实现聚合在 rocketfellows\TinkoffInvestV1UsersRestClient\UsersService。

为了遵循接口隔离原则,您应注入特定接口作为依赖,并通过容器(DI)定义实现。

安装

composer require rocketfellows/tinkoff-invest-v1-users-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 的接口特定方法配置)

$usersService = new UsersService($client);

获取账户投资组合方法调用示例

$usersService->getAccounts();

结果模式您可以在以下链接找到: https://tinkoff.github.io/investAPI/swagger-ui/#/UsersService/UsersService_GetAccounts

贡献

欢迎提交拉取请求。如果发生重大变更,请先创建一个问题进行讨论。

请确保根据需要更新测试。