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