-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Implement PHP client endpoints into Prestashop #587
Open
Benjamin-Freoua-Alma
wants to merge
14
commits into
develop
Choose a base branch
from
feature/ecom-2127-ps-implement-php-client-endpoints-into-prestashop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
69a3e84
feat: CMS is able to send the endpoint_url to backend
Benjamin-Freoua-Alma 27578af
feat: add cmsdataexport front controller
Benjamin-Freoua-Alma 6399e6f
feat: refacto controller front cmsdataexport
Benjamin-Freoua-Alma 2c8eb85
fix: update previous test
Benjamin-Freoua-Alma fb115ce
fix: add test in function refactored
Benjamin-Freoua-Alma 59484b0
feat: Hmac + Timetamp + CmsDataService + Helper Data CMS
Benjamin-Freoua-Alma 957c882
feat: refacto controller + Test
Benjamin-Freoua-Alma 9edbf24
fix: Sonar
Benjamin-Freoua-Alma cb2ad99
fix: Sonar include_once instead include
Benjamin-Freoua-Alma a3cc2c2
fix: php client dependency
Francois-Gomis 01ed88f
fix: change merchant endpoint to configuration
Francois-Gomis 5a4bb24
fix: alma php client version requirement
Francois-Gomis ffd32fd
feat: review [FRA] create ShopModel + docblock
Benjamin-Freoua-Alma 2383ddb
fix: constante ALMA_CMSDATA_DATE
Benjamin-Freoua-Alma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
<?php | ||
/** | ||
* 2018-2024 Alma SAS. | ||
* | ||
* THE MIT LICENSE | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and | ||
* to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the | ||
* Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | ||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
* | ||
* @author Alma SAS <[email protected]> | ||
* @copyright 2018-2024 Alma SAS | ||
* @license https://opensource.org/licenses/MIT The MIT License | ||
*/ | ||
|
||
use Alma\API\Entities\MerchantData\CmsFeatures; | ||
use Alma\API\Entities\MerchantData\CmsInfo; | ||
use Alma\API\Lib\PayloadFormatter; | ||
use Alma\PrestaShop\Builders\Helpers\SettingsHelperBuilder; | ||
use Alma\PrestaShop\Exceptions\CmsDataException; | ||
use Alma\PrestaShop\Exceptions\ValidateException; | ||
use Alma\PrestaShop\Helpers\CmsDataHelper; | ||
use Alma\PrestaShop\Helpers\SettingsHelper; | ||
use Alma\PrestaShop\Helpers\ValidateHelper; | ||
use Alma\PrestaShop\Traits\AjaxTrait; | ||
|
||
if (!defined('_PS_VERSION_')) { | ||
exit; | ||
} | ||
|
||
/** | ||
* AlmaCmsDataExportModuleFrontController | ||
*/ | ||
class AlmaCmsDataExportModuleFrontController extends ModuleFrontController | ||
{ | ||
use AjaxTrait; | ||
|
||
/** | ||
* @var ValidateHelper | ||
*/ | ||
protected $validateHelper; | ||
/** | ||
* @var \Alma\PrestaShop\Helpers\SettingsHelper | ||
*/ | ||
protected $settingsHelper; | ||
/** | ||
* @var \Alma\API\Lib\PayloadFormatter | ||
*/ | ||
protected $payloadFormatter; | ||
/** | ||
* @var CmsDataHelper | ||
*/ | ||
protected $cmsDataHelper; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
$this->validateHelper = new ValidateHelper(); | ||
$this->cmsDataHelper = new CmsDataHelper(); | ||
$this->settingsHelper = (new SettingsHelperBuilder())->getInstance(); | ||
$this->payloadFormatter = new PayloadFormatter(); | ||
} | ||
|
||
/** | ||
* @throws \Alma\PrestaShop\Exceptions\CmsDataException | ||
* @throws \PrestaShopException | ||
*/ | ||
public function postProcess() | ||
{ | ||
parent::postProcess(); | ||
try { | ||
$this->validateHelper->checkSignature($this->settingsHelper->getIdMerchant(), SettingsHelper::getActiveAPIKey(), $_SERVER['HTTP_X_ALMA_SIGNATURE']); | ||
} catch (ValidateException $e) { | ||
throw new CmsDataException('[Alma] checkSignature - ' . $e->getMessage()); | ||
} catch (\Exception $e) { | ||
throw new CmsDataException('[Alma] Get Merchant Id - ' . $e->getMessage()); | ||
} | ||
|
||
$cmsInfo = new CmsInfo($this->cmsDataHelper->getCmsInfoArray()); | ||
$cmsFeature = new CmsFeatures($this->cmsDataHelper->getCmsFeatureArray()); | ||
|
||
$payload = $this->payloadFormatter->formatConfigurationPayload($cmsInfo, $cmsFeature); | ||
$this->ajaxRenderAndExit(json_encode(['success' => $payload])); | ||
} | ||
|
||
/** | ||
* @param $validateHelper | ||
* | ||
* @return void | ||
*/ | ||
public function setValidateHelper($validateHelper) | ||
{ | ||
$this->validateHelper = $validateHelper; | ||
} | ||
|
||
/** | ||
* @param $settingsHelper | ||
* | ||
* @return void | ||
*/ | ||
public function setSettingsHelper($settingsHelper) | ||
{ | ||
$this->settingsHelper = $settingsHelper; | ||
} | ||
|
||
/** | ||
* @param $payloadFormatter | ||
* | ||
* @return void | ||
*/ | ||
public function setPayloadFormatter($payloadFormatter) | ||
{ | ||
$this->payloadFormatter = $payloadFormatter; | ||
} | ||
|
||
/** | ||
* @param $cmsDataHelper | ||
* | ||
* @return void | ||
*/ | ||
public function setCmsDataHelper($cmsDataHelper) | ||
{ | ||
$this->cmsDataHelper = $cmsDataHelper; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* 2018-2024 Alma SAS. | ||
* | ||
* THE MIT LICENSE | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and | ||
* to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the | ||
* Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | ||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
* | ||
* @author Alma SAS <[email protected]> | ||
* @copyright 2018-2024 Alma SAS | ||
* @license https://opensource.org/licenses/MIT The MIT License | ||
*/ | ||
|
||
namespace Alma\PrestaShop\Exceptions; | ||
|
||
if (!defined('_PS_VERSION_')) { | ||
exit; | ||
} | ||
|
||
class CmsDataException extends AlmaException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* 2018-2024 Alma SAS. | ||
* | ||
* THE MIT LICENSE | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and | ||
* to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the | ||
* Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | ||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
* | ||
* @author Alma SAS <[email protected]> | ||
* @copyright 2018-2024 Alma SAS | ||
* @license https://opensource.org/licenses/MIT The MIT License | ||
*/ | ||
|
||
namespace Alma\PrestaShop\Exceptions; | ||
|
||
if (!defined('_PS_VERSION_')) { | ||
exit; | ||
} | ||
|
||
class ValidateException extends AlmaException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/** | ||
* 2018-2024 Alma SAS. | ||
* | ||
* THE MIT LICENSE | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and | ||
* to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the | ||
* Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | ||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
* | ||
* @author Alma SAS <[email protected]> | ||
* @copyright 2018-2024 Alma SAS | ||
* @license https://opensource.org/licenses/MIT The MIT License | ||
*/ | ||
|
||
namespace Alma\PrestaShop\Factories; | ||
|
||
if (!defined('_PS_VERSION_')) { | ||
exit; | ||
} | ||
|
||
/** | ||
* Class CategoryFactory. | ||
*/ | ||
class CategoryFactory | ||
{ | ||
/** | ||
* @param int $id | ||
* | ||
* @return \Category | ||
*/ | ||
public function create($id = null, $idLang = null) | ||
{ | ||
return new \Category($id, $idLang); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module name is not a Param - it a getAlmaModule methode and it's an AlmaModuleFactory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Francois-Gomis I'm not sure to understand your request. Can we speak on that in synchroniously