Skip to content

Commit

Permalink
Merge pull request #24 from openeyes/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
vetusko authored Jan 25, 2022
2 parents dfff3d5 + 63fce42 commit ea38197
Show file tree
Hide file tree
Showing 18 changed files with 759 additions and 592 deletions.
46 changes: 46 additions & 0 deletions CSDClientModule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* OpenEyes.
*
* (C) Moorfields Eye Hospital NHS Foundation Trust, 2008-2011
* (C) OpenEyes Foundation, 2011-2013
* This file is part of OpenEyes.
* OpenEyes is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* OpenEyes is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License along with OpenEyes in a file titled COPYING. If not, see <http://www.gnu.org/licenses/>.
*
* @link http://www.openeyes.org.uk
*
* @author OpenEyes <info@openeyes.org.uk>
* @copyright Copyright (c) 2011-2013, OpenEyes Foundation
* @license http://www.gnu.org/licenses/agpl-3.0.html The GNU Affero General Public License V3.0
*/

namespace OEModule\mehstaffdb;

class CSDClientModule extends \BaseModule
{
public function init()
{
// this method is called when the module is being created
// you may place code here to customize the module or the application

// import the module-level models and components
$this->setImport(array(
'mehstaffdb.components.*',
'mehstaffdb.controllers.*',
));
parent::init();
}

public function beforeControllerAction($controller, $action)
{
if (parent::beforeControllerAction($controller, $action)) {
// this method is called before any module controller action is performed
// you may place customized code here
return true;
} else {
return false;
}
}
}
Empty file added commands/.gitkeep
Empty file.
67 changes: 0 additions & 67 deletions commands/UserCheckerCommand.php

This file was deleted.

72 changes: 0 additions & 72 deletions commands/UserFixerCommand.php

This file was deleted.

73 changes: 0 additions & 73 deletions commands/UserUpdateCommand.php

This file was deleted.

61 changes: 61 additions & 0 deletions components/CSDClient/CSDClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
* OpenEyes
*
* (C) OpenEyes Foundation, 2021
* This file is part of OpenEyes.
* OpenEyes is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* OpenEyes is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License along with OpenEyes in a file titled COPYING. If not, see <http://www.gnu.org/licenses/>.
*
* @package OpenEyes
* @link http://www.openeyes.org.uk
* @author OpenEyes <info@openeyes.org.uk>
* @copyright Copyright (c) 2021, OpenEyes Foundation
* @license http://www.gnu.org/licenses/agpl-3.0.html The GNU Affero General Public License V3.0
*/

namespace OEModule\mehstaffdb\components\CSDClient;

use OEModule\mehstaffdb\components\CSDClient\GetUserDataRequest;
use OEModule\mehstaffdb\components\Singleton;

/**
* Class CSDClient
*
* This is a facade for all CSD API calls. Other classes should only
* call methods of this class.
*
* @method static CSDClient get()
*/

class CSDClient extends Singleton
{

/**
* Sends request
*
* @param Request $request
* @return string|null JSON-encoded data on success or null on failure
*/
private function sendRequest(Request $request): ?string
{
$response = $request->submit();
if(!$response["success"]) {
return null;
}

return $response["success"] > 0 && isset($response["result"]) ? json_encode($response["result"]) : null;
}

/**
* Retrieves patient data from CSD
*
* @param string $username
* @return string|null JSON-encoded data on success or null on failure
*/
public function getUserData(string $username): ?string
{
return $this->sendRequest((new GetUserDataRequest($this))->setUsername($username));
}
}
44 changes: 44 additions & 0 deletions components/CSDClient/GetUserDataRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* OpenEyes
*
* (C) OpenEyes Foundation, 2021
* This file is part of OpenEyes.
* OpenEyes is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* OpenEyes is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License along with OpenEyes in a file titled COPYING. If not, see <http://www.gnu.org/licenses/>.
*
* @package OpenEyes
* @link http://www.openeyes.org.uk
* @author OpenEyes <info@openeyes.org.uk>
* @copyright Copyright (c) 2021, OpenEyes Foundation
* @license http://www.gnu.org/licenses/agpl-3.0.html The GNU Affero General Public License V3.0
*/

namespace OEModule\mehstaffdb\components\CSDClient;

use OEModule\mehstaffdb\components\CSDClient\Request;

class GetUserDataRequest extends Request
{
/** @var string */
protected $username;

/**
* @param string $username
* @return GetUserDataRequest
*/
public function setUsername(string $username): GetUserDataRequest
{
$this->username = $username;
return $this;
}

/**
* @inheritDoc
*/
public function getActionName(): string
{
return "CSDAPI/api/staff?DomainUsername=".$this->username;
}
}
Loading

0 comments on commit ea38197

Please sign in to comment.