-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Benjamin Calef
committed
Nov 5, 2021
0 parents
commit 50ccd25
Showing
30 changed files
with
1,918 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
/** | ||
* This file is part of Zepgram\Rest\Exception | ||
* | ||
* @package Zepgram\Rest\Exception | ||
* @file ExternalException.php | ||
* @date 04 11 2021 23:28 | ||
* | ||
* @author Benjamin Calef <[email protected]> | ||
* @copyright 2021 Zepgram Copyright (c) (https://github.com/zepgram) | ||
* @license MIT License | ||
**/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zepgram\Rest\Exception; | ||
|
||
class ExternalException extends RestException | ||
{ | ||
|
||
} |
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,21 @@ | ||
<?php | ||
/** | ||
* This file is part of Zepgram\Rest\Exception | ||
* | ||
* @package Zepgram\Rest\Exception | ||
* @file InternalException.php | ||
* @date 04 11 2021 23:28 | ||
* | ||
* @author Benjamin Calef <[email protected]> | ||
* @copyright 2021 Zepgram Copyright (c) (https://github.com/zepgram) | ||
* @license MIT License | ||
**/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zepgram\Rest\Exception; | ||
|
||
class InternalException extends RestException | ||
{ | ||
|
||
} |
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,23 @@ | ||
<?php | ||
/** | ||
* This file is part of Zepgram\Rest\Exception | ||
* | ||
* @package Zepgram\Rest\Exception | ||
* @file RestException.php | ||
* @date 04 11 2021 23:28 | ||
* | ||
* @author Benjamin Calef <[email protected]> | ||
* @copyright 2021 Zepgram Copyright (c) (https://github.com/zepgram) | ||
* @license MIT License | ||
**/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zepgram\Rest\Exception; | ||
|
||
use Magento\Framework\Exception\LocalizedException; | ||
|
||
class RestException extends LocalizedException | ||
{ | ||
|
||
} |
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,23 @@ | ||
<?php | ||
/** | ||
* This file is part of Zepgram\Rest\Exception\Result | ||
* | ||
* @package Zepgram\Rest\Exception\Result | ||
* @file BusinessException.php | ||
* @date 04 11 2021 23:22 | ||
* | ||
* @author Benjamin Calef <[email protected]> | ||
* @copyright 2021 Zepgram Copyright (c) (https://github.com/zepgram) | ||
* @license MIT License | ||
**/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zepgram\Rest\Exception\Result; | ||
|
||
use Zepgram\Rest\Exception\InternalException; | ||
|
||
class BusinessException extends InternalException | ||
{ | ||
|
||
} |
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,36 @@ | ||
<?php | ||
/** | ||
* This file is part of Zepgram\Rest\Exception\Result | ||
* | ||
* @package Zepgram\Rest\Exception\Result | ||
* @file HttpException.php | ||
* @date 04 11 2021 23:22 | ||
* | ||
* @author Benjamin Calef <[email protected]> | ||
* @copyright 2021 Zepgram Copyright (c) (https://github.com/zepgram) | ||
* @license MIT License | ||
**/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zepgram\Rest\Exception\Result; | ||
|
||
use Exception; | ||
use Magento\Framework\Phrase; | ||
use Zepgram\Rest\Exception\ExternalException; | ||
|
||
class HttpException extends ExternalException | ||
{ | ||
/** | ||
* @throws ExternalException | ||
*/ | ||
public function __construct(Phrase $phrase, Exception $cause = null, $code = 0) | ||
{ | ||
parent::__construct($phrase, $cause, $code); | ||
if ($cause && $cause->getCode() && ($code === 0 || $code === null)) { | ||
$code = $cause->getCode(); | ||
} | ||
|
||
throw new ExternalException(__($phrase), $cause, $code); | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
/** | ||
* This file is part of Zepgram\Rest\Exception\Result | ||
* | ||
* @package Zepgram\Rest\Exception\Result | ||
* @file NotFoundException.php | ||
* @date 04 11 2021 23:22 | ||
* | ||
* @author Benjamin Calef <[email protected]> | ||
* @copyright 2021 Zepgram Copyright (c) (https://github.com/zepgram) | ||
* @license MIT License | ||
**/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zepgram\Rest\Exception\Result; | ||
|
||
use Zepgram\Rest\Exception\ExternalException; | ||
|
||
class NotFoundException extends ExternalException | ||
{ | ||
|
||
} |
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,23 @@ | ||
<?php | ||
/** | ||
* This file is part of Zepgram\Rest\Exception\Result | ||
* | ||
* @package Zepgram\Rest\Exception\Result | ||
* @file UnserializeException.php | ||
* @date 04 11 2021 23:22 | ||
* | ||
* @author Benjamin Calef <[email protected]> | ||
* @copyright 2021 Zepgram Copyright (c) (https://github.com/zepgram) | ||
* @license MIT License | ||
**/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zepgram\Rest\Exception\Result; | ||
|
||
use Zepgram\Rest\Exception\ExternalException; | ||
|
||
class UnserializeException extends ExternalException | ||
{ | ||
|
||
} |
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,23 @@ | ||
<?php | ||
/** | ||
* This file is part of Zepgram\Rest\Exception\Technical | ||
* | ||
* @package Zepgram\Rest\Exception\Technical | ||
* @file InvalidContractException.php | ||
* @date 04 11 2021 23:22 | ||
* | ||
* @author Benjamin Calef <[email protected]> | ||
* @copyright 2021 Zepgram Copyright (c) (https://github.com/zepgram) | ||
* @license MIT License | ||
**/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zepgram\Rest\Exception\Technical; | ||
|
||
use Zepgram\Rest\Exception\RestException; | ||
|
||
class InvalidContractException extends RestException | ||
{ | ||
|
||
} |
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,23 @@ | ||
<?php | ||
/** | ||
* This file is part of Zepgram\Rest\Exception\Technical | ||
* | ||
* @package Zepgram\Rest\Exception\Technical | ||
* @file LogicException.php | ||
* @date 04 11 2021 23:22 | ||
* | ||
* @author Benjamin Calef <[email protected]> | ||
* @copyright 2021 Zepgram Copyright (c) (https://github.com/zepgram) | ||
* @license MIT License | ||
**/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zepgram\Rest\Exception\Technical; | ||
|
||
use Zepgram\Rest\Exception\RestException; | ||
|
||
class LogicException extends RestException | ||
{ | ||
|
||
} |
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,23 @@ | ||
<?php | ||
/** | ||
* This file is part of Zepgram\Rest\Exception\Technical | ||
* | ||
* @package Zepgram\Rest\Exception\Technical | ||
* @file LogicException.php | ||
* @date 04 11 2021 23:22 | ||
* | ||
* @author Benjamin Calef <[email protected]> | ||
* @copyright 2021 Zepgram Copyright (c) (https://github.com/zepgram) | ||
* @license MIT License | ||
**/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zepgram\Rest\Exception\Technical; | ||
|
||
use Zepgram\Rest\Exception\RestException; | ||
|
||
class MissingBaseUriException extends RestException | ||
{ | ||
|
||
} |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Zepgram - Benjamin Calef | ||
|
||
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. |
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,52 @@ | ||
<?php | ||
/** | ||
* This file is part of Zepgram\Rest\Model\Cache | ||
* | ||
* @package Zepgram\Rest\Model\Cache | ||
* @file Identifier.php | ||
* @date 04 11 2021 23:28 | ||
* | ||
* @author Benjamin Calef <[email protected]> | ||
* @copyright 2021 Zepgram Copyright (c) (https://github.com/zepgram) | ||
* @license MIT License | ||
**/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zepgram\Rest\Model\Cache; | ||
|
||
use Magento\Framework\Encryption\Encryptor; | ||
use Zepgram\Rest\Model\ParametersInterface; | ||
|
||
class Identifier | ||
{ | ||
/** @var Encryptor */ | ||
private $encryptor; | ||
|
||
/** | ||
* @param Encryptor $encryptor | ||
*/ | ||
public function __construct(Encryptor $encryptor) | ||
{ | ||
$this->encryptor = $encryptor; | ||
} | ||
|
||
/** | ||
* @param ParametersInterface $parameters | ||
* @return string | ||
*/ | ||
public function getCacheKey(ParametersInterface $parameters): string | ||
{ | ||
return $this->encryptor->hash($parameters->getServiceName() . '_' . $parameters->getCacheKey()); | ||
} | ||
|
||
/** | ||
* @param string $serviceName | ||
* @param $data | ||
* @return string | ||
*/ | ||
public function getRegistryKey(string $serviceName, $data): string | ||
{ | ||
return $this->encryptor->hash($serviceName . '_' . $data); | ||
} | ||
} |
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,36 @@ | ||
<?php | ||
/** | ||
* This file is part of Zepgram\Rest\Model\Cache | ||
* | ||
* @package Zepgram\Rest\Model\Cache | ||
* @file RestApiCache.php | ||
* @date 04 11 2021 23:28 | ||
* | ||
* @author Benjamin Calef <[email protected]> | ||
* @copyright 2021 Zepgram Copyright (c) (https://github.com/zepgram) | ||
* @license MIT License | ||
**/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zepgram\Rest\Model\Cache; | ||
|
||
use Magento\Framework\App\Cache\Type\FrontendPool; | ||
use Magento\Framework\Cache\Frontend\Decorator\TagScope; | ||
|
||
class RestApiCache extends TagScope | ||
{ | ||
/** @var string */ | ||
public const TYPE_IDENTIFIER = 'rest_api_result'; | ||
|
||
/** @var string */ | ||
public const CACHE_TAG = 'REST_API_RESULT'; | ||
|
||
/** | ||
* @param FrontendPool $cacheFrontendPool | ||
*/ | ||
public function __construct(FrontendPool $cacheFrontendPool) | ||
{ | ||
parent::__construct($cacheFrontendPool->get(self::TYPE_IDENTIFIER), self::CACHE_TAG); | ||
} | ||
} |
Oops, something went wrong.