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

Profile   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 1
b 0
f 0
dl 0
loc 25
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A balance() 0 6 1
A dailyStat() 0 6 1
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