From e83a94b38a005a909037eeb6ba11fc233313aa7e Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 13 Mar 2017 18:08:32 +0200 Subject: [PATCH] docs + ap --- app/library/App/Collections/ExportCollection.php | 7 +------ app/library/App/Controllers/AllPositionController.php | 23 +++++++++++++++++++++++ app/library/App/Resources/AllPositionResource.php | 44 +++++++++++++++++++++++++++++++++++--------- 3 files changed, 59 insertions(+), 15 deletions(-) diff --git a/app/library/App/Collections/ExportCollection.php b/app/library/App/Collections/ExportCollection.php index 40f05db..fe9af85 100755 --- a/app/library/App/Collections/ExportCollection.php +++ b/app/library/App/Collections/ExportCollection.php @@ -10,16 +10,11 @@ class ExportCollection extends ApiCollection { protected function initialize() { -// $this -// ->name('Export') -// ->handler(ExportController::class) -// -// ->endpoint(ApiEndpoint::get('/documentation.json', 'documentation')) -// ->endpoint(ApiEndpoint::get('/postman.json', 'postman')); $this->name('Export'); $this->handler(ExportController::class); $this->endpoint(ApiEndpoint::get('/documentation.json', 'documentation')); $this->endpoint(ApiEndpoint::get('/postman.json', 'postman')); + } } diff --git a/app/library/App/Controllers/AllPositionController.php b/app/library/App/Controllers/AllPositionController.php index 7dae47f..cb77ea4 100644 --- a/app/library/App/Controllers/AllPositionController.php +++ b/app/library/App/Controllers/AllPositionController.php @@ -41,6 +41,16 @@ class AllPositionController extends CrudResourceController } + public function projectsGroupAction() { + + $APObj = new Client(self::API_KEY); + + $projects_group = $APObj->getProjectsGroup(); + + return $projects_group; + + } + public function queriesAction() { /** user params **/ @@ -54,6 +64,19 @@ class AllPositionController extends CrudResourceController } + public function queriesGroupAction() { + + /** user params **/ + $project = $this->request->get('project') ?? 418068; + + $APObj = new Client(self::API_KEY); + + $queries_group = $APObj->getQueriesGroup($project); + + return $queries_group; + + } + public function reportAction() { /** user params **/ diff --git a/app/library/App/Resources/AllPositionResource.php b/app/library/App/Resources/AllPositionResource.php index 25f6a06..5759a26 100644 --- a/app/library/App/Resources/AllPositionResource.php +++ b/app/library/App/Resources/AllPositionResource.php @@ -11,6 +11,8 @@ namespace App\Resources; use App\Constants\AclRoles; use App\Controllers\AllPositionController; +use Phalcon\Acl; +use PhalconApi\Constants\HttpMethods; use PhalconRest\Api\ApiEndpoint; use PhalconRest\Api\ApiResource; @@ -28,29 +30,53 @@ class AllPositionResource extends ApiResource ->deny(AclRoles::UNAUTHORIZED) ->handler(AllPositionController::class) - ->endpoint(ApiEndpoint::get('/project', 'projectAction') - ->allow(AclRoles::USER) + ->endpoint( + ApiEndpoint::factory('/project', HttpMethods::GET, 'projectAction') + ->name('project') ->description('Данные о проекте') + ->allow(AclRoles::USER) ) - ->endpoint(ApiEndpoint::get('/projects', 'projectsAction') - ->allow(AclRoles::USER) + ->endpoint( + ApiEndpoint::factory('/projects', HttpMethods::GET, 'projectsAction') + ->name('projects') ->description('Список проектов пользователя') + ->allow(AclRoles::UNAUTHORIZED) ) - ->endpoint(ApiEndpoint::get('/queries', 'queriesAction') + ->endpoint( + ApiEndpoint::factory('/projects_group', HttpMethods::GET, 'projectsGroupAction') + ->name('projects group') + ->description('Список групп проектов') ->allow(AclRoles::USER) - ->description('Список запросов, по которым определяется позиция сайта') ) - ->endpoint(ApiEndpoint::get('/report', 'reportAction') + ->endpoint( + ApiEndpoint::factory('/queries', HttpMethods::GET, 'queriesAction') + ->name('queries') + ->description('Список запросов, по которым определяется позиция сайта') ->allow(AclRoles::USER) - ->description('Отчет по позициям сайта') ) - ->endpoint(ApiEndpoint::get('/visibility', 'visibilityAction') + ->endpoint( + ApiEndpoint::factory('/queries_group', HttpMethods::GET, 'queriesGroupAction') + ->name('queries group') + ->description('Список групп запросов') + ->allow(AclRoles::USER) + ) + + ->endpoint( + ApiEndpoint::factory('/report', HttpMethods::GET, 'reportAction') + ->name('report') + ->description('Отчет по позициям сайта') ->allow(AclRoles::USER) + ) + + ->endpoint( + ApiEndpoint::factory('/visibility', HttpMethods::GET, 'visibilityAction') + ->name('visibility') ->description('Данные о видимости сайта за указанный период') + ->allow(AclRoles::USER) ) ; -- libgit2 0.21.4