-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PIPRES-349: Update subscription action
- Loading branch information
Showing
13 changed files
with
101 additions
and
255 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
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
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
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,55 @@ | ||
<?php | ||
/** | ||
* Mollie https://www.mollie.nl | ||
* | ||
* @author Mollie B.V. <[email protected]> | ||
* @copyright Mollie B.V. | ||
* @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md | ||
* | ||
* @see https://github.com/mollie/PrestaShop | ||
* @codingStandardsIgnoreStart | ||
*/ | ||
|
||
namespace Mollie\Subscription\Action; | ||
|
||
use Mollie\Logger\PrestaLoggerInterface; | ||
use Mollie\Subscription\Api\SubscriptionApi; | ||
use Mollie\Subscription\DTO\UpdateSubscriptionData; | ||
use Mollie\Subscription\Exception\CouldNotUpdateSubscription; | ||
use Mollie\Subscription\Exception\MollieSubscriptionException; | ||
|
||
if (!defined('_PS_VERSION_')) { | ||
exit; | ||
} | ||
|
||
class UpdateSubscriptionAction | ||
{ | ||
/** @var SubscriptionApi */ | ||
private $subscriptionApi; | ||
/** @var PrestaLoggerInterface */ | ||
private $logger; | ||
|
||
public function __construct( | ||
SubscriptionApi $subscriptionApi, | ||
PrestaLoggerInterface $logger | ||
) { | ||
$this->subscriptionApi = $subscriptionApi; | ||
$this->logger = $logger; | ||
} | ||
|
||
/** | ||
* @throws MollieSubscriptionException | ||
*/ | ||
public function run(UpdateSubscriptionData $data): void | ||
{ | ||
$this->logger->info(sprintf('%s - Function called', __METHOD__)); | ||
|
||
try { | ||
$this->subscriptionApi->updateSubscription($data); | ||
} catch (\Throwable $exception) { | ||
throw CouldNotUpdateSubscription::failedToUpdateSubscription($exception, $data->getSubscriptionId()); | ||
} | ||
|
||
$this->logger->info(sprintf('%s - Function ended', __METHOD__)); | ||
} | ||
} |
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,32 @@ | ||
<?php | ||
/** | ||
* Mollie https://www.mollie.nl | ||
* | ||
* @author Mollie B.V. <[email protected]> | ||
* @copyright Mollie B.V. | ||
* @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md | ||
* | ||
* @see https://github.com/mollie/PrestaShop | ||
* @codingStandardsIgnoreStart | ||
*/ | ||
|
||
namespace Mollie\Subscription\Exception; | ||
|
||
if (!defined('_PS_VERSION_')) { | ||
exit; | ||
} | ||
|
||
class CouldNotUpdateSubscription extends MollieSubscriptionException | ||
{ | ||
public static function failedToUpdateSubscription(\Throwable $exception, string $subscriptionId): self | ||
{ | ||
return new self( | ||
sprintf( | ||
'Failed to update subscription. Subscription ID: (%s)', | ||
$subscriptionId | ||
), | ||
ExceptionCode::ORDER_FAILED_TO_UPDATE_SUBSCRIPTION, | ||
Check failure on line 28 in subscription/Exception/CouldNotUpdateSubscription.php GitHub Actions / PHPStan (1.7.6.8)
|
||
$exception | ||
); | ||
} | ||
} |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.