定制 rocketfellows/tinkoff-invest-v1-rest-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rocketfellows/tinkoff-invest-v1-rest-client

Composer 安装命令:

composer require rocketfellows/tinkoff-invest-v1-rest-client

包简介

README 文档

README

Code Coverage Badge

This component implement's wrapper over guzzle http client for sending request to Tinkoff Invest V1.

Consist of:

  • \rocketfellows\TinkoffInvestV1RestClient\Client - intended for direct sending of requests
  • \rocketfellows\TinkoffInvestV1RestClient\ClientConfig - client configuration

Installation

composer require rocketfellows/tinkoff-invest-v1-rest-client

Client config

ClientConfig contains:

  • serverUrl - which is common Tinkoff Invest V1 url, for example https://invest-public-api.tinkoff.ru/rest
  • accessToken - Tinkoff Invest V1 access token which can be generated through the account settings of the Tinkoff Investments application

ClientConfig can be configured through DI from your environment params. For example: for test environment of your application you can set serverUrl with Tinkoff Invest V1 sandbox, accessToken - with generated from Tinkoff Investments application for sandbox.

Client

Client interface:

public function request(string $serviceName, string $serviceMethod, array $data): array;

Where $serviceName for example InstrumentsService and $serviceMethod for example GetDividends. Full list of available Tinkoff Invest V1 services and methods here https://tinkoff.github.io/investAPI/swagger-ui/

Interface exceptions

  • \rocketfellows\TinkoffInvestV1RestClient\exceptions\request\ServerException - exception when a server error is encountered (5xx codes)
  • \rocketfellows\TinkoffInvestV1RestClient\exceptions\request\ClientException - exception when a client error is encountered (4xx codes)
  • \rocketfellows\TinkoffInvestV1RestClient\exceptions\request\HttpClientException - exception for other errors

Both ServerException and ClientException extends \rocketfellows\TinkoffInvestV1RestClient\exceptions\request\BadResponseException which holds server error response data:

  • \rocketfellows\TinkoffInvestV1RestClient\exceptions\request\BadResponseException::getErrorCode
  • \rocketfellows\TinkoffInvestV1RestClient\exceptions\request\BadResponseException::getErrorMessage
  • \rocketfellows\TinkoffInvestV1RestClient\exceptions\request\BadResponseException::getErrorDescription

Server error data response example:

{
    "code": 3,
    "message": "missing parameter: 'figi'",
    "description": "30008"
}

Component dependencies

"guzzlehttp/guzzle": "7.4.3" - https://github.com/guzzle/guzzle

Usage example

$client = new Client(
    (
        new ClientConfig(
            'https://invest-public-api.tinkoff.ru/rest',
            <your_access_token>
        )
    ),
    new \GuzzleHttp\Client()
);

$response = $client->request(
    'InstrumentsService',
    'GetDividends',
    [
        "figi" => "BBG004730RP0",
        "from" => "2022-05-28T15:38:52.283Z",
        "to" => '2022-08-18T15:38:52.283Z',
    ]
);

// response
array(1) {
  ["dividends"]=>
  array(1) {
    [0]=>
    array(9) {
      ["dividendNet"]=>
      array(3) {
        ["currency"]=>
        string(3) "rub"
        ["units"]=>
        string(2) "52"
        ["nano"]=>
        int(530000000)
      }
      ["declaredDate"]=>
      string(20) "2022-06-30T00:00:00Z"
      ["lastBuyDate"]=>
      string(20) "2022-07-18T00:00:00Z"
      ["dividendType"]=>
      string(0) ""
      ["recordDate"]=>
      string(20) "2022-07-20T00:00:00Z"
      ["regularity"]=>
      string(0) ""
      ["closePrice"]=>
      array(3) {
        ["currency"]=>
        string(3) "rub"
        ["units"]=>
        string(3) "297"
        ["nano"]=>
        int(0)
      }
      ["yieldValue"]=>
      array(2) {
        ["units"]=>
        string(2) "17"
        ["nano"]=>
        int(690000000)
      }
      ["createdAt"]=>
      string(27) "2022-06-06T02:04:47.759671Z"
    }
  }
}

Contributing

Welcome to pull requests. If there is a major changes, first please open an issue for discussion.

Please make sure to update tests as appropriate.

rocketfellows/tinkoff-invest-v1-rest-client 适用场景与选型建议

rocketfellows/tinkoff-invest-v1-rest-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 221 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 06 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 rocketfellows/tinkoff-invest-v1-rest-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 rocketfellows/tinkoff-invest-v1-rest-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 rocketfellows/tinkoff-invest-v1-rest-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 221
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 7
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-06