{"action":"created","comment":{"url":"https://api.github.com/repos/openemr/openemr/pulls/comments/80185189","id":80185189,"diff_hunk":"@@ -0,0 +1,79 @@\n+<?php\n+/**\n+ * ProductRegistrationController\n+ *\n+ * LICENSE: This program is free software; you can redistribute it and/or\n+ * modify it under the terms of the GNU General Public License\n+ * as published by the Free Software Foundation; either version 2\n+ * of the License, or (at your option) any later version.\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n+ * GNU General Public License for more details.\n+ * You should have received a copy of the GNU General Public License\n+ * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.\n+ *\n+ * @package OpenEMR\n+ * @author  Matthew Vita <matthewvita48@gmail.com>\n+ * @link    http://www.open-emr.org\n+ */\n+\n+$fake_register_globals=false;\n+$sanitize_all_escapes=true;\n+$ignoreAuth=true;\n+require_once(\"../globals.php\");\n+require_once($GLOBALS['fileroot'] . \"/library/sql.inc\");\n+require_once($GLOBALS['fileroot'] . \"/interface/main/exceptions/invalid_email_exception.php\");\n+require_once($GLOBALS['fileroot'] . \"/interface/main/utils/http_response_helper.php\");\n+require_once($GLOBALS['fileroot'] . \"/interface/product_registration/product_registration_service.php\");\n+require_once($GLOBALS['fileroot'] . \"/interface/product_registration/remote_product_registration_exception.php\");\n+\n+class ProductRegistrationController {\n+    private $productRegistrationService;\n+\n+    public function __construct($productRegistrationServiceInstance) {\n+        $this->productRegistrationService = $productRegistrationServiceInstance;\n+\n+        switch ($_SERVER['REQUEST_METHOD']) {\n+            case 'POST':\n+                $this->post();\n+                break;\n+            case 'GET':\n+                $this->get();\n+                break;\n+        }\n+    }\n+\n+    public function get() {\n+        $statusPayload = $this->productRegistrationService->getProductStatus();\n+\n+        HttpResponseHelper::send(200, $statusPayload, 'JSON');\n+    }\n+\n+    public function post() {\n+        $registrationPayload = new stdClass();\n+        $status = null;\n+\n+        try {\n+            $registrationId = $this->productRegistrationService->registerProduct($_POST['email']);\n+            $registrationPayload->registration_id = $registrationId;\n+            $registrationPayload->email = $_POST['email'];\n+            $status = 201;\n+        } catch (InvalidEmailException $emailException) {\n+            $registrationPayload->error = $emailException->errorMessage();\n+            $status = 400;\n+        } catch (RemoteProductRegistrationException $remoteRegistrationException) {\n+            $registrationPayload->error = $remoteRegistrationException->errorMessage();\n+            $status = 500;\n+        }\n+\n+        HttpResponseHelper::send($status, $registrationPayload, 'JSON');\n+    }\n+}\n+\n+// Dependencies for injection into controller (TODO: a php notice is thrown b/c the sql\n+// functions aren't being picked up despite including sql.inc...)","path":"interface/product_registration/product_registration_controller.php","position":75,"original_position":75,"commit_id":"810220de3d6ad3ba148f98558c075abb4af036a6","original_commit_id":"810220de3d6ad3ba148f98558c075abb4af036a6","user":{"login":"bradymiller","id":278968,"avatar_url":"https://avatars.githubusercontent.com/u/278968?v=3","gravatar_id":"","url":"https://api.github.com/users/bradymiller","html_url":"https://github.com/bradymiller","followers_url":"https://api.github.com/users/bradymiller/followers","following_url":"https://api.github.com/users/bradymiller/following{/other_user}","gists_url":"https://api.github.com/users/bradymiller/gists{/gist_id}","starred_url":"https://api.github.com/users/bradymiller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradymiller/subscriptions","organizations_url":"https://api.github.com/users/bradymiller/orgs","repos_url":"https://api.github.com/users/bradymiller/repos","events_url":"https://api.github.com/users/bradymiller/events{/privacy}","received_events_url":"https://api.github.com/users/bradymiller/received_events","type":"User","site_admin":false},"body":"This seems really odd to need to require injecting outside functions into a class. Is this normal?","created_at":"2016-09-23T05:51:27Z","updated_at":"2016-09-23T05:51:27Z","html_url":"https://github.com/openemr/openemr/pull/257#discussion_r80185189","pull_request_url":"https://api.github.com/repos/openemr/openemr/pulls/257","_links":{"self":{"href":"https://api.github.com/repos/openemr/openemr/pulls/comments/80185189"},"html":{"href":"https://github.com/openemr/openemr/pull/257#discussion_r80185189"},"pull_request":{"href":"https://api.github.com/repos/openemr/openemr/pulls/257"}}},"pull_request":{"url":"https://api.github.com/repos/openemr/openemr/pulls/257","id":85694363,"html_url":"https://github.com/openemr/openemr/pull/257","diff_url":"https://github.com/openemr/openemr/pull/257.diff","patch_url":"https://github.com/openemr/openemr/pull/257.patch","issue_url":"https://api.github.com/repos/openemr/openemr/issues/257","number":257,"state":"open","locked":false,"title":"[WIP] Product Registration","user":{"login":"MatthewVita","id":1715206,"avatar_url":"https://avatars.githubusercontent.com/u/1715206?v=3","gravatar_id":"","url":"https://api.github.com/users/MatthewVita","html_url":"https://github.com/MatthewVita","followers_url":"https://api.github.com/users/MatthewVita/followers","following_url":"https://api.github.com/users/MatthewVita/following{/other_user}","gists_url":"https://api.github.com/users/MatthewVita/gists{/gist_id}","starred_url":"https://api.github.com/users/MatthewVita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MatthewVita/subscriptions","organizations_url":"https://api.github.com/users/MatthewVita/orgs","repos_url":"https://api.github.com/users/MatthewVita/repos","events_url":"https://api.github.com/users/MatthewVita/events{/privacy}","received_events_url":"https://api.github.com/users/MatthewVita/received_events","type":"User","site_admin":false},"body":"Just a WIP for now:\r\n\r\n![gh](https://cloud.githubusercontent.com/assets/1715206/18612434/c4c72c42-7d27-11e6-9669-f34fcc9ad774.gif)\r\n","created_at":"2016-09-18T02:40:57Z","updated_at":"2016-09-23T05:51:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5b7fc95585e0ba48b7a0712cf0ea83ceb754fa6d","assignee":{"login":"robertdown","id":1381170,"avatar_url":"https://avatars.githubusercontent.com/u/1381170?v=3","gravatar_id":"","url":"https://api.github.com/users/robertdown","html_url":"https://github.com/robertdown","followers_url":"https://api.github.com/users/robertdown/followers","following_url":"https://api.github.com/users/robertdown/following{/other_user}","gists_url":"https://api.github.com/users/robertdown/gists{/gist_id}","starred_url":"https://api.github.com/users/robertdown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertdown/subscriptions","organizations_url":"https://api.github.com/users/robertdown/orgs","repos_url":"https://api.github.com/users/robertdown/repos","events_url":"https://api.github.com/users/robertdown/events{/privacy}","received_events_url":"https://api.github.com/users/robertdown/received_events","type":"User","site_admin":false},"assignees":[{"login":"robertdown","id":1381170,"avatar_url":"https://avatars.githubusercontent.com/u/1381170?v=3","gravatar_id":"","url":"https://api.github.com/users/robertdown","html_url":"https://github.com/robertdown","followers_url":"https://api.github.com/users/robertdown/followers","following_url":"https://api.github.com/users/robertdown/following{/other_user}","gists_url":"https://api.github.com/users/robertdown/gists{/gist_id}","starred_url":"https://api.github.com/users/robertdown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertdown/subscriptions","organizations_url":"https://api.github.com/users/robertdown/orgs","repos_url":"https://api.github.com/users/robertdown/repos","events_url":"https://api.github.com/users/robertdown/events{/privacy}","received_events_url":"https://api.github.com/users/robertdown/received_events","type":"User","site_admin":false},{"login":"MatthewVita","id":1715206,"avatar_url":"https://avatars.githubusercontent.com/u/1715206?v=3","gravatar_id":"","url":"https://api.github.com/users/MatthewVita","html_url":"https://github.com/MatthewVita","followers_url":"https://api.github.com/users/MatthewVita/followers","following_url":"https://api.github.com/users/MatthewVita/following{/other_user}","gists_url":"https://api.github.com/users/MatthewVita/gists{/gist_id}","starred_url":"https://api.github.com/users/MatthewVita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MatthewVita/subscriptions","organizations_url":"https://api.github.com/users/MatthewVita/orgs","repos_url":"https://api.github.com/users/MatthewVita/repos","events_url":"https://api.github.com/users/MatthewVita/events{/privacy}","received_events_url":"https://api.github.com/users/MatthewVita/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/openemr/openemr/pulls/257/commits","review_comments_url":"https://api.github.com/repos/openemr/openemr/pulls/257/comments","review_comment_url":"https://api.github.com/repos/openemr/openemr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openemr/openemr/issues/257/comments","statuses_url":"https://api.github.com/repos/openemr/openemr/statuses/810220de3d6ad3ba148f98558c075abb4af036a6","head":{"label":"MatthewVita:product_registration","ref":"product_registration","sha":"810220de3d6ad3ba148f98558c075abb4af036a6","user":{"login":"MatthewVita","id":1715206,"avatar_url":"https://avatars.githubusercontent.com/u/1715206?v=3","gravatar_id":"","url":"https://api.github.com/users/MatthewVita","html_url":"https://github.com/MatthewVita","followers_url":"https://api.github.com/users/MatthewVita/followers","following_url":"https://api.github.com/users/MatthewVita/following{/other_user}","gists_url":"https://api.github.com/users/MatthewVita/gists{/gist_id}","starred_url":"https://api.github.com/users/MatthewVita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MatthewVita/subscriptions","organizations_url":"https://api.github.com/users/MatthewVita/orgs","repos_url":"https://api.github.com/users/MatthewVita/repos","events_url":"https://api.github.com/users/MatthewVita/events{/privacy}","received_events_url":"https://api.github.com/users/MatthewVita/received_events","type":"User","site_admin":false},"repo":{"id":68490806,"name":"openemr","full_name":"MatthewVita/openemr","owner":{"login":"MatthewVita","id":1715206,"avatar_url":"https://avatars.githubusercontent.com/u/1715206?v=3","gravatar_id":"","url":"https://api.github.com/users/MatthewVita","html_url":"https://github.com/MatthewVita","followers_url":"https://api.github.com/users/MatthewVita/followers","following_url":"https://api.github.com/users/MatthewVita/following{/other_user}","gists_url":"https://api.github.com/users/MatthewVita/gists{/gist_id}","starred_url":"https://api.github.com/users/MatthewVita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MatthewVita/subscriptions","organizations_url":"https://api.github.com/users/MatthewVita/orgs","repos_url":"https://api.github.com/users/MatthewVita/repos","events_url":"https://api.github.com/users/MatthewVita/events{/privacy}","received_events_url":"https://api.github.com/users/MatthewVita/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MatthewVita/openemr","description":"Mirror of official OpenEMR Sourceforge repository","fork":true,"url":"https://api.github.com/repos/MatthewVita/openemr","forks_url":"https://api.github.com/repos/MatthewVita/openemr/forks","keys_url":"https://api.github.com/repos/MatthewVita/openemr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MatthewVita/openemr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MatthewVita/openemr/teams","hooks_url":"https://api.github.com/repos/MatthewVita/openemr/hooks","issue_events_url":"https://api.github.com/repos/MatthewVita/openemr/issues/events{/number}","events_url":"https://api.github.com/repos/MatthewVita/openemr/events","assignees_url":"https://api.github.com/repos/MatthewVita/openemr/assignees{/user}","branches_url":"https://api.github.com/repos/MatthewVita/openemr/branches{/branch}","tags_url":"https://api.github.com/repos/MatthewVita/openemr/tags","blobs_url":"https://api.github.com/repos/MatthewVita/openemr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MatthewVita/openemr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MatthewVita/openemr/git/refs{/sha}","trees_url":"https://api.github.com/repos/MatthewVita/openemr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MatthewVita/openemr/statuses/{sha}","languages_url":"https://api.github.com/repos/MatthewVita/openemr/languages","stargazers_url":"https://api.github.com/repos/MatthewVita/openemr/stargazers","contributors_url":"https://api.github.com/repos/MatthewVita/openemr/contributors","subscribers_url":"https://api.github.com/repos/MatthewVita/openemr/subscribers","subscription_url":"https://api.github.com/repos/MatthewVita/openemr/subscription","commits_url":"https://api.github.com/repos/MatthewVita/openemr/commits{/sha}","git_commits_url":"https://api.github.com/repos/MatthewVita/openemr/git/commits{/sha}","comments_url":"https://api.github.com/repos/MatthewVita/openemr/comments{/number}","issue_comment_url":"https://api.github.com/repos/MatthewVita/openemr/issues/comments{/number}","contents_url":"https://api.github.com/repos/MatthewVita/openemr/contents/{+path}","compare_url":"https://api.github.com/repos/MatthewVita/openemr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MatthewVita/openemr/merges","archive_url":"https://api.github.com/repos/MatthewVita/openemr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MatthewVita/openemr/downloads","issues_url":"https://api.github.com/repos/MatthewVita/openemr/issues{/number}","pulls_url":"https://api.github.com/repos/MatthewVita/openemr/pulls{/number}","milestones_url":"https://api.github.com/repos/MatthewVita/openemr/milestones{/number}","notifications_url":"https://api.github.com/repos/MatthewVita/openemr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MatthewVita/openemr/labels{/name}","releases_url":"https://api.github.com/repos/MatthewVita/openemr/releases{/id}","deployments_url":"https://api.github.com/repos/MatthewVita/openemr/deployments","created_at":"2016-09-18T02:35:02Z","updated_at":"2016-09-18T02:35:21Z","pushed_at":"2016-09-23T01:48:04Z","git_url":"git://github.com/MatthewVita/openemr.git","ssh_url":"git@github.com:MatthewVita/openemr.git","clone_url":"https://github.com/MatthewVita/openemr.git","svn_url":"https://github.com/MatthewVita/openemr","homepage":"http://open-emr.org/","size":273872,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"openemr:master","ref":"master","sha":"56f7cbaa78d51987cfa55fdd3ee4368976a99296","user":{"login":"openemr","id":283089,"avatar_url":"https://avatars.githubusercontent.com/u/283089?v=3","gravatar_id":"","url":"https://api.github.com/users/openemr","html_url":"https://github.com/openemr","followers_url":"https://api.github.com/users/openemr/followers","following_url":"https://api.github.com/users/openemr/following{/other_user}","gists_url":"https://api.github.com/users/openemr/gists{/gist_id}","starred_url":"https://api.github.com/users/openemr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openemr/subscriptions","organizations_url":"https://api.github.com/users/openemr/orgs","repos_url":"https://api.github.com/users/openemr/repos","events_url":"https://api.github.com/users/openemr/events{/privacy}","received_events_url":"https://api.github.com/users/openemr/received_events","type":"Organization","site_admin":false},"repo":{"id":679584,"name":"openemr","full_name":"openemr/openemr","owner":{"login":"openemr","id":283089,"avatar_url":"https://avatars.githubusercontent.com/u/283089?v=3","gravatar_id":"","url":"https://api.github.com/users/openemr","html_url":"https://github.com/openemr","followers_url":"https://api.github.com/users/openemr/followers","following_url":"https://api.github.com/users/openemr/following{/other_user}","gists_url":"https://api.github.com/users/openemr/gists{/gist_id}","starred_url":"https://api.github.com/users/openemr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openemr/subscriptions","organizations_url":"https://api.github.com/users/openemr/orgs","repos_url":"https://api.github.com/users/openemr/repos","events_url":"https://api.github.com/users/openemr/events{/privacy}","received_events_url":"https://api.github.com/users/openemr/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openemr/openemr","description":"Mirror of official OpenEMR Sourceforge repository","fork":false,"url":"https://api.github.com/repos/openemr/openemr","forks_url":"https://api.github.com/repos/openemr/openemr/forks","keys_url":"https://api.github.com/repos/openemr/openemr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openemr/openemr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openemr/openemr/teams","hooks_url":"https://api.github.com/repos/openemr/openemr/hooks","issue_events_url":"https://api.github.com/repos/openemr/openemr/issues/events{/number}","events_url":"https://api.github.com/repos/openemr/openemr/events","assignees_url":"https://api.github.com/repos/openemr/openemr/assignees{/user}","branches_url":"https://api.github.com/repos/openemr/openemr/branches{/branch}","tags_url":"https://api.github.com/repos/openemr/openemr/tags","blobs_url":"https://api.github.com/repos/openemr/openemr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openemr/openemr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openemr/openemr/git/refs{/sha}","trees_url":"https://api.github.com/repos/openemr/openemr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openemr/openemr/statuses/{sha}","languages_url":"https://api.github.com/repos/openemr/openemr/languages","stargazers_url":"https://api.github.com/repos/openemr/openemr/stargazers","contributors_url":"https://api.github.com/repos/openemr/openemr/contributors","subscribers_url":"https://api.github.com/repos/openemr/openemr/subscribers","subscription_url":"https://api.github.com/repos/openemr/openemr/subscription","commits_url":"https://api.github.com/repos/openemr/openemr/commits{/sha}","git_commits_url":"https://api.github.com/repos/openemr/openemr/git/commits{/sha}","comments_url":"https://api.github.com/repos/openemr/openemr/comments{/number}","issue_comment_url":"https://api.github.com/repos/openemr/openemr/issues/comments{/number}","contents_url":"https://api.github.com/repos/openemr/openemr/contents/{+path}","compare_url":"https://api.github.com/repos/openemr/openemr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openemr/openemr/merges","archive_url":"https://api.github.com/repos/openemr/openemr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openemr/openemr/downloads","issues_url":"https://api.github.com/repos/openemr/openemr/issues{/number}","pulls_url":"https://api.github.com/repos/openemr/openemr/pulls{/number}","milestones_url":"https://api.github.com/repos/openemr/openemr/milestones{/number}","notifications_url":"https://api.github.com/repos/openemr/openemr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openemr/openemr/labels{/name}","releases_url":"https://api.github.com/repos/openemr/openemr/releases{/id}","deployments_url":"https://api.github.com/repos/openemr/openemr/deployments","created_at":"2010-05-21T19:54:08Z","updated_at":"2016-09-22T18:41:21Z","pushed_at":"2016-09-23T01:48:05Z","git_url":"git://github.com/openemr/openemr.git","ssh_url":"git@github.com:openemr/openemr.git","clone_url":"https://github.com/openemr/openemr.git","svn_url":"https://github.com/openemr/openemr","homepage":"http://open-emr.org/","size":306891,"stargazers_count":301,"watchers_count":301,"language":"PHP","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":456,"mirror_url":null,"open_issues_count":34,"forks":456,"open_issues":34,"watchers":301,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openemr/openemr/pulls/257"},"html":{"href":"https://github.com/openemr/openemr/pull/257"},"issue":{"href":"https://api.github.com/repos/openemr/openemr/issues/257"},"comments":{"href":"https://api.github.com/repos/openemr/openemr/issues/257/comments"},"review_comments":{"href":"https://api.github.com/repos/openemr/openemr/pulls/257/comments"},"review_comment":{"href":"https://api.github.com/repos/openemr/openemr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openemr/openemr/pulls/257/commits"},"statuses":{"href":"https://api.github.com/repos/openemr/openemr/statuses/810220de3d6ad3ba148f98558c075abb4af036a6"}}}}
{"actor":{"display_login":"bradymiller"}}