Commit 37701e29430194438bd1188b219f4538fb2f75be

Authored by Alex Savenko
1 parent 903ac393

ap testing

app/library/App/Controllers/AllPositionController.php
@@ -18,24 +18,54 @@ class AllPositionController extends CrudResourceController @@ -18,24 +18,54 @@ class AllPositionController extends CrudResourceController
18 { 18 {
19 const API_KEY = '150bb253651622507341cd7845f5b9d2'; 19 const API_KEY = '150bb253651622507341cd7845f5b9d2';
20 20
21 - public function testAction() { 21 + public function projectAction() {
22 22
23 - try  
24 - {  
25 - $APObj = new Client('150bb253651622507341cd7845f5b9d2'); 23 + /** user params **/
  24 + $project = $this->request->get('project') ?? 418068;
26 25
27 - $project_info = $APObj->getProject(418068);  
28 - }  
29 - catch (Exception $e)  
30 - { 26 + $APObj = new Client(self::API_KEY);
31 27
32 - return $e->getMessage(); 28 + $project_info = $APObj->getProject($project);
33 29
34 - } 30 + return $project_info;
35 31
  32 + }
36 33
37 - return var_dump($project_info);  
38 - return $project_info; 34 + public function projectsAction() {
  35 +
  36 + $APObj = new Client(self::API_KEY);
  37 +
  38 + $projects_info = $APObj->getProjects();
  39 +
  40 + return $projects_info;
  41 +
  42 + }
  43 +
  44 + public function queriesAction() {
  45 +
  46 + /** user params **/
  47 + $project = $this->request->get('project') ?? 418068;
  48 +
  49 + $APObj = new Client(self::API_KEY);
  50 +
  51 + $projects_info = $APObj->getQueries($project);
  52 +
  53 + return $projects_info;
  54 +
  55 + }
  56 +
  57 + public function visibilityAction() {
  58 +
  59 + /** user params **/
  60 + $project = $this->request->get('project') ?? 418068;
  61 + $get_start_date = $this->request->get('start') ?? '30daysAgo';
  62 + $get_end_date = $this->request->get('end') ?? 'today';
  63 +
  64 + $APObj = new Client(self::API_KEY);
  65 +
  66 + $projects_info = $APObj->getVisibility($project, $get_start_date, $get_end_date);
  67 +
  68 + return $projects_info;
39 69
40 } 70 }
41 71
app/library/App/Resources/AllPositionResource.php
@@ -28,9 +28,24 @@ class AllPositionResource extends ApiResource @@ -28,9 +28,24 @@ class AllPositionResource extends ApiResource
28 ->deny(AclRoles::UNAUTHORIZED) 28 ->deny(AclRoles::UNAUTHORIZED)
29 ->handler(AllPositionController::class) 29 ->handler(AllPositionController::class)
30 30
31 - ->endpoint(ApiEndpoint::get('', 'testAction') 31 + ->endpoint(ApiEndpoint::get('/project', 'projectAction')
32 ->allow(AclRoles::USER) 32 ->allow(AclRoles::USER)
33 - ->description('Returns data from AllPosition Api.') 33 + ->description('Данные о проекте')
  34 + )
  35 +
  36 + ->endpoint(ApiEndpoint::get('/projects', 'projectsAction')
  37 + ->allow(AclRoles::USER)
  38 + ->description('Список проектов пользователя')
  39 + )
  40 +
  41 + ->endpoint(ApiEndpoint::get('/queries', 'queriesAction')
  42 + ->allow(AclRoles::USER)
  43 + ->description('Список запросов, по которым определяется позиция сайта')
  44 + )
  45 +
  46 + ->endpoint(ApiEndpoint::get('/visibility', 'visibilityAction')
  47 + ->allow(AclRoles::USER)
  48 + ->description('Данные о видимости сайта за указанный период')
34 ) 49 )
35 ; 50 ;
36 51