Compare commits
11 Commits
Author | SHA1 | Date |
---|---|---|
Daniel Seifert | 258961bddc | |
Daniel Seifert | d964824fa1 | |
Daniel Seifert | b8cd9b3b0d | |
Daniel Seifert | ff45750c35 | |
Daniel Seifert | a00061a37c | |
Daniel Seifert | 9eff4ad296 | |
Daniel Seifert | cd2ea14121 | |
Daniel Seifert | 63ec4670b7 | |
Daniel Seifert | c36ebf7381 | |
Daniel Seifert | 72fcd89823 | |
Daniel Seifert | 00e54ec4dc |
|
@ -0,0 +1 @@
|
|||
.php_cs.cache
|
|
@ -6,7 +6,7 @@ $finder = PhpCsFixer\Finder::create()
|
|||
|
||||
$config = new PhpCsFixer\Config();
|
||||
return $config->setRules([
|
||||
'@PHP70Migration' => true,
|
||||
'@PHP71Migration' => true,
|
||||
'@PSR12' => true
|
||||
])
|
||||
->setFinder($finder)
|
||||
|
|
21
CHANGELOG.md
21
CHANGELOG.md
|
@ -1,9 +1,26 @@
|
|||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
---
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## 1.0.0.0 (2022-07-13)
|
||||
## [Unreleased](https://git.d3data.de/D3Private/linkmobility4oxid/compare/1.1.0.0...rel_1.x)
|
||||
|
||||
## [1.1.0.0](https://git.d3data.de/D3Private/linkmobility4oxid/compare/1.0.0.0...1.1.0.0) - 2022-07-28
|
||||
### Added
|
||||
- phpstan code checks
|
||||
|
||||
### Changed
|
||||
- improved changelog
|
||||
|
||||
### Fixed
|
||||
- type in IntelliSenseHelper class name
|
||||
|
||||
### Removed
|
||||
- PHP 7.0 support
|
||||
|
||||
## [1.0.0.0](https://git.d3data.de/D3Private/linkmobility4oxid/releases/tag/1.0.0.0) - 2022-07-13
|
||||
### Added
|
||||
- initial implementation
|
||||
Send message on:
|
||||
- Order completion, sending order confirmation message.
|
||||
|
|
|
@ -27,6 +27,7 @@ This package requires an OXID eShop installed with Composer in one of the follow
|
|||
- 6.2.4 or above
|
||||
- 6.3.x
|
||||
- 6.4.x
|
||||
- 6.5.x
|
||||
|
||||
and its requirements.
|
||||
|
||||
|
@ -54,6 +55,12 @@ If you have a suggestion that would make this better, please fork the repo and c
|
|||
- Push to the Branch (git push origin feature/AmazingFeature)
|
||||
- Open a Pull Request
|
||||
|
||||
## Support
|
||||
|
||||
If you have any questions about the *messaging service* and its *contracts*, please contact the [LINK Mobility Team](https://www.linkmobility.de/kontakt).
|
||||
|
||||
For *technical inquiries* you will find the contact options in the [composer.json](composer.json).
|
||||
|
||||
## License
|
||||
(status: 2022-07-13)
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ Dieses Paket erfordert einen mit Composer installierten OXID eShop in einer der
|
|||
- 6.2.4 oder höher
|
||||
- 6.3.x
|
||||
- 6.4.x
|
||||
- 6.5.x
|
||||
|
||||
und dessen Anforderungen.
|
||||
|
||||
|
@ -54,6 +55,12 @@ Wenn Sie eine Verbesserungsvorschlag haben, legen Sie einen Fork des Repositorie
|
|||
- Ăśbertragen Sie den Branch (git push origin feature/AmazingFeature)
|
||||
- Ă–ffnen Sie einen Pull Request
|
||||
|
||||
## Support
|
||||
|
||||
Bei Fragen zum *Messaging Service* und dessen *Verträgen* kontaktieren Sie bitte das [LINK Mobility Team](https://www.linkmobility.de/kontakt).
|
||||
|
||||
Zu *technischen Anfragen* finden Sie die Kontaktmöglichkeiten in der [composer.json](composer.json).
|
||||
|
||||
## Lizenz
|
||||
(Stand: 13.07.2022)
|
||||
|
||||
|
|
|
@ -17,11 +17,19 @@
|
|||
"role": "Owner"
|
||||
}
|
||||
],
|
||||
"license": [
|
||||
"GPL-3.0-or-later"
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.0 || ^8.0",
|
||||
"oxid-esales/oxideshop-ce": "6.7 - 6.10",
|
||||
"php": "^7.1 || ^8.0",
|
||||
"oxid-esales/oxideshop-ce": "6.7 - 6.12",
|
||||
"d3/linkmobility-php-client": "^1.2.0 || ^2.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"oxid-esales/oxideshop-ce": "~6.10.0",
|
||||
"friendsofphp/php-cs-fixer": "^2.19",
|
||||
"phpstan/phpstan": "^1.8"
|
||||
},
|
||||
"extra": {
|
||||
"oxideshop": {
|
||||
"source-directory": "/src",
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
parameters:
|
||||
scanFiles:
|
||||
- src/IntelliSenseHelper.php
|
||||
- ../../oxid-esales/oxideshop-ce/source/oxfunctions.php
|
||||
paths:
|
||||
- src
|
||||
level: 9
|
||||
phpVersion: 70100
|
||||
ignoreErrors:
|
||||
- '#Psr\\Container\\ContainerExceptionInterface is not subtype of Throwable#'
|
|
@ -58,24 +58,25 @@ class AdminOrder extends AdminController
|
|||
try {
|
||||
return oxNew(OrderRecipients::class, $this->order)->getSmsRecipient();
|
||||
} catch (noRecipientFoundException $e) {
|
||||
Registry::getUtilsView()->addErrorToDisplay(
|
||||
Registry::getLang()->translateString($e->getMessage())
|
||||
);
|
||||
/** @var string $message */
|
||||
$message = Registry::getLang()->translateString($e->getMessage());
|
||||
Registry::getUtilsView()->addErrorToDisplay($message);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function send()
|
||||
public function send(): void
|
||||
{
|
||||
$messageBody = Registry::getRequest()->getRequestEscapedParameter('messagebody');
|
||||
|
||||
if (false === is_string($messageBody) || strlen($messageBody) <= 1) {
|
||||
Registry::getUtilsView()->addErrorToDisplay(
|
||||
Registry::getLang()->translateString('D3LM_EXC_MESSAGE_NO_LENGTH')
|
||||
);
|
||||
/** @var string $message */
|
||||
$message = Registry::getLang()->translateString('D3LM_EXC_MESSAGE_NO_LENGTH');
|
||||
Registry::getUtilsView()->addErrorToDisplay($message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -85,17 +86,15 @@ class AdminOrder extends AdminController
|
|||
try {
|
||||
$sms = oxNew(Sms::class, $messageBody);
|
||||
if ($sms->sendOrderMessage($order)) {
|
||||
$smsCount = $sms->getResponse() ? $sms->getResponse()->getSmsCount() : 0;
|
||||
Registry::getUtilsView()->addErrorToDisplay(
|
||||
oxNew(successfullySentException::class, $sms->getResponse()->getSmsCount())
|
||||
oxNew(successfullySentException::class, $smsCount)
|
||||
);
|
||||
} else {
|
||||
$errorMsg = $sms->getResponse() instanceof ResponseInterface ? $sms->getResponse()->getErrorMessage() : 'no response';
|
||||
Registry::getUtilsView()->addErrorToDisplay(
|
||||
sprintf(
|
||||
Registry::getLang()->translateString('D3LM_EXC_MESSAGE_UNEXPECTED_ERR_SEND'),
|
||||
$errorMsg
|
||||
)
|
||||
);
|
||||
/** @var string $format */
|
||||
$format = Registry::getLang()->translateString('D3LM_EXC_MESSAGE_UNEXPECTED_ERR_SEND');
|
||||
Registry::getUtilsView()->addErrorToDisplay(sprintf($format, $errorMsg));
|
||||
}
|
||||
} catch (noRecipientFoundException $e) {
|
||||
Registry::getUtilsView()->addErrorToDisplay($e);
|
||||
|
|
|
@ -57,24 +57,26 @@ class AdminUser extends AdminController
|
|||
try {
|
||||
return oxNew(UserRecipients::class, $this->user)->getSmsRecipient();
|
||||
} catch (noRecipientFoundException $e) {
|
||||
Registry::getUtilsView()->addErrorToDisplay(
|
||||
Registry::getLang()->translateString($e->getMessage())
|
||||
);
|
||||
/** @var string $message */
|
||||
$message = Registry::getLang()->translateString($e->getMessage());
|
||||
Registry::getUtilsView()->addErrorToDisplay($message);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function send()
|
||||
public function send(): void
|
||||
{
|
||||
/** @var string $messageBody */
|
||||
$messageBody = Registry::getRequest()->getRequestEscapedParameter('messagebody');
|
||||
|
||||
if (strlen($messageBody) <= 1) {
|
||||
Registry::getUtilsView()->addErrorToDisplay(
|
||||
Registry::getLang()->translateString('D3LM_EXC_MESSAGE_NO_LENGTH')
|
||||
);
|
||||
/** @var string $message */
|
||||
$message = Registry::getLang()->translateString('D3LM_EXC_MESSAGE_NO_LENGTH');
|
||||
Registry::getUtilsView()->addErrorToDisplay($message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -83,20 +85,15 @@ class AdminUser extends AdminController
|
|||
|
||||
$sms = oxNew(Sms::class, $messageBody);
|
||||
if ($sms->sendUserAccountMessage($user)) {
|
||||
Registry::getUtilsView()->addErrorToDisplay(
|
||||
sprintf(
|
||||
Registry::getLang()->translateString('D3LM_EXC_SMS_SUCC_SENT'),
|
||||
$sms->getResponse()->getSmsCount()
|
||||
)
|
||||
);
|
||||
/** @var string $format */
|
||||
$format = Registry::getLang()->translateString('D3LM_EXC_SMS_SUCC_SENT');
|
||||
$smsCount = $sms->getResponse() ? $sms->getResponse()->getSmsCount() : 0;
|
||||
Registry::getUtilsView()->addErrorToDisplay(sprintf($format, $smsCount));
|
||||
} else {
|
||||
$errorMsg = $sms->getResponse() instanceof ResponseInterface ? $sms->getResponse()->getErrorMessage() : 'no response';
|
||||
Registry::getUtilsView()->addErrorToDisplay(
|
||||
sprintf(
|
||||
Registry::getLang()->translateString('D3LM_EXC_MESSAGE_UNEXPECTED_ERR_SEND'),
|
||||
$errorMsg
|
||||
)
|
||||
);
|
||||
/** @var string $format */
|
||||
$format = Registry::getLang()->translateString('D3LM_EXC_MESSAGE_UNEXPECTED_ERR_SEND');
|
||||
Registry::getUtilsView()->addErrorToDisplay(sprintf($format, $errorMsg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,28 +22,30 @@ use OxidEsales\Eshop\Core\Registry;
|
|||
|
||||
class Configuration
|
||||
{
|
||||
const GENERAL_APITOKEN = "d3linkmobility_apitoken";
|
||||
const GENERAL_DEBUG = "d3linkmobility_debug";
|
||||
public const GENERAL_APITOKEN = "d3linkmobility_apitoken";
|
||||
public const GENERAL_DEBUG = "d3linkmobility_debug";
|
||||
|
||||
const ORDER_RECFIELDS = "d3linkmobility_smsOrderRecipientsFields";
|
||||
const USER_RECFIELDS = "d3linkmobility_smsUserRecipientsFields";
|
||||
public const ORDER_RECFIELDS = "d3linkmobility_smsOrderRecipientsFields";
|
||||
public const USER_RECFIELDS = "d3linkmobility_smsUserRecipientsFields";
|
||||
|
||||
const SMS_SENDERNR = "d3linkmobility_smsSenderNumber";
|
||||
const SMS_SENDERCOUNTRY = "d3linkmobility_smsSenderCountry";
|
||||
public const SMS_SENDERNR = "d3linkmobility_smsSenderNumber";
|
||||
public const SMS_SENDERCOUNTRY = "d3linkmobility_smsSenderCountry";
|
||||
|
||||
const SENDBY_ORDERED = "d3linkmobility_orderActive";
|
||||
const SENDBY_SENDEDNOW = "d3linkmobility_sendedNowActive";
|
||||
const SENDBY_CANCELED = "d3linkmobility_cancelOrderActive";
|
||||
public const SENDBY_ORDERED = "d3linkmobility_orderActive";
|
||||
public const SENDBY_SENDEDNOW = "d3linkmobility_sendedNowActive";
|
||||
public const SENDBY_CANCELED = "d3linkmobility_cancelOrderActive";
|
||||
|
||||
const ARGS_CHECKKEYS = "checkKeys";
|
||||
const ARGS_CHECKCLASS = "checkClassName";
|
||||
public const ARGS_CHECKKEYS = "checkKeys";
|
||||
public const ARGS_CHECKCLASS = "checkClassName";
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getApiToken(): string
|
||||
{
|
||||
$token = trim(Registry::getConfig()->getConfigParam(self::GENERAL_APITOKEN));
|
||||
/** @var string $token */
|
||||
$token = Registry::getConfig()->getConfigParam(self::GENERAL_APITOKEN);
|
||||
$token = trim($token);
|
||||
|
||||
Assert::that($token)->string()->notEmpty();
|
||||
|
||||
|
@ -63,7 +65,9 @@ class Configuration
|
|||
*/
|
||||
public function getSmsSenderNumber()
|
||||
{
|
||||
$number = trim(Registry::getConfig()->getConfigParam(self::SMS_SENDERNR));
|
||||
/** @var string $number */
|
||||
$number = Registry::getConfig()->getConfigParam(self::SMS_SENDERNR);
|
||||
$number = trim($number);
|
||||
|
||||
return strlen($number) ? $number : null;
|
||||
}
|
||||
|
@ -71,9 +75,11 @@ class Configuration
|
|||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSmsSenderCountry(): string
|
||||
public function getSmsSenderCountry(): ?string
|
||||
{
|
||||
$country = trim(Registry::getConfig()->getConfigParam(self::SMS_SENDERCOUNTRY));
|
||||
/** @var string $country */
|
||||
$country = Registry::getConfig()->getConfigParam(self::SMS_SENDERCOUNTRY);
|
||||
$country = trim($country);
|
||||
$country = strlen($country) ? strtoupper($country) : null;
|
||||
|
||||
Assert::that($country)->nullOr()->string()->length(2);
|
||||
|
@ -82,10 +88,11 @@ class Configuration
|
|||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function getOrderRecipientFields(): array
|
||||
{
|
||||
/** @var string[] $customFields */
|
||||
$customFields = Registry::getConfig()->getConfigParam(self::ORDER_RECFIELDS);
|
||||
|
||||
array_walk(
|
||||
|
@ -101,10 +108,11 @@ class Configuration
|
|||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function getUserRecipientFields(): array
|
||||
{
|
||||
/** @var string[] $customFields */
|
||||
$customFields = Registry::getConfig()->getConfigParam(self::USER_RECFIELDS);
|
||||
|
||||
array_walk(
|
||||
|
@ -120,12 +128,13 @@ class Configuration
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $checkPhoneFieldName
|
||||
* @param $checkCountryFieldName
|
||||
* @param $args
|
||||
* @template T
|
||||
* @param string $checkPhoneFieldName
|
||||
* @param string $checkCountryFieldName
|
||||
* @param array{checkKeys: bool, checkClassName: class-string<T>} $args
|
||||
* @return void
|
||||
*/
|
||||
protected function checkFieldExists(&$checkPhoneFieldName, $checkCountryFieldName, $args)
|
||||
protected function checkFieldExists(string &$checkPhoneFieldName, string $checkCountryFieldName, array $args): void
|
||||
{
|
||||
$checkCountryFieldName = $args[self::ARGS_CHECKKEYS] ? trim($checkCountryFieldName) : $checkCountryFieldName;
|
||||
$checkPhoneFieldName = trim($checkPhoneFieldName);
|
||||
|
|
|
@ -15,6 +15,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace D3\Linkmobility4OXID\Application\Model\Exceptions;
|
||||
|
||||
interface abortSendingExceptionInterface
|
||||
interface abortSendingExceptionInterface extends \Throwable
|
||||
{
|
||||
}
|
||||
|
|
|
@ -16,19 +16,21 @@ declare(strict_types=1);
|
|||
namespace D3\Linkmobility4OXID\Application\Model\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use OxidEsales\Eshop\Core\Exception\StandardException;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
use Throwable;
|
||||
|
||||
class successfullySentException extends Exception
|
||||
class successfullySentException extends StandardException
|
||||
{
|
||||
/**
|
||||
* @param int $messageCount
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct($messageCount = 1, $code = 0, Throwable $previous = null)
|
||||
public function __construct($messageCount = 1, $code = 0, Exception $previous = null)
|
||||
{
|
||||
$message = sprintf(Registry::getLang()->translateString('D3LM_EXC_SMS_SUCC_SENT'), $messageCount);
|
||||
/** @var string $format */
|
||||
$format = Registry::getLang()->translateString('D3LM_EXC_SMS_SUCC_SENT');
|
||||
$message = sprintf($format, $messageCount);
|
||||
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
|
|
@ -24,22 +24,24 @@ class MessageSender
|
|||
{
|
||||
/**
|
||||
* @param Order $order
|
||||
* @param $messageBody
|
||||
* @param string $messageBody
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function sendOrderFinishedMessage(Order $order, $messageBody)
|
||||
public function sendOrderFinishedMessage(Order $order, string $messageBody): void
|
||||
{
|
||||
if ((oxNew(Configuration::class))->sendOrderFinishedMessage()) {
|
||||
$this->sendMessageByOrder( $order, $messageBody);
|
||||
$this->sendMessageByOrder($order, $messageBody);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
* @param $messageBody
|
||||
* @param string $messageBody
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function sendSendedNowMessage(Order $order, $messageBody)
|
||||
public function sendSendedNowMessage(Order $order, string $messageBody): void
|
||||
{
|
||||
if ((oxNew(Configuration::class))->sendOrderSendedNowMessage()) {
|
||||
$this->sendMessageByOrder($order, $messageBody);
|
||||
|
@ -48,10 +50,11 @@ class MessageSender
|
|||
|
||||
/**
|
||||
* @param Order $order
|
||||
* @param $messageBody
|
||||
* @param string $messageBody
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function sendCancelOrderMessage(Order $order, $messageBody)
|
||||
public function sendCancelOrderMessage(Order $order, string $messageBody): void
|
||||
{
|
||||
if ((oxNew(Configuration::class))->sendOrderCanceledMessage()) {
|
||||
$this->sendMessageByOrder($order, $messageBody);
|
||||
|
@ -60,10 +63,11 @@ class MessageSender
|
|||
|
||||
/**
|
||||
* @param Order $order
|
||||
* @param $messageBody
|
||||
* @param string $messageBody
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function sendMessageByOrder(Order $order, $messageBody)
|
||||
public function sendMessageByOrder(Order $order, string $messageBody): void
|
||||
{
|
||||
if ((bool) strlen(trim($messageBody)) === false) {
|
||||
return;
|
||||
|
|
|
@ -22,13 +22,18 @@ use OxidEsales\Eshop\Application\Model\Remark;
|
|||
|
||||
abstract class AbstractMessage
|
||||
{
|
||||
const REMARK_IDENT = 'LINKMOB';
|
||||
public const REMARK_IDENT = 'LINKMOB';
|
||||
|
||||
/** @var string */
|
||||
protected $message;
|
||||
/** @var bool */
|
||||
protected $removeLineBreaks = true;
|
||||
/** @var bool */
|
||||
protected $removeMultipleSpaces = true;
|
||||
|
||||
/** @var ResponseInterface */
|
||||
protected $response;
|
||||
/** @var Recipient[] */
|
||||
protected $recipients = [];
|
||||
|
||||
/**
|
||||
|
@ -48,13 +53,14 @@ abstract class AbstractMessage
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $userId
|
||||
* @param $recipients
|
||||
* @param $message
|
||||
* @param string $userId
|
||||
* @param string $recipients
|
||||
* @param string $message
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setRemark($userId, $recipients, $message)
|
||||
protected function setRemark(string $userId, string $recipients, string $message): void
|
||||
{
|
||||
$remark = oxNew(Remark::class);
|
||||
$remark->assign([
|
||||
|
@ -74,7 +80,7 @@ abstract class AbstractMessage
|
|||
}
|
||||
|
||||
/**
|
||||
* @param array $recipients
|
||||
* @param array<Recipient> $recipients
|
||||
* @return void
|
||||
*/
|
||||
protected function setRecipients(array $recipients)
|
||||
|
@ -97,17 +103,17 @@ abstract class AbstractMessage
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $message
|
||||
* @param string $message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function sanitizeMessage($message): string
|
||||
protected function sanitizeMessage(string $message): string
|
||||
{
|
||||
$message = trim(strip_tags($message));
|
||||
$message = $this->removeLineBreaks ? str_replace(["\r", "\n"], ' ', $message) : $message;
|
||||
$regexp = '/\s{2,}/m';
|
||||
return $this->removeMultipleSpaces ? preg_replace($regexp, ' ', $message) : $message;
|
||||
return $this->removeMultipleSpaces ? (string) preg_replace($regexp, ' ', $message) : $message;
|
||||
}
|
||||
|
||||
abstract public function getTypeName() : string;
|
||||
abstract public function getTypeName(): string;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ use D3\Linkmobility4OXID\Application\Model\UserRecipients;
|
|||
use D3\LinkmobilityClient\Exceptions\ApiException;
|
||||
use D3\LinkmobilityClient\Request\RequestInterface;
|
||||
use D3\LinkmobilityClient\SMS\SmsRequestInterface;
|
||||
use D3\LinkmobilityClient\ValueObject\Recipient;
|
||||
use D3\LinkmobilityClient\ValueObject\Sender;
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
|
@ -87,7 +88,7 @@ class Sms extends AbstractMessage
|
|||
}
|
||||
|
||||
/**
|
||||
* @param array $recipientsArray
|
||||
* @param array<Recipient> $recipientsArray
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -126,16 +127,17 @@ class Sms extends AbstractMessage
|
|||
return $response->isSuccessful();
|
||||
} catch (abortSendingExceptionInterface $e) {
|
||||
Registry::getLogger()->warning($e->getMessage());
|
||||
Registry::getUtilsView()->addErrorToDisplay($e);
|
||||
// Oxid does not accept throwable interface only exceptions according by definition
|
||||
Registry::getUtilsView()->addErrorToDisplay($e->getMessage());
|
||||
} catch (GuzzleException $e) {
|
||||
Registry::getLogger()->warning($e->getMessage());
|
||||
Registry::getUtilsView()->addErrorToDisplay($e);
|
||||
Registry::getUtilsView()->addErrorToDisplay($e->getMessage());
|
||||
} catch (ApiException $e) {
|
||||
Registry::getLogger()->warning($e->getMessage());
|
||||
Registry::getUtilsView()->addErrorToDisplay($e);
|
||||
Registry::getUtilsView()->addErrorToDisplay($e->getMessage());
|
||||
} catch (InvalidArgumentException $e) {
|
||||
Registry::getLogger()->warning($e->getMessage());
|
||||
Registry::getUtilsView()->addErrorToDisplay($e);
|
||||
Registry::getUtilsView()->addErrorToDisplay($e->getMessage());
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -42,18 +42,22 @@ class OrderRecipients
|
|||
public function getSmsRecipient(): Recipient
|
||||
{
|
||||
foreach ($this->getSmsRecipientFields() as $phoneFieldName => $countryIdFieldName) {
|
||||
$content = trim((string) $this->order->getFieldData($phoneFieldName));
|
||||
$country = oxNew( Country::class );
|
||||
/** @var string $content */
|
||||
$content = $this->order->getFieldData($phoneFieldName) ?: '';
|
||||
$content = trim($content);
|
||||
$country = oxNew(Country::class);
|
||||
|
||||
try {
|
||||
if ( strlen( $content ) ) {
|
||||
$country->load( $this->order->getFieldData( $countryIdFieldName ) );
|
||||
return oxNew( Recipient::class, $content, $country->getFieldData( 'oxisoalpha2' ) );
|
||||
if (strlen($content)) {
|
||||
/** @var string $countryId */
|
||||
$countryId = $this->order->getFieldData(trim($countryIdFieldName));
|
||||
$country->load($countryId);
|
||||
return oxNew(Recipient::class, $content, $country->getFieldData('oxisoalpha2'));
|
||||
}
|
||||
} catch (NumberParseException $e) {
|
||||
LoggerHandler::getInstance()->getLogger()->info($e->getMessage(), [$content, $country->getFieldData( 'oxisoalpha2' )]);
|
||||
LoggerHandler::getInstance()->getLogger()->info($e->getMessage(), [$content, $country->getFieldData('oxisoalpha2')]);
|
||||
} catch (RecipientException $e) {
|
||||
LoggerHandler::getInstance()->getLogger()->info($e->getMessage(), [$content, $country->getFieldData( 'oxisoalpha2' )]);
|
||||
LoggerHandler::getInstance()->getLogger()->info($e->getMessage(), [$content, $country->getFieldData('oxisoalpha2')]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ class RequestFactory extends \D3\LinkmobilityClient\SMS\RequestFactory
|
|||
{
|
||||
$configuration = oxNew(Configuration::class);
|
||||
|
||||
/** @var SmsRequestInterface $request */
|
||||
$request = parent::getSmsRequest();
|
||||
$request->setTestMode($configuration->getTestMode())
|
||||
->setSenderAddress(
|
||||
|
|
|
@ -42,18 +42,22 @@ class UserRecipients
|
|||
public function getSmsRecipient(): Recipient
|
||||
{
|
||||
foreach ($this->getSmsRecipientFields() as $fieldName) {
|
||||
$content = trim($this->user->getFieldData($fieldName));
|
||||
$country = oxNew( Country::class );
|
||||
/** @var string $content */
|
||||
$content = $this->user->getFieldData($fieldName) ?: '';
|
||||
$content = trim($content);
|
||||
$country = oxNew(Country::class);
|
||||
|
||||
try {
|
||||
if ( strlen( $content ) ) {
|
||||
$country->load( $this->user->getFieldData( 'oxcountryid' ) );
|
||||
return oxNew( Recipient::class, $content, $country->getFieldData( 'oxisoalpha2' ) );
|
||||
if (strlen($content)) {
|
||||
/** @var string $countryId */
|
||||
$countryId = $this->user->getFieldData('oxcountryid');
|
||||
$country->load($countryId);
|
||||
return oxNew(Recipient::class, $content, $country->getFieldData('oxisoalpha2'));
|
||||
}
|
||||
} catch (NumberParseException $e) {
|
||||
LoggerHandler::getInstance()->getLogger()->info($e->getMessage(), [$content, $country->getFieldData( 'oxisoalpha2' )]);
|
||||
LoggerHandler::getInstance()->getLogger()->info($e->getMessage(), [$content, $country->getFieldData('oxisoalpha2')]);
|
||||
} catch (RecipientException $e) {
|
||||
LoggerHandler::getInstance()->getLogger()->info($e->getMessage(), [$content, $country->getFieldData( 'oxisoalpha2' )]);
|
||||
LoggerHandler::getInstance()->getLogger()->info($e->getMessage(), [$content, $country->getFieldData('oxisoalpha2')]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\Linkmobility4OXID\Modules\Aplication\Model {
|
||||
namespace D3\Linkmobility4OXID\Modules\Application\Model {
|
||||
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
|
||||
|
|
|
@ -17,14 +17,21 @@ namespace D3\Linkmobility4OXID\Modules\Application\Model;
|
|||
|
||||
use D3\Linkmobility4OXID\Modules\Core\EmailCore;
|
||||
use OxidEsales\Eshop\Core\Email;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
class OrderModel extends OrderModel_parent
|
||||
{
|
||||
public function cancelOrder()
|
||||
/**
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function cancelOrder(): void
|
||||
{
|
||||
parent::cancelOrder();
|
||||
|
||||
if ($this->getFieldData('oxstorno') === 1) {
|
||||
if ((bool) $this->getFieldData('oxstorno') === true) {
|
||||
/** @var EmailCore $Email */
|
||||
$Email = oxNew(Email::class);
|
||||
$Email->d3SendCancelMessage($this);
|
||||
|
|
|
@ -26,13 +26,16 @@ use Psr\Container\NotFoundExceptionInterface;
|
|||
|
||||
class EmailCore extends EmailCore_parent
|
||||
{
|
||||
/** @var string */
|
||||
protected $d3OrderCustSmsTemplate = 'd3sms_ordercust.tpl';
|
||||
/** @var string */
|
||||
protected $d3OrderSendedNowSmsTemplate = 'd3sms_sendednow.tpl';
|
||||
/** @var string */
|
||||
protected $d3OrderCanceledSmsTemplate = 'd3sms_ordercanceled.tpl';
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
* @param null $subject
|
||||
* @param string $subject
|
||||
*
|
||||
* @return bool
|
||||
* @throws ContainerExceptionInterface
|
||||
|
@ -49,7 +52,7 @@ class EmailCore extends EmailCore_parent
|
|||
|
||||
/**
|
||||
* @param Order $order
|
||||
* @param null $subject
|
||||
* @param string $subject
|
||||
*
|
||||
* @return bool
|
||||
* @throws ContainerExceptionInterface
|
||||
|
@ -67,11 +70,12 @@ class EmailCore extends EmailCore_parent
|
|||
/**
|
||||
* @param Order $order
|
||||
*
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function d3SendOrderFinishedMessageToUser(Order $order)
|
||||
public function d3SendOrderFinishedMessageToUser(Order $order): void
|
||||
{
|
||||
$messageSender = oxNew(MessageSender::class);
|
||||
$messageSender->sendOrderFinishedMessage($order, $this->d3GetOrderFinishedSmsMessageBody($order));
|
||||
|
@ -95,11 +99,12 @@ class EmailCore extends EmailCore_parent
|
|||
/**
|
||||
* @param Order $order
|
||||
*
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function d3SendedNowMessage(Order $order)
|
||||
public function d3SendedNowMessage(Order $order): void
|
||||
{
|
||||
$messageSender = oxNew(MessageSender::class);
|
||||
$messageSender->sendSendedNowMessage($order, $this->d3GetSendedNowSmsMessageBody($order));
|
||||
|
@ -121,13 +126,14 @@ class EmailCore extends EmailCore_parent
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $order
|
||||
* @param Order $order
|
||||
*
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function d3SendCancelMessage($order)
|
||||
public function d3SendCancelMessage(Order $order): void
|
||||
{
|
||||
$messageSender = oxNew(MessageSender::class);
|
||||
$messageSender->sendCancelOrderMessage($order, $this->d3GetCancelOrderSmsMessageBody($order));
|
||||
|
@ -157,6 +163,7 @@ class EmailCore extends EmailCore_parent
|
|||
*/
|
||||
protected function d3GetTplRenderer(): TemplateRendererInterface
|
||||
{
|
||||
/** @var TemplateRendererBridgeInterface $bridge */
|
||||
$bridge = ContainerFactory::getInstance()->getContainer()
|
||||
->get(TemplateRendererBridgeInterface::class);
|
||||
$bridge->setEngine($this->_getSmarty());
|
||||
|
|
|
@ -34,7 +34,7 @@ $aModule = [
|
|||
'de' => 'Anbindung der LINK Mobility API (Nachrichtenversand per SMS) an den Shop',
|
||||
'en' => 'Connection of the LINK Mobility API ( sending messages via SMS) to the shop',
|
||||
],
|
||||
'version' => '1.0.0.0',
|
||||
'version' => '1.1.0.0',
|
||||
'thumbnail' => 'picture.png',
|
||||
'author' => 'D³ Data Development (Inh.: Thomas Dartsch)',
|
||||
'email' => 'support@shopmodule.com',
|
||||
|
|
Loading…
Reference in New Issue