linkmobility4oxid/src/Application/Model/RequestFactory.php

63 lines
1.9 KiB
PHP
Raw Normal View History

2022-07-04 09:13:36 +02:00
<?php
/**
2022-07-13 13:21:52 +02:00
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
2022-07-04 09:13:36 +02:00
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
2022-07-13 13:21:52 +02:00
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link https://www.oxidmodule.com
2022-07-04 09:13:36 +02:00
*/
2022-07-13 13:21:52 +02:00
declare(strict_types=1);
2022-07-04 16:33:49 +02:00
namespace D3\Linkmobility4OXID\Application\Model;
2022-07-04 09:13:36 +02:00
use D3\LinkmobilityClient\Exceptions\RecipientException;
2022-07-04 09:13:36 +02:00
use D3\LinkmobilityClient\Request\RequestInterface;
use D3\LinkmobilityClient\SMS\SmsRequestInterface;
use D3\LinkmobilityClient\ValueObject\Sender;
2023-01-04 23:08:05 +01:00
use D3\TestingTools\Production\IsMockable;
use libphonenumber\NumberParseException;
2022-07-04 09:13:36 +02:00
class RequestFactory extends \D3\LinkmobilityClient\SMS\RequestFactory
{
2023-01-04 23:08:05 +01:00
use IsMockable;
/**
* @return SmsRequestInterface
* @throws NumberParseException
* @throws RecipientException
*/
2022-07-04 09:13:36 +02:00
public function getSmsRequest(): SmsRequestInterface
{
2023-01-04 23:08:05 +01:00
/** @var Configuration $configuration */
$configuration = d3GetOxidDIC()->get(Configuration::class);
/** parent call */
2023-01-10 23:33:48 +01:00
/** @var SmsRequestInterface $request */
2023-01-04 23:08:05 +01:00
$request = $this->d3CallMockableFunction([\D3\LinkmobilityClient\SMS\RequestFactory::class, 'getSmsRequest']);
2022-07-04 09:13:36 +02:00
2023-01-15 22:24:49 +01:00
$sender = $this->getSender((string) $configuration->getSmsSenderNumber(), (string) $configuration->getSmsSenderCountry());
2022-07-04 09:13:36 +02:00
$request->setTestMode($configuration->getTestMode())
2023-01-10 23:33:48 +01:00
->setSenderAddress($sender)
2022-07-13 13:23:48 +02:00
->setSenderAddressType(RequestInterface::SENDERADDRESSTYPE_INTERNATIONAL);
2022-07-04 09:13:36 +02:00
return $request;
}
/**
* @param string $number
* @param string $countryCode
* @throws NumberParseException
* @throws RecipientException
* @return Sender
*/
protected function getSender(string $number, string $countryCode): Sender
{
return oxNew(Sender::class, $number, $countryCode);
}
2022-07-13 13:23:48 +02:00
}