Completed
Push — master ( 75bb60...f66dd4 )
by Dmitry
01:14
created

Profile::balance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Promopult\Dadata\Services;
6
7
/**
8
 * Class Profile
9
 */
10
final class Profile extends \Promopult\Dadata\Service
11
{
12
    /**
13
     * @return array
14
     * @throws \Psr\Http\Client\ClientExceptionInterface
15
     */
16
    public function balance(): array
17
    {
18
        $request = $this->requestFactory->createRequest('POST', 'https://dadata.ru/api/v2/profile/balance');
19
        $response = $this->httpClient->sendRequest($request);
20
21
        return \json_decode($response->getBody()->getContents(), true);
22
    }
23
24
    /**
25
     * @param string $date  Дата в формате YYYY-mm-dd
26
     * @return array
27
     * @throws \Psr\Http\Client\ClientExceptionInterface
28
     */
29
    public function dailyStat(string $date): array
30
    {
31
        $request = $this->requestFactory->createRequest('POST', 'https://dadata.ru/api/v2/stat/daily?date=' . $date);
32
        $response = $this->httpClient->sendRequest($request);
33
34
        return \json_decode($response->getBody()->getContents(), true);
35
    }
36
}
37