Compare commits
8 Commits
Author | SHA1 | Date |
---|---|---|
Daniel Seifert | 4f3b1029f4 | |
Daniel Seifert | f4d5e54448 | |
Daniel Seifert | 4cd0ab0d17 | |
Daniel Seifert | 1a9389d763 | |
Daniel Seifert | 491c260870 | |
Daniel Seifert | 50d2276a78 | |
Daniel Seifert | b22da1bd4a | |
Daniel Seifert | 95b95d1d8b |
53
CHANGELOG.md
53
CHANGELOG.md
|
@ -1,42 +1,51 @@
|
||||||
# Changelog
|
# 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.3.0.0 (2022-07-18)
|
## [Unreleased](https://git.d3data.de/D3Private/linkmobility-php-client/compare/1.3.1...rel_1.x)
|
||||||
|
|
||||||
- tests use generated example phone numbers
|
## [1.3.1](https://git.d3data.de/D3Private/linkmobility-php-client/compare/1.3.0...1.3.1) - 2022-07-28
|
||||||
- move recipient checks from list to recipient itself
|
### Changed
|
||||||
|
- improve code quality
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- wrong return type of LoggerHandler::getInstance
|
||||||
|
|
||||||
|
## [1.3.0](https://git.d3data.de/D3Private/linkmobility-php-client/compare/1.2.1...1.3.0) - 2022-07-18
|
||||||
|
### Added
|
||||||
- tests added
|
- tests added
|
||||||
|
|
||||||
---
|
### Changed
|
||||||
|
- tests use generated example phone numbers
|
||||||
## 1.2.1.0 (2022-07-15)
|
- move recipient checks from list to recipient itself
|
||||||
|
|
||||||
|
## [1.2.1](https://git.d3data.de/D3Private/linkmobility-php-client/compare/1.2.0...1.2.1) - 2022-07-15
|
||||||
|
### Changed
|
||||||
- extend log messages
|
- extend log messages
|
||||||
- sanitize special phone number format before request
|
- sanitize special phone number format before request
|
||||||
|
|
||||||
---
|
## [1.2.0](https://git.d3data.de/D3Private/linkmobility-php-client/compare/1.1.0...1.2.0) - 2022-07-14
|
||||||
|
### Added
|
||||||
## 1.2.0.0 (2022-07-14)
|
|
||||||
|
|
||||||
- make sender number optional
|
|
||||||
- assign sender address type only if sender is set
|
|
||||||
- collect exception messages in a class
|
- collect exception messages in a class
|
||||||
- collect URI parts in a class
|
- collect URI parts in a class
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- make sender number optional
|
||||||
|
- assign sender address type only if sender is set
|
||||||
- extract logger handler from client
|
- extract logger handler from client
|
||||||
|
|
||||||
---
|
## [1.1.0](https://git.d3data.de/D3Private/linkmobility-php-client/compare/1.0.0...1.1.0) - 2022-07-13
|
||||||
|
### Added
|
||||||
## 1.1.0.0 (2022-07-13)
|
|
||||||
|
|
||||||
- make installable in PHP 8
|
- make installable in PHP 8
|
||||||
|
|
||||||
|
### Removed
|
||||||
- remove unused dependency
|
- remove unused dependency
|
||||||
|
|
||||||
---
|
## [1.0.0](https://git.d3data.de/D3Private/linkmobility-php-client/releases/tag/1.0.0) - 2022-07-13
|
||||||
|
### Added
|
||||||
## 1.0.0.0 (2022-07-13)
|
|
||||||
|
|
||||||
- initial implementation
|
- initial implementation
|
||||||
- SMS requests (text or binary)
|
- SMS requests (text or binary)
|
||||||
- SMS responses
|
- SMS responses
|
||||||
- recipient managing
|
- recipient managing
|
||||||
|
|
|
@ -39,6 +39,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)
|
- Push to the Branch (git push origin feature/AmazingFeature)
|
||||||
- Open a Pull Request
|
- 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
|
## License
|
||||||
(status: 2022-07-13)
|
(status: 2022-07-13)
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,12 @@ Wenn Sie eine Verbesserungsvorschlag haben, legen Sie einen Fork des Respoitorie
|
||||||
- Ăśbertragen Sie den Branch (git push origin feature/AmazingFeature)
|
- Ăśbertragen Sie den Branch (git push origin feature/AmazingFeature)
|
||||||
- Ă–ffnen Sie einen Pull Request
|
- Ă–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
|
## Lizenz
|
||||||
(Stand: 13.07.2022)
|
(Stand: 13.07.2022)
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ class RecipientsListTest extends ApiTestCase
|
||||||
|
|
||||||
$phoneUtil = PhoneNumberUtil::getInstance();
|
$phoneUtil = PhoneNumberUtil::getInstance();
|
||||||
$example = $phoneUtil->getExampleNumberForType($this->phoneCountryFixture, PhoneNumberType::MOBILE);
|
$example = $phoneUtil->getExampleNumberForType($this->phoneCountryFixture, PhoneNumberType::MOBILE);
|
||||||
$this->phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
|
$this->phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -124,7 +124,7 @@ abstract class AbstractRequest extends ApiTestCase
|
||||||
{
|
{
|
||||||
$phoneUtil = PhoneNumberUtil::getInstance();
|
$phoneUtil = PhoneNumberUtil::getInstance();
|
||||||
$example = $phoneUtil->getExampleNumberForType('DE', PhoneNumberType::MOBILE);
|
$example = $phoneUtil->getExampleNumberForType('DE', PhoneNumberType::MOBILE);
|
||||||
$phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
|
$phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
|
||||||
|
|
||||||
$recipient = new Recipient($phoneNumberFixture, 'DE');
|
$recipient = new Recipient($phoneNumberFixture, 'DE');
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ abstract class AbstractRequest extends ApiTestCase
|
||||||
{
|
{
|
||||||
$phoneUtil = PhoneNumberUtil::getInstance();
|
$phoneUtil = PhoneNumberUtil::getInstance();
|
||||||
$example = $phoneUtil->getExampleNumberForType('DE', PhoneNumberType::MOBILE);
|
$example = $phoneUtil->getExampleNumberForType('DE', PhoneNumberType::MOBILE);
|
||||||
$phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
|
$phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
|
||||||
|
|
||||||
$recipient = new Recipient($phoneNumberFixture, 'DE');
|
$recipient = new Recipient($phoneNumberFixture, 'DE');
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ class RecipientTest extends ApiTestCase
|
||||||
|
|
||||||
$phoneUtil = PhoneNumberUtil::getInstance();
|
$phoneUtil = PhoneNumberUtil::getInstance();
|
||||||
$example = $phoneUtil->getExampleNumberForType($this->phoneCountryFixture, PhoneNumberType::MOBILE);
|
$example = $phoneUtil->getExampleNumberForType($this->phoneCountryFixture, PhoneNumberType::MOBILE);
|
||||||
$this->phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
|
$this->phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
|
||||||
|
|
||||||
$this->recipient = new Recipient($this->phoneNumberFixture, $this->phoneCountryFixture);
|
$this->recipient = new Recipient($this->phoneNumberFixture, $this->phoneCountryFixture);
|
||||||
}
|
}
|
||||||
|
@ -155,14 +155,14 @@ class RecipientTest extends ApiTestCase
|
||||||
{
|
{
|
||||||
$phoneUtil = PhoneNumberUtil::getInstance();
|
$phoneUtil = PhoneNumberUtil::getInstance();
|
||||||
$example = $phoneUtil->getExampleNumberForType($this->phoneCountryFixture, PhoneNumberType::MOBILE);
|
$example = $phoneUtil->getExampleNumberForType($this->phoneCountryFixture, PhoneNumberType::MOBILE);
|
||||||
$phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
|
$phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'empty number' => ['', 'DE', true, PhoneNumberType::MOBILE, InvalidArgumentException::class],
|
'empty number' => ['', 'DE', true, PhoneNumberType::MOBILE, InvalidArgumentException::class],
|
||||||
'invalid country code' => [$phoneNumberFixture, 'DEX', true, PhoneNumberType::MOBILE, InvalidArgumentException::class],
|
'invalid country code' => [$phoneNumberFixture, 'DEX', true, PhoneNumberType::MOBILE, InvalidArgumentException::class],
|
||||||
'unparsable' => ['abc', 'DE', true, PhoneNumberType::MOBILE, NumberParseException::class],
|
'unparsable' => ['abc', 'DE', true, PhoneNumberType::MOBILE, NumberParseException::class],
|
||||||
'invalid number' => ['abcd', 'DE', false, PhoneNumberType::MOBILE, RecipientException::class],
|
'invalid number' => ['abcd', 'DE', false, PhoneNumberType::MOBILE, RecipientException::class],
|
||||||
'not mobile number' => ['abcd', 'DE', false, PhoneNumberType::FIXED_LINE, RecipientException::class]
|
'not mobile number' => ['abcd', 'DE', true, PhoneNumberType::FIXED_LINE, RecipientException::class]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ class SenderTest extends ApiTestCase
|
||||||
|
|
||||||
$phoneUtil = PhoneNumberUtil::getInstance();
|
$phoneUtil = PhoneNumberUtil::getInstance();
|
||||||
$example = $phoneUtil->getExampleNumberForType($this->phoneCountryFixture, PhoneNumberType::MOBILE);
|
$example = $phoneUtil->getExampleNumberForType($this->phoneCountryFixture, PhoneNumberType::MOBILE);
|
||||||
$this->phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
|
$this->phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
|
||||||
|
|
||||||
/** @var Sender|MockObject sender */
|
/** @var Sender|MockObject sender */
|
||||||
$this->sender = new Sender($this->phoneNumberFixture, $this->phoneCountryFixture);
|
$this->sender = new Sender($this->phoneNumberFixture, $this->phoneCountryFixture);
|
||||||
|
@ -107,7 +107,7 @@ class SenderTest extends ApiTestCase
|
||||||
{
|
{
|
||||||
$phoneUtil = PhoneNumberUtil::getInstance();
|
$phoneUtil = PhoneNumberUtil::getInstance();
|
||||||
$example = $phoneUtil->getExampleNumberForType($this->phoneCountryFixture, PhoneNumberType::MOBILE);
|
$example = $phoneUtil->getExampleNumberForType($this->phoneCountryFixture, PhoneNumberType::MOBILE);
|
||||||
$this->phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
|
$this->phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'null number' => [null, $this->phoneCountryFixture, false],
|
'null number' => [null, $this->phoneCountryFixture, false],
|
||||||
|
@ -168,7 +168,7 @@ class SenderTest extends ApiTestCase
|
||||||
{
|
{
|
||||||
$phoneUtil = PhoneNumberUtil::getInstance();
|
$phoneUtil = PhoneNumberUtil::getInstance();
|
||||||
$example = $phoneUtil->getExampleNumberForType($this->phoneCountryFixture, PhoneNumberType::MOBILE);
|
$example = $phoneUtil->getExampleNumberForType($this->phoneCountryFixture, PhoneNumberType::MOBILE);
|
||||||
$phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
|
$phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'empty number' => ['', 'DE', true, InvalidArgumentException::class],
|
'empty number' => ['', 'DE', true, InvalidArgumentException::class],
|
||||||
|
|
|
@ -52,7 +52,7 @@ class ValueObjectTest extends ApiTestCase
|
||||||
{
|
{
|
||||||
$phoneUtil = PhoneNumberUtil::getInstance();
|
$phoneUtil = PhoneNumberUtil::getInstance();
|
||||||
$example = $phoneUtil->getExampleNumberForType('DE', PhoneNumberType::MOBILE);
|
$example = $phoneUtil->getExampleNumberForType('DE', PhoneNumberType::MOBILE);
|
||||||
$phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
|
$phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
|
||||||
|
|
||||||
$this->callMethod(
|
$this->callMethod(
|
||||||
$this->value,
|
$this->value,
|
||||||
|
@ -85,4 +85,4 @@ class ValueObjectTest extends ApiTestCase
|
||||||
['']
|
['']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,10 +20,14 @@ use Psr\Log\NullLogger;
|
||||||
|
|
||||||
class LoggerHandler
|
class LoggerHandler
|
||||||
{
|
{
|
||||||
|
/** @var LoggerHandler */
|
||||||
private static $instance = null;
|
private static $instance = null;
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
public static function getInstance()
|
/**
|
||||||
|
* @return LoggerHandler
|
||||||
|
*/
|
||||||
|
public static function getInstance(): LoggerHandler
|
||||||
{
|
{
|
||||||
if (self::$instance === null) {
|
if (self::$instance === null) {
|
||||||
self::$instance = new self();
|
self::$instance = new self();
|
||||||
|
|
|
@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||||
namespace D3\LinkmobilityClient\Request;
|
namespace D3\LinkmobilityClient\Request;
|
||||||
|
|
||||||
use D3\LinkmobilityClient\Client;
|
use D3\LinkmobilityClient\Client;
|
||||||
|
use D3\LinkmobilityClient\RecipientsList\RecipientsListInterface;
|
||||||
use D3\LinkmobilityClient\ValueObject\SmsMessageInterface;
|
use D3\LinkmobilityClient\ValueObject\SmsMessageInterface;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Psr\Http\Message\ResponseInterface as PsrResponseInterface;
|
use Psr\Http\Message\ResponseInterface as PsrResponseInterface;
|
||||||
|
@ -42,9 +43,18 @@ interface RequestInterface
|
||||||
public const SENDERADDRESSTYPE_ALPHANUMERIC = 'alphanumeric';
|
public const SENDERADDRESSTYPE_ALPHANUMERIC = 'alphanumeric';
|
||||||
public const SENDERADDRESSTYPE_SHORTCODE = 'shortcode';
|
public const SENDERADDRESSTYPE_SHORTCODE = 'shortcode';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param SmsMessageInterface $message
|
||||||
|
* @param Client $client
|
||||||
|
*/
|
||||||
public function __construct(SmsMessageInterface $message, Client $client);
|
public function __construct(SmsMessageInterface $message, Client $client);
|
||||||
|
|
||||||
public function setMethod(string $method);
|
/**
|
||||||
|
* @param string $method
|
||||||
|
*
|
||||||
|
* @return Request
|
||||||
|
*/
|
||||||
|
public function setMethod(string $method): Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Must return the HTTP verb for this request, i.e. GET, POST, PUT
|
* Must return the HTTP verb for this request, i.e. GET, POST, PUT
|
||||||
|
@ -53,6 +63,18 @@ interface RequestInterface
|
||||||
*/
|
*/
|
||||||
public function getMethod(): string;
|
public function getMethod(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $test
|
||||||
|
*
|
||||||
|
* @return Request
|
||||||
|
*/
|
||||||
|
public function setTestMode(bool $test): Request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getTestMode(): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Must return the URI for the request with a leading slash, i.e. /messages.json
|
* Must return the URI for the request with a leading slash, i.e. /messages.json
|
||||||
*
|
*
|
||||||
|
@ -81,6 +103,11 @@ interface RequestInterface
|
||||||
*/
|
*/
|
||||||
public function getResponseInstance(PsrResponseInterface $rawResponse): LMResponseInterface;
|
public function getResponseInstance(PsrResponseInterface $rawResponse): LMResponseInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return RecipientsListInterface
|
||||||
|
*/
|
||||||
|
public function getRecipientsList(): RecipientsListInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Must return the options for this request. If there are none, return [] (empty array)
|
* Must return the options for this request. If there are none, return [] (empty array)
|
||||||
*
|
*
|
||||||
|
|
|
@ -53,7 +53,7 @@ class Recipient extends StringValueObject
|
||||||
$phoneUtil = $this->getPhoneNumberUtil();
|
$phoneUtil = $this->getPhoneNumberUtil();
|
||||||
|
|
||||||
$phoneNumber = $phoneUtil->parse($number, strtoupper($iso2CountryCode));
|
$phoneNumber = $phoneUtil->parse($number, strtoupper($iso2CountryCode));
|
||||||
$number = $phoneUtil->format( $phoneNumber, PhoneNumberFormat::E164 );
|
$number = $phoneUtil->format($phoneNumber, PhoneNumberFormat::E164);
|
||||||
|
|
||||||
if (false === $phoneUtil->isValidNumber($phoneNumber)) {
|
if (false === $phoneUtil->isValidNumber($phoneNumber)) {
|
||||||
throw new RecipientException(ExceptionMessages::INVALID_RECIPIENT_PHONE);
|
throw new RecipientException(ExceptionMessages::INVALID_RECIPIENT_PHONE);
|
||||||
|
@ -63,9 +63,9 @@ class Recipient extends StringValueObject
|
||||||
$this->allowedNumberTypes
|
$this->allowedNumberTypes
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
throw new RecipientException( ExceptionMessages::NOT_A_MOBILE_NUMBER);
|
throw new RecipientException(ExceptionMessages::NOT_A_MOBILE_NUMBER);
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::__construct($number);
|
parent::__construct($number);
|
||||||
$this->countryCode = $iso2CountryCode;
|
$this->countryCode = $iso2CountryCode;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue