From 37701e29430194438bd1188b219f4538fb2f75be Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 1 Mar 2017 20:59:12 +0200 Subject: [PATCH] ap testing --- app/library/App/Controllers/AllPositionController.php | 54 ++++++++++++++++++++++++++++++++++++++++++------------ app/library/App/Resources/AllPositionResource.php | 19 +++++++++++++++++-- 2 files changed, 59 insertions(+), 14 deletions(-) diff --git a/app/library/App/Controllers/AllPositionController.php b/app/library/App/Controllers/AllPositionController.php index 93dfd3c..ad5da7d 100644 --- a/app/library/App/Controllers/AllPositionController.php +++ b/app/library/App/Controllers/AllPositionController.php @@ -18,24 +18,54 @@ class AllPositionController extends CrudResourceController { const API_KEY = '150bb253651622507341cd7845f5b9d2'; - public function testAction() { + public function projectAction() { - try - { - $APObj = new Client('150bb253651622507341cd7845f5b9d2'); + /** user params **/ + $project = $this->request->get('project') ?? 418068; - $project_info = $APObj->getProject(418068); - } - catch (Exception $e) - { + $APObj = new Client(self::API_KEY); - return $e->getMessage(); + $project_info = $APObj->getProject($project); - } + return $project_info; + } - return var_dump($project_info); - return $project_info; + public function projectsAction() { + + $APObj = new Client(self::API_KEY); + + $projects_info = $APObj->getProjects(); + + return $projects_info; + + } + + public function queriesAction() { + + /** user params **/ + $project = $this->request->get('project') ?? 418068; + + $APObj = new Client(self::API_KEY); + + $projects_info = $APObj->getQueries($project); + + return $projects_info; + + } + + public function visibilityAction() { + + /** user params **/ + $project = $this->request->get('project') ?? 418068; + $get_start_date = $this->request->get('start') ?? '30daysAgo'; + $get_end_date = $this->request->get('end') ?? 'today'; + + $APObj = new Client(self::API_KEY); + + $projects_info = $APObj->getVisibility($project, $get_start_date, $get_end_date); + + return $projects_info; } diff --git a/app/library/App/Resources/AllPositionResource.php b/app/library/App/Resources/AllPositionResource.php index 76cb3a7..2495358 100644 --- a/app/library/App/Resources/AllPositionResource.php +++ b/app/library/App/Resources/AllPositionResource.php @@ -28,9 +28,24 @@ class AllPositionResource extends ApiResource ->deny(AclRoles::UNAUTHORIZED) ->handler(AllPositionController::class) - ->endpoint(ApiEndpoint::get('', 'testAction') + ->endpoint(ApiEndpoint::get('/project', 'projectAction') ->allow(AclRoles::USER) - ->description('Returns data from AllPosition Api.') + ->description('Данные о проекте') + ) + + ->endpoint(ApiEndpoint::get('/projects', 'projectsAction') + ->allow(AclRoles::USER) + ->description('Список проектов пользователя') + ) + + ->endpoint(ApiEndpoint::get('/queries', 'queriesAction') + ->allow(AclRoles::USER) + ->description('Список запросов, по которым определяется позиция сайта') + ) + + ->endpoint(ApiEndpoint::get('/visibility', 'visibilityAction') + ->allow(AclRoles::USER) + ->description('Данные о видимости сайта за указанный период') ) ; -- libgit2 0.21.4