|
1
|
|
|
<?php |
|
2
|
|
|
namespace Yandex\Metrica\Stat; |
|
3
|
|
|
|
|
4
|
|
|
use Yandex\Metrica\Stat\StatClient; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Class DataClient |
|
8
|
|
|
* |
|
9
|
|
|
* @category Yandex |
|
10
|
|
|
* @package Metrica |
|
11
|
|
|
* |
|
12
|
|
|
* @author Tanya Kalashnik |
|
13
|
|
|
* @created 18.07.14 15:37 |
|
14
|
|
|
*/ |
|
15
|
|
|
class DataClient extends StatClient |
|
16
|
|
|
{ |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Get table |
|
20
|
|
|
* |
|
21
|
|
|
* @see http://api.yandex.ru/metrika/doc/beta/api_v1/data.xml |
|
22
|
|
|
* |
|
23
|
|
|
* @param Models\TableParams $params |
|
24
|
|
|
* @return Models\Table |
|
25
|
|
|
*/ |
|
26
|
1 |
|
public function getTable(Models\TableParams $params) |
|
27
|
|
|
{ |
|
28
|
1 |
|
$resource = ''; |
|
29
|
|
|
|
|
30
|
1 |
|
$response = $this->sendGetRequest($resource, $params->toArray()); |
|
31
|
1 |
|
$dataResponse = new Models\Table($response); |
|
32
|
1 |
|
return $dataResponse; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Get drill down |
|
37
|
|
|
* |
|
38
|
|
|
* @see http://api.yandex.ru/metrika/doc/beta/api_v1/drilldown.xml |
|
39
|
|
|
* |
|
40
|
|
|
* @param Models\TableParams $params |
|
41
|
|
|
* @param array $parentId |
|
42
|
|
|
* @return Models\DrillDown |
|
43
|
|
|
*/ |
|
44
|
1 |
|
public function getDrillDown(Models\TableParams $params, array $parentId = []) |
|
45
|
|
|
{ |
|
46
|
1 |
|
$resource = 'drilldown'; |
|
47
|
1 |
|
$params = $params->toArray(); |
|
48
|
|
|
|
|
49
|
1 |
|
if (!empty($parentId)) { |
|
50
|
1 |
|
$params['parent_id'] = json_encode($parentId); |
|
51
|
1 |
|
} |
|
52
|
|
|
|
|
53
|
1 |
|
$response = $this->sendGetRequest($resource, $params); |
|
54
|
1 |
|
$dataResponse = new Models\DrillDown($response); |
|
55
|
1 |
|
return $dataResponse; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Get data by time |
|
60
|
|
|
* |
|
61
|
|
|
* @see http://api.yandex.ru/metrika/doc/beta/api_v1/bytime.xml |
|
62
|
|
|
* |
|
63
|
|
|
* @param Models\ByTimeParams $params |
|
64
|
|
|
* @return Models\ByTimeData |
|
65
|
|
|
*/ |
|
66
|
1 |
|
public function getByTime(Models\ByTimeParams $params) |
|
67
|
|
|
{ |
|
68
|
1 |
|
$resource = 'bytime'; |
|
69
|
1 |
|
$response = $this->sendGetRequest($resource, $params->toArray()); |
|
70
|
1 |
|
$dataResponse = new Models\ByTimeData($response); |
|
71
|
1 |
|
return $dataResponse; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Comparison segments |
|
76
|
|
|
* |
|
77
|
|
|
* @see http://api.yandex.ru/metrika/doc/beta/api_v1/requestcompareab.xml |
|
78
|
|
|
* |
|
79
|
|
|
* @param Models\ComparisonParams $params |
|
80
|
|
|
* @return Models\Comparison |
|
81
|
|
|
*/ |
|
82
|
1 |
|
public function getComparisonSegments(Models\ComparisonParams $params) |
|
83
|
|
|
{ |
|
84
|
1 |
|
$resource = 'comparison'; |
|
85
|
1 |
|
$response = $this->sendGetRequest($resource, $params->toArray()); |
|
86
|
1 |
|
$dataResponse = new Models\Comparison($response); |
|
87
|
1 |
|
return $dataResponse; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Comparison drill down |
|
92
|
|
|
* |
|
93
|
|
|
* @see http://api.yandex.ru/metrika/doc/beta/api_v1/comparison_drilldown.xml |
|
94
|
|
|
* |
|
95
|
|
|
* @param Models\DrillDownComparisonParams $params |
|
96
|
|
|
* @return Models\DrillDownComparison |
|
97
|
|
|
*/ |
|
98
|
1 |
|
public function getComparisonDrillDown(Models\DrillDownComparisonParams $params) |
|
99
|
|
|
{ |
|
100
|
1 |
|
$resource = 'comparison/drilldown'; |
|
101
|
1 |
|
$response = $this->sendGetRequest($resource, $params->toArray()); |
|
102
|
1 |
|
$dataResponse = new Models\DrillDownComparison($response); |
|
103
|
1 |
|
return $dataResponse; |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|