3 * ProductRegistrationController
5 * LICENSE: This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
17 * @author Matthew Vita <matthewvita48@gmail.com>
18 * @link http://www.open-emr.org
24 require_once("../globals.php");
25 require_once($GLOBALS['fileroot'] . "/interface/main/exceptions/invalid_email_exception.php");
26 require_once($GLOBALS['fileroot'] . "/interface/product_registration/exceptions/generic_product_registration_exception.php");
27 require_once($GLOBALS['fileroot'] . "/interface/product_registration/exceptions/duplicate_registration_exception.php");
29 class ProductRegistrationController
31 private $productRegistrationService;
33 public function __construct()
35 $this->productRegistrationService
= new \services\
ProductRegistrationService();
37 // (note this is here until we use Zend Framework)
38 switch ($_SERVER['REQUEST_METHOD']) {
50 $statusPayload = $this->productRegistrationService
->getProductStatus();
52 \common\http\HttpResponseHelper
::send(200, $statusPayload, 'JSON');
55 public function post()
61 $response = new \entities\
ProductRegistration();
62 $registrationId = $this->productRegistrationService
->registerProduct($_POST['email']);
63 $response->setRegistrationId($registrationId);
64 $response->setEmail($_POST['email']);
66 } catch (InvalidEmailException
$emailException) {
67 $response = $emailException->errorMessage();
68 } catch (DuplicateRegistrationException
$duplicateRegistrationException) {
69 $response = $duplicateRegistrationException->errorMessage();
70 } catch (GenericProductRegistrationException
$genericProductRegistrationException) {
71 $response = $genericProductRegistrationException->errorMessage();
74 \common\http\HttpResponseHelper
::send($status, $response, 'JSON');
78 // Initialize self (note this is here until we use Zend Framework)
79 $productRegistrationController = new ProductRegistrationController();