diff --git a/app/code/IpSupply/SyncOrder/Api/Repository.php b/app/code/IpSupply/SyncOrder/Api/Repository.php new file mode 100755 index 00000000..1dc1f84b --- /dev/null +++ b/app/code/IpSupply/SyncOrder/Api/Repository.php @@ -0,0 +1,86 @@ +authorization(); + } + + private function authorization() + { + $headers = apache_request_headers(); + $apiKey = \IpSupply\SyncOrder\Helper::API_KEY; + + foreach ($headers as $key => $value) { + $key = strtolower($key); + if ('api_key' === $key && $value === $apiKey) { + return true; + } + } + + header('HTTP/1.1 401 Unauthorized'); + header('Accept: application/json'); + header('Content-Type: application/json'); + die(json_encode(['message' => 'unauthorized'])); + } + + private function _responseOk(array $data) + { + header('HTTP/1.1 200 Ok'); + header('Accept: application/json'); + header('Content-Type: application/json'); + die(json_encode($data)); + } + + private function _responseFail(array $data) + { + header('HTTP/1.1 400 Bad request'); + header('Accept: application/json'); + header('Content-Type: application/json'); + die(json_encode($data)); + } + + private function _responseMethodFail() + { + header('HTTP/1.1 400 bad request'); + header('Accept: application/json'); + header('Content-Type: application/json'); + die(json_encode([ + 'status' => false, + 'message' => 'Param ?method=... not exist!' + ])); + } + + public function getData() + { + return $this->_responseOk([ + 'status' => true, + 'data' => [] + ]); + // return $this->_responseMethodFail(); + } + + public function postData() + { + parse_str( + string: file_get_contents('php://input'), + result: $payload + ); + + return $this->_responseOk([ + 'status' => true, + 'data' => [], // TODO + 'payload' => $payload + ]); + + // return $this->_responseMethodFail(); + } +} diff --git a/app/code/IpSupply/SyncOrder/Api/RepositoryInterface.php b/app/code/IpSupply/SyncOrder/Api/RepositoryInterface.php new file mode 100755 index 00000000..52a740cb --- /dev/null +++ b/app/code/IpSupply/SyncOrder/Api/RepositoryInterface.php @@ -0,0 +1,23 @@ +urlInterface = $urlInterface; + parent::__construct($context, $data); + } + + public function getSecretKey() + { + return $this->urlInterface->getSecretKey(); + } + + public function getApiKey() + { + return \IpSupply\SyncOrder\Helper::API_KEY; + } +} diff --git a/app/code/IpSupply/SyncOrder/Controller/Adminhtml/Config/Index.php b/app/code/IpSupply/SyncOrder/Controller/Adminhtml/Config/Index.php new file mode 100755 index 00000000..1cb7d5c0 --- /dev/null +++ b/app/code/IpSupply/SyncOrder/Controller/Adminhtml/Config/Index.php @@ -0,0 +1,27 @@ +resultPageFactory = $resultPageFactory; + } + public function execute() + { + $resultPage = $this->resultPageFactory->create(); + $resultPage->setActiveMenu('IpSupply_SyncOrder::menu'); + $resultPage->getConfig()->getTitle()->prepend(__('IpSupply | Sync Order')); + return $resultPage; + } + protected function _isAllowed() + { + return $this->_authorization->isAllowed('IpSupply_SyncOrder::config'); + } +} diff --git a/app/code/IpSupply/SyncOrder/Helper.php b/app/code/IpSupply/SyncOrder/Helper.php new file mode 100755 index 00000000..e33c96df --- /dev/null +++ b/app/code/IpSupply/SyncOrder/Helper.php @@ -0,0 +1,7 @@ + + + + + + + + diff --git a/app/code/IpSupply/SyncOrder/etc/adminhtml/routes.xml b/app/code/IpSupply/SyncOrder/etc/adminhtml/routes.xml new file mode 100755 index 00000000..3d343d7f --- /dev/null +++ b/app/code/IpSupply/SyncOrder/etc/adminhtml/routes.xml @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/app/code/IpSupply/SyncOrder/etc/module.xml b/app/code/IpSupply/SyncOrder/etc/module.xml new file mode 100755 index 00000000..24da24b0 --- /dev/null +++ b/app/code/IpSupply/SyncOrder/etc/module.xml @@ -0,0 +1,4 @@ + + + + diff --git a/app/code/IpSupply/SyncOrder/etc/webapi.xml b/app/code/IpSupply/SyncOrder/etc/webapi.xml new file mode 100755 index 00000000..ff2976a2 --- /dev/null +++ b/app/code/IpSupply/SyncOrder/etc/webapi.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/app/code/IpSupply/SyncOrder/registration.php b/app/code/IpSupply/SyncOrder/registration.php new file mode 100755 index 00000000..d4fa4b75 --- /dev/null +++ b/app/code/IpSupply/SyncOrder/registration.php @@ -0,0 +1,6 @@ + + + + + + + + + + + + diff --git a/app/code/IpSupply/SyncOrder/view/adminhtml/templates/syncorder_config.phtml b/app/code/IpSupply/SyncOrder/view/adminhtml/templates/syncorder_config.phtml new file mode 100755 index 00000000..e69de29b diff --git a/app/code/IpSupply/SyncOrder/view/adminhtml/web/css/config.css b/app/code/IpSupply/SyncOrder/view/adminhtml/web/css/config.css new file mode 100755 index 00000000..e69de29b