PHP code example of rocketfellows / tinkoff-invest-v1-method-get-dividends

1. Go to this page and download the library: Download rocketfellows/tinkoff-invest-v1-method-get-dividends library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rocketfellows / tinkoff-invest-v1-method-get-dividends example snippets


/**
 * @throws SourceFaultException
 * @throws IncorrectInputsFaultException
 */
public function getAll(string $figi): Dividends;

/**
 * @throws SourceFaultException
 * @throws IncorrectInputsFaultException
 */
public function getBeforeDate(string $figi, DateTime $dateTime): Dividends;

/**
 * @throws IncorrectInputsFaultException
 * @throws SourceFaultException
 */
public function getByPeriod(string $figi, DateTime $fromDateTime, DateTime $toDateTime): Dividends;

/**
* @throws IncorrectInputsFaultException
* @throws SourceFaultException
*/
public function requestAll(string $figi): Dividends;

/**
* @throws IncorrectInputsFaultException
* @throws SourceFaultException
*/
public function requestToDate(string $figi, DateTime $toDateTime): Dividends;

/**
* @throws IncorrectInputsFaultException
* @throws SourceFaultException
*/
public function requestByPeriod(string $figi, DateTime $fromDateTime, DateTime $toDateTime): Dividends;

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

$instrumentsService = new \rocketfellows\TinkoffInvestV1InstrumentsRestClient\InstrumentsService($client);

$dividendsRequestService = new \rocketfellows\TinkoffInvestV1MethodGetDividends\adapters\rest\DividendsRequestService($instrumentsService);


$dividends = $dividendsService->getByPeriod(
    'BBG004730RP0',
    new DateTime('2022-05-24T15:38:52.283Z'),
    new DateTime('2022-08-24T15:38:52.283Z'),
);

var_dump($dividends);


object(rocketfellows\TinkoffInvestV1MethodGetDividends\models\Dividends)#35 (2) {
  ["data":protected]=>
  array(1) {
    [0]=>
    object(rocketfellows\TinkoffInvestV1MethodGetDividends\models\Dividend)#38 (10) {
      ["dividendNet":"rocketfellows\TinkoffInvestV1MethodGetDividends\models\Dividend":private]=>
      object(rocketfellows\TinkoffInvestV1Common\models\MoneyValue)#36 (3) {
        ["currency":"rocketfellows\TinkoffInvestV1Common\models\MoneyValue":private]=>
        object(arslanimamutdinov\ISOStandard4217\Currency)#23 (3) {
          ["name":"arslanimamutdinov\ISOStandard4217\Currency":private]=>
          string(13) "Russian ruble"
          ["alpha3":"arslanimamutdinov\ISOStandard4217\Currency":private]=>
          string(3) "RUB"
          ["numericCode":"arslanimamutdinov\ISOStandard4217\Currency":private]=>
          string(3) "643"
        }
        ["units":"rocketfellows\TinkoffInvestV1Common\models\MoneyValue":private]=>
        int(52)
        ["nano":"rocketfellows\TinkoffInvestV1Common\models\MoneyValue":private]=>
        int(530000000)
      }
      ["closePrice":"rocketfellows\TinkoffInvestV1MethodGetDividends\models\Dividend":private]=>
      object(rocketfellows\TinkoffInvestV1Common\models\MoneyValue)#33 (3) {
        ["currency":"rocketfellows\TinkoffInvestV1Common\models\MoneyValue":private]=>
        object(arslanimamutdinov\ISOStandard4217\Currency)#26 (3) {
          ["name":"arslanimamutdinov\ISOStandard4217\Currency":private]=>
          string(13) "Russian ruble"
          ["alpha3":"arslanimamutdinov\ISOStandard4217\Currency":private]=>
          string(3) "RUB"
          ["numericCode":"arslanimamutdinov\ISOStandard4217\Currency":private]=>
          string(3) "643"
        }
        ["units":"rocketfellows\TinkoffInvestV1Common\models\MoneyValue":private]=>
        int(296)
        ["nano":"rocketfellows\TinkoffInvestV1Common\models\MoneyValue":private]=>
        int(0)
      }
      ["yieldValue":"rocketfellows\TinkoffInvestV1MethodGetDividends\models\Dividend":private]=>
      object(rocketfellows\TinkoffInvestV1Common\models\Quotation)#24 (2) {
        ["units":"rocketfellows\TinkoffInvestV1Common\models\Quotation":private]=>
        int(17)
        ["nano":"rocketfellows\TinkoffInvestV1Common\models\Quotation":private]=>
        int(750000000)
      }
      ["paymentDate":"rocketfellows\TinkoffInvestV1MethodGetDividends\models\Dividend":private]=>
      NULL
      ["declaredDate":"rocketfellows\TinkoffInvestV1MethodGetDividends\models\Dividend":private]=>
      object(DateTime)#22 (3) {
        ["date"]=>
        string(26) "2022-06-30 00:00:00.000000"
        ["timezone_type"]=>
        int(2)
        ["timezone"]=>
        string(1) "Z"
      }
      ["lastBuyDate":"rocketfellows\TinkoffInvestV1MethodGetDividends\models\Dividend":private]=>
      object(DateTime)#37 (3) {
        ["date"]=>
        string(26) "2022-07-18 00:00:00.000000"
        ["timezone_type"]=>
        int(2)
        ["timezone"]=>
        string(1) "Z"
      }
      ["recordDate":"rocketfellows\TinkoffInvestV1MethodGetDividends\models\Dividend":private]=>
      object(DateTime)#30 (3) {
        ["date"]=>
        string(26) "2022-07-20 00:00:00.000000"
        ["timezone_type"]=>
        int(2)
        ["timezone"]=>
        string(1) "Z"
      }
      ["createdAt":"rocketfellows\TinkoffInvestV1MethodGetDividends\models\Dividend":private]=>
      object(DateTime)#39 (3) {
        ["date"]=>
        string(26) "2022-06-26 02:04:44.658320"
        ["timezone_type"]=>
        int(2)
        ["timezone"]=>
        string(1) "Z"
      }
      ["dividendType":"rocketfellows\TinkoffInvestV1MethodGetDividends\models\Dividend":private]=>
      string(0) ""
      ["regularity":"rocketfellows\TinkoffInvestV1MethodGetDividends\models\Dividend":private]=>
      string(0) ""
    }
  }
  ["position"]=>
  int(0)
}