| @@ 346-370 (lines=25) @@ | ||
| 343 | } |
|
| 344 | break; |
|
| 345 | ||
| 346 | case 'addGrant': |
|
| 347 | if (isset($_POST['counterId'], $_POST['userLogin'], $_POST['perm'], $_POST['comment'] |
|
| 348 | , $_POST['createdAt']) |
|
| 349 | && $_POST['counterId'] |
|
| 350 | && $_POST['userLogin'] |
|
| 351 | && $_POST['perm'] |
|
| 352 | ) { |
|
| 353 | ||
| 354 | $grantModel = new Yandex\Metrica\Management\Models\Grant(); |
|
| 355 | $grantModel |
|
| 356 | ->setUserLogin($_POST['userLogin']) |
|
| 357 | ->setPerm($_POST['perm']) |
|
| 358 | ->setComment($_POST['comment']) |
|
| 359 | ->setCreatedAt($_POST['createdAt']); |
|
| 360 | ||
| 361 | //POST /management/v1/counter/{counterId}/grants |
|
| 362 | /** |
|
| 363 | * @see http://api.yandex.ru/metrika/doc/beta/management/grants/addgrant.xml |
|
| 364 | */ |
|
| 365 | $result = $managementClient |
|
| 366 | ->grants() |
|
| 367 | ->addGrant($_POST['counterId'], $grantModel) |
|
| 368 | ->toArray(); |
|
| 369 | } |
|
| 370 | break; |
|
| 371 | ||
| 372 | case 'updateGrant': |
|
| 373 | if (isset($_POST['counterId'], $_POST['userLogin'], $_POST['perm'], $_POST['comment'] |
|
| @@ 372-396 (lines=25) @@ | ||
| 369 | } |
|
| 370 | break; |
|
| 371 | ||
| 372 | case 'updateGrant': |
|
| 373 | if (isset($_POST['counterId'], $_POST['userLogin'], $_POST['perm'], $_POST['comment'] |
|
| 374 | , $_POST['createdAt']) |
|
| 375 | && $_POST['counterId'] |
|
| 376 | && $_POST['userLogin'] |
|
| 377 | && $_POST['perm'] |
|
| 378 | ) { |
|
| 379 | ||
| 380 | $grantModel = new Yandex\Metrica\Management\Models\Grant(); |
|
| 381 | $grantModel |
|
| 382 | ->setUserLogin($_POST['userLogin']) |
|
| 383 | ->setPerm($_POST['perm']) |
|
| 384 | ->setComment($_POST['comment']) |
|
| 385 | ->setCreatedAt($_POST['createdAt']); |
|
| 386 | ||
| 387 | //PUT /management/v1/counter/{counterId}/grant/{userLogin} |
|
| 388 | /** |
|
| 389 | * @see http://api.yandex.ru/metrika/doc/beta/management/grants/editgrantold.xml |
|
| 390 | */ |
|
| 391 | $result = $managementClient |
|
| 392 | ->grants() |
|
| 393 | ->updateGrant($_POST['counterId'], $_POST['userLogin'], $grantModel) |
|
| 394 | ->toArray(); |
|
| 395 | } |
|
| 396 | break; |
|
| 397 | ||
| 398 | case 'deleteGrant': |
|
| 399 | if (isset($_POST['counterId'], $_POST['userLogin']) |
|