@@ 13-104 (lines=92) @@ | ||
10 | * @author Alexander Khaylo <[email protected]> |
|
11 | * @created 13.02.14 17:41 |
|
12 | */ |
|
13 | class FiltersClient extends ManagementClient |
|
14 | { |
|
15 | ||
16 | /** |
|
17 | * Get counter filters |
|
18 | * |
|
19 | * @see http://api.yandex.ru/metrika/doc/beta/management/filters/filters.xml |
|
20 | * |
|
21 | * @param int $counterId |
|
22 | * @return array |
|
23 | */ |
|
24 | public function getFilters($counterId) |
|
25 | { |
|
26 | $resource = 'counter/' . $counterId . '/filters'; |
|
27 | $response = $this->sendGetRequest($resource); |
|
28 | $filterResponse = new Models\GetFiltersResponse($response); |
|
29 | return $filterResponse->getFilters(); |
|
30 | } |
|
31 | ||
32 | ||
33 | /** |
|
34 | * Add filter to counter |
|
35 | * |
|
36 | * @see http://api.yandex.ru/metrika/doc/beta/management/filters/addfilter.xml |
|
37 | * |
|
38 | * @param int $counterId |
|
39 | * @param Models\Filter $filter |
|
40 | * @return array |
|
41 | */ |
|
42 | public function addFilter($counterId, Models\Filter $filter) |
|
43 | { |
|
44 | $resource = 'counter/' . $counterId . '/filters'; |
|
45 | $response = $this->sendPostRequest($resource, ["filter" => $filter->toArray()]); |
|
46 | $filterResponse = new Models\AddFilterResponse($response); |
|
47 | return $filterResponse->getFilter(); |
|
48 | } |
|
49 | ||
50 | ||
51 | /** |
|
52 | * Get counter filter |
|
53 | * |
|
54 | * @see http://api.yandex.ru/metrika/doc/beta/management/filters/filter.xml |
|
55 | * |
|
56 | * @param int $id |
|
57 | * @param int $counterId |
|
58 | * @param array $params |
|
59 | * @return array |
|
60 | */ |
|
61 | public function getFilter($id, $counterId, $params = []) |
|
62 | { |
|
63 | $resource = 'counter/' . $counterId . '/filter/' . $id; |
|
64 | $response = $this->sendGetRequest($resource, $params); |
|
65 | $filterResponse = new Models\GetFilterResponse($response); |
|
66 | return $filterResponse->getFilter(); |
|
67 | } |
|
68 | ||
69 | ||
70 | /** |
|
71 | * Update counter filter |
|
72 | * |
|
73 | * @see http://api.yandex.ru/metrika/doc/beta/management/filters/editfilter.xml |
|
74 | * |
|
75 | * @param int $id |
|
76 | * @param int $counterId |
|
77 | * @param Models\Filter $filter |
|
78 | * @return array |
|
79 | */ |
|
80 | public function updateFilter($id, $counterId, Models\Filter $filter) |
|
81 | { |
|
82 | $resource = 'counter/' . $counterId . '/filter/' . $id; |
|
83 | $response = $this->sendPutRequest($resource, ["filter" => $filter->toArray()]); |
|
84 | $filterResponse = new Models\UpdateFilterResponse($response); |
|
85 | return $filterResponse->getFilter(); |
|
86 | } |
|
87 | ||
88 | ||
89 | /** |
|
90 | * Delete counter filter |
|
91 | * |
|
92 | * @see http://api.yandex.ru/metrika/doc/ref/reference/del-counter-filter.xml |
|
93 | * |
|
94 | * @param int $id |
|
95 | * @param int $counterId |
|
96 | * @return array |
|
97 | */ |
|
98 | public function deleteFilter($id, $counterId) |
|
99 | { |
|
100 | $resource = 'counter/' . $counterId . '/filter/' . $id; |
|
101 | $response = $this->sendDeleteRequest($resource); |
|
102 | return $response; |
|
103 | } |
|
104 | } |
|
105 |
@@ 13-103 (lines=91) @@ | ||
10 | * @author Alexander Khaylo <[email protected]> |
|
11 | * @created 13.02.14 17:39 |
|
12 | */ |
|
13 | class GoalsClient extends ManagementClient |
|
14 | { |
|
15 | ||
16 | /** |
|
17 | * Get counter goals |
|
18 | * |
|
19 | * @see http://api.yandex.ru/metrika/doc/beta/management/goals/goals.xml |
|
20 | * |
|
21 | * @param int $counterId |
|
22 | * @return Models\Goals |
|
23 | */ |
|
24 | public function getGoals($counterId) |
|
25 | { |
|
26 | $resource = 'counter/' . $counterId . '/goals'; |
|
27 | $response = $this->sendGetRequest($resource); |
|
28 | $goalResponse = new Models\GetGoalsResponse($response); |
|
29 | return $goalResponse->getGoals(); |
|
30 | } |
|
31 | ||
32 | ||
33 | /** |
|
34 | * Add goal to counter |
|
35 | * |
|
36 | * @see http://api.yandex.ru/metrika/doc/beta/management/goals/addgoal.xml |
|
37 | * |
|
38 | * @param int $counterId |
|
39 | * @param Models\Goal $goal |
|
40 | * @return Models\Goal |
|
41 | */ |
|
42 | public function addGoal($counterId, Models\Goal $goal) |
|
43 | { |
|
44 | $resource = 'counter/' . $counterId . '/goals'; |
|
45 | $response = $this->sendPostRequest($resource, ["goal" => $goal->toArray()]); |
|
46 | $goalResponse = new Models\AddGoalResponse($response); |
|
47 | return $goalResponse->getGoal(); |
|
48 | } |
|
49 | ||
50 | ||
51 | /** |
|
52 | * Get counter goal |
|
53 | * |
|
54 | * @see http://api.yandex.ru/metrika/doc/beta/management/goals/goal.xml |
|
55 | * |
|
56 | * @param int $id |
|
57 | * @param int $counterId |
|
58 | * @return Models\Goal |
|
59 | */ |
|
60 | public function getGoal($id, $counterId) |
|
61 | { |
|
62 | $resource = 'counter/' . $counterId . '/goal/' . $id; |
|
63 | $response = $this->sendGetRequest($resource); |
|
64 | $goalResponse = new Models\GetGoalResponse($response); |
|
65 | return $goalResponse->getGoal(); |
|
66 | } |
|
67 | ||
68 | ||
69 | /** |
|
70 | * Update counter goal |
|
71 | * |
|
72 | * @see http://api.yandex.ru/metrika/doc/beta/management/goals/editgoal.xml |
|
73 | * |
|
74 | * @param int $id |
|
75 | * @param int $counterId |
|
76 | * @param Models\Goal $goal |
|
77 | * @return Models\Goal |
|
78 | */ |
|
79 | public function updateGoal($id, $counterId, Models\Goal $goal) |
|
80 | { |
|
81 | $resource = 'counter/' . $counterId . '/goal/' . $id; |
|
82 | $response = $this->sendPutRequest($resource, ["goal" => $goal->toArray()]); |
|
83 | $goalResponse = new Models\UpdateGoalResponse($response); |
|
84 | return $goalResponse->getGoal(); |
|
85 | } |
|
86 | ||
87 | ||
88 | /** |
|
89 | * Delete counter goal |
|
90 | * |
|
91 | * @see http://api.yandex.ru/metrika/doc/ref/reference/del-counter-goal.xml |
|
92 | * |
|
93 | * @param int $id |
|
94 | * @param int $counterId |
|
95 | * @return array |
|
96 | */ |
|
97 | public function deleteGoal($id, $counterId) |
|
98 | { |
|
99 | $resource = 'counter/' . $counterId . '/goal/' . $id; |
|
100 | $response = $this->sendDeleteRequest($resource); |
|
101 | return $response; |
|
102 | } |
|
103 | } |
|
104 |
@@ 13-105 (lines=93) @@ | ||
10 | * @author Alexander Khaylo <[email protected]> |
|
11 | * @created 13.02.14 17:43 |
|
12 | */ |
|
13 | class GrantsClient extends ManagementClient |
|
14 | { |
|
15 | ||
16 | /** |
|
17 | * Get counter grants |
|
18 | * |
|
19 | * @see http://api.yandex.ru/metrika/doc/beta/management/grants/grants.xml |
|
20 | * |
|
21 | * @param int $counterId |
|
22 | * @param array $params |
|
23 | * @return array |
|
24 | */ |
|
25 | public function getGrants($counterId, $params = []) |
|
26 | { |
|
27 | $resource = 'counter/' . $counterId . '/grants'; |
|
28 | $response = $this->sendGetRequest($resource, $params); |
|
29 | $grantResponse = new Models\GetGrantsResponse($response); |
|
30 | return $grantResponse->getGrants(); |
|
31 | } |
|
32 | ||
33 | ||
34 | /** |
|
35 | * Add grant to counter |
|
36 | * |
|
37 | * @see http://api.yandex.ru/metrika/doc/beta/management/grants/addgrant.xml |
|
38 | * |
|
39 | * @param int $counterId |
|
40 | * @param Models\Grant $grant |
|
41 | * @return Models\Grant |
|
42 | */ |
|
43 | public function addGrant($counterId, Models\Grant $grant) |
|
44 | { |
|
45 | $resource = 'counter/' . $counterId . '/grants'; |
|
46 | $response = $this->sendPostRequest($resource, ["grant" => $grant->toArray()]); |
|
47 | $grantResponse = new Models\AddGrantResponse($response); |
|
48 | return $grantResponse->getGrant(); |
|
49 | } |
|
50 | ||
51 | ||
52 | /** |
|
53 | * Get counter grant |
|
54 | * |
|
55 | * @see http://api.yandex.ru/metrika/doc/beta/management/grants/grantold.xml |
|
56 | * |
|
57 | * @param int $counterId |
|
58 | * @param string $userLogin |
|
59 | * @param array $params |
|
60 | * @return Models\Grant |
|
61 | */ |
|
62 | public function getGrant($counterId, $userLogin, $params = []) |
|
63 | { |
|
64 | $resource = 'counter/' . $counterId . '/grant/' . $userLogin; |
|
65 | $response = $this->sendGetRequest($resource, $params); |
|
66 | $grantResponse = new Models\GetGrantResponse($response); |
|
67 | return $grantResponse->getGrant(); |
|
68 | } |
|
69 | ||
70 | ||
71 | /** |
|
72 | * Update counter grant |
|
73 | * |
|
74 | * @see http://api.yandex.ru/metrika/doc/beta/management/grants/editgrantold.xml |
|
75 | * |
|
76 | * @param int $counterId |
|
77 | * @param string $userLogin |
|
78 | * @param Models\Grant $grant |
|
79 | * @return Models\Grant |
|
80 | */ |
|
81 | public function updateGrant($counterId, $userLogin, Models\Grant $grant) |
|
82 | { |
|
83 | $resource = 'counter/' . $counterId . '/grant/' . $userLogin; |
|
84 | $response = $this->sendPutRequest($resource, ["grant" => $grant->toArray()]); |
|
85 | $grantResponse = new Models\UpdateGrantResponse($response); |
|
86 | return $grantResponse->getGrant(); |
|
87 | } |
|
88 | ||
89 | ||
90 | /** |
|
91 | * Delete counter grant |
|
92 | * |
|
93 | * @see http://api.yandex.ru/metrika/doc/ref/reference/del-counter-grant.xml |
|
94 | * |
|
95 | * @param int $counterId |
|
96 | * @param string $userLogin |
|
97 | * @return array |
|
98 | */ |
|
99 | public function deleteGrant($counterId, $userLogin) |
|
100 | { |
|
101 | $resource = 'counter/' . $counterId . '/grant/' . $userLogin; |
|
102 | $response = $this->sendDeleteRequest($resource); |
|
103 | return $response; |
|
104 | } |
|
105 | } |
|
106 |
@@ 13-105 (lines=93) @@ | ||
10 | * @author Alexander Khaylo <[email protected]> |
|
11 | * @created 13.02.14 17:42 |
|
12 | */ |
|
13 | class OperationsClient extends ManagementClient |
|
14 | { |
|
15 | ||
16 | /** |
|
17 | * Get counter operations |
|
18 | * |
|
19 | * @see http://api.yandex.ru/metrika/doc/beta/management/operations/operations.xml |
|
20 | * |
|
21 | * @param int $counterId |
|
22 | * @param array $params |
|
23 | * @return array |
|
24 | */ |
|
25 | public function getOperations($counterId, $params = []) |
|
26 | { |
|
27 | $resource = 'counter/' . $counterId . '/operations'; |
|
28 | $response = $this->sendGetRequest($resource, $params); |
|
29 | $operationResponse = new Models\GetOperationsResponse($response); |
|
30 | return $operationResponse->getOperations(); |
|
31 | } |
|
32 | ||
33 | ||
34 | /** |
|
35 | * Add operation to counter |
|
36 | * |
|
37 | * @see http://api.yandex.ru/metrika/doc/beta/management/operations/addoperation.xml |
|
38 | * |
|
39 | * @param int $counterId |
|
40 | * @param Models\Operation $operation |
|
41 | * @return Models\Operation |
|
42 | */ |
|
43 | public function addOperation($counterId, Models\Operation $operation) |
|
44 | { |
|
45 | $resource = 'counter/' . $counterId . '/operations'; |
|
46 | $response = $this->sendPostRequest($resource, ["operation" => $operation->toArray()]); |
|
47 | $operationResponse = new Models\AddOperationResponse($response); |
|
48 | return $operationResponse->getOperation(); |
|
49 | } |
|
50 | ||
51 | ||
52 | /** |
|
53 | * Get counter operation |
|
54 | * |
|
55 | * @see http://api.yandex.ru/metrika/doc/beta/management/operations/operation.xml |
|
56 | * |
|
57 | * @param int $id |
|
58 | * @param int $counterId |
|
59 | * @param array $params |
|
60 | * @return Models\Operation |
|
61 | */ |
|
62 | public function getOperation($id, $counterId, $params = []) |
|
63 | { |
|
64 | $resource = 'counter/' . $counterId . '/operation/' . $id; |
|
65 | $response = $this->sendGetRequest($resource, $params); |
|
66 | $operationResponse = new Models\GetOperationResponse($response); |
|
67 | return $operationResponse->getOperation(); |
|
68 | } |
|
69 | ||
70 | ||
71 | /** |
|
72 | * Update counter operation |
|
73 | * |
|
74 | * @see http://api.yandex.ru/metrika/doc/beta/management/operations/editoperation.xml |
|
75 | * |
|
76 | * @param int $id |
|
77 | * @param int $counterId |
|
78 | * @param Models\Operation $operation |
|
79 | * @return Models\Operation |
|
80 | */ |
|
81 | public function updateOperation($id, $counterId, Models\Operation $operation) |
|
82 | { |
|
83 | $resource = 'counter/' . $counterId . '/operation/' . $id; |
|
84 | $response = $this->sendPutRequest($resource, ["operation" => $operation->toArray()]); |
|
85 | $operationsResponse = new Models\UpdateOperationResponse($response); |
|
86 | return $operationsResponse->getOperation(); |
|
87 | } |
|
88 | ||
89 | ||
90 | /** |
|
91 | * Delete counter operation |
|
92 | * |
|
93 | * @see http://api.yandex.ru/metrika/doc/ref/reference/del-counter-operation.xml |
|
94 | * |
|
95 | * @param int $id |
|
96 | * @param int $counterId |
|
97 | * @return array |
|
98 | */ |
|
99 | public function deleteCounterOperation($id, $counterId) |
|
100 | { |
|
101 | $resource = 'counter/' . $counterId . '/operation/' . $id; |
|
102 | $response = $this->sendDeleteRequest($resource); |
|
103 | return $response; |
|
104 | } |
|
105 | } |
|
106 |