Completed
Push — master ( 941bae...7099e1 )
by Vladymyr
01:43
created

Markets::buildQueryGetTimeseries()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 6
dl 0
loc 15
ccs 5
cts 5
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Codenixsv\MessariApi\Api;
6
7
use Exception;
8
9
/**
10
 * Class Markets
11
 * @package Codenixsv\MessariApi\Api
12
 */
13
class Markets extends Api
14
{
15
    /**
16
     * @param int|null $page Page number, starts at 1. Increment to paginate through results (until
17
     *  result is empty array)
18
     * @param string|null $fields pare down the returned fields (comma , separated, drill down with a slash /)
19
     * @return array
20
     * @throws Exception
21
     */
22 2
    public function getAll(?int $page = null, ?string $fields = null): array
23
    {
24 2
        $query = $this->queryBuilder->buildQuery(compact('fields', 'page'));
25 2
        $response = $this->client->getBaseClient()->get('/markets' . $query);
26
27 2
        return $this->transformer->transform($response);
28
    }
29
30
    /**
31
     * Retrieve historical timeseries data for a market.
32
     *
33
     * @param string $assetKey This "key" can be the asset's ID (unique), slug (unique), or symbol (non-unique)
34
     * @param string $metricID The metricID is a unique identifier which describes the type of data returned by
35
     *  time-series endpoints.
36
     * @param string|null $start The "start" query parameter can be used to set the start date after which points
37
     *  are returned.
38
     * @param string|null $end The "end" query parameter can be used to set the end date after which no more points
39
     *  will be returned.
40
     * @param string|null $interval Defines what interval the resulting points will be returned in.
41
     * @param string|null $columns A comma separated list of strings that controls which columns will be returned and
42
     *  in what order.
43
     * @param string|null $order Order controls whether points in the response are returned in ascending or
44
     *  descending order.
45
     * @param string|null $format Specify format = csv to download data as CSV.
46
     * @return array
47
     * @throws Exception
48
     */
49 2
    public function getTimeseries(
50
        string $assetKey,
51
        string $metricID,
52
        ?string $start = null,
53
        ?string $end = null,
54
        ?string $interval = null,
55
        ?string $columns = null,
56
        ?string $order = null,
57
        ?string $format = null
58
    ): array {
59 2
        $query = $this->queryBuilder->buildQuery(compact('start', 'end', 'interval', 'columns', 'order', 'format'));
60 2
        $response = $this->client->getBaseClient()->get('/markets/' . strtolower($assetKey) . '/metrics/'
61 2
            . $metricID . '/time-series' . $query);
62
63 2
        return $this->transformer->transform($response);
64
    }
65
}
66