Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
1d5ccb6d73
|
|||
4f3b1029f4
|
|||
f4d5e54448
|
|||
4cd0ab0d17
|
|||
1a9389d763
|
|||
491c260870
|
|||
50d2276a78
|
@ -6,7 +6,7 @@ $finder = PhpCsFixer\Finder::create()
|
||||
|
||||
$config = new PhpCsFixer\Config();
|
||||
return $config->setRules([
|
||||
'@PHP73Migration' => true,
|
||||
'@PHP70Migration' => true,
|
||||
'@PSR12' => true
|
||||
])
|
||||
->setFinder($finder)
|
||||
|
58
CHANGELOG.md
58
CHANGELOG.md
@ -1,48 +1,56 @@
|
||||
# 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).
|
||||
|
||||
## 2.0.0.0 (2022-07-19)
|
||||
## [Unreleased](https://git.d3data.de/D3Private/linkmobility-php-client/compare/1.3.2...rel_1.x)
|
||||
|
||||
- adjust to PHP >= 7.3 and current dependency packages
|
||||
## [1.3.2](https://git.d3data.de/D3Private/linkmobility-php-client/compare/1.3.1...1.3.2) - 2022-07-28
|
||||
### Changed
|
||||
- add support note
|
||||
- adjust readme
|
||||
|
||||
---
|
||||
## [1.3.1](https://git.d3data.de/D3Private/linkmobility-php-client/compare/1.3.0...1.3.1) - 2022-07-28
|
||||
### Changed
|
||||
- improve code quality
|
||||
|
||||
## 1.3.0.0 (2022-07-18)
|
||||
### Fixed
|
||||
- wrong return type of LoggerHandler::getInstance
|
||||
|
||||
- tests use generated example phone numbers
|
||||
- move recipient checks from list to recipient itself
|
||||
## [1.3.0](https://git.d3data.de/D3Private/linkmobility-php-client/compare/1.2.1...1.3.0) - 2022-07-18
|
||||
### Added
|
||||
- tests added
|
||||
|
||||
---
|
||||
|
||||
## 1.2.1.0 (2022-07-15)
|
||||
### Changed
|
||||
- tests use generated example phone numbers
|
||||
- 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
|
||||
- sanitize special phone number format before request
|
||||
|
||||
---
|
||||
|
||||
## 1.2.0.0 (2022-07-14)
|
||||
|
||||
- make sender number optional
|
||||
- assign sender address type only if sender is set
|
||||
## [1.2.0](https://git.d3data.de/D3Private/linkmobility-php-client/compare/1.1.0...1.2.0) - 2022-07-14
|
||||
### Added
|
||||
- collect exception messages 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
|
||||
|
||||
---
|
||||
|
||||
## 1.1.0.0 (2022-07-13)
|
||||
|
||||
## [1.1.0](https://git.d3data.de/D3Private/linkmobility-php-client/compare/1.0.0...1.1.0) - 2022-07-13
|
||||
### Added
|
||||
- make installable in PHP 8
|
||||
|
||||
### Removed
|
||||
- remove unused dependency
|
||||
|
||||
---
|
||||
|
||||
## 1.0.0.0 (2022-07-13)
|
||||
|
||||
## [1.0.0](https://git.d3data.de/D3Private/linkmobility-php-client/releases/tag/1.0.0) - 2022-07-13
|
||||
### Added
|
||||
- initial implementation
|
||||
- SMS requests (text or binary)
|
||||
- SMS responses
|
||||
- recipient managing
|
||||
- recipient managing
|
||||
|
@ -1,7 +1,7 @@
|
||||
[](README.md)
|
||||
[](README.en.md)
|
||||
|
||||
# LINK Mobility Austria PHP API Client
|
||||
# LINK Mobility PHP API Client
|
||||
|
||||
[LINK Mobility](https://www.linkmobility.de/) provides a service for sending mobile messages (SMS, Whatsapp, RCS, Chatbot, ...).
|
||||
|
||||
@ -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)
|
||||
- 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)
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
[](README.md)
|
||||
[](README.en.md)
|
||||
|
||||
# LINK Mobility Austria PHP API Client
|
||||
# LINK Mobility PHP API Client
|
||||
|
||||
[LINK Mobility](https://www.linkmobility.de/) stellt einen Service zum Versenden von mobilen Nachrichten (SMS, Whatsapp, RCS, Chatbot, ...) zur VerfĂĽgung.
|
||||
|
||||
@ -39,6 +39,12 @@ Wenn Sie eine Verbesserungsvorschlag haben, legen Sie einen Fork des Respoitorie
|
||||
- Ăś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)
|
||||
|
||||
|
@ -96,7 +96,7 @@ class ClientTest extends ApiTestCase
|
||||
return [
|
||||
'api key only' => ['apiKey', null, null],
|
||||
'all without client' => ['apiKey', new Url(), null],
|
||||
'all arguments' => ['apiKey', new Url(), new GuzzleClient()],
|
||||
'all arguments' => ['apiKey', new Url(), new GuzzleClient()]
|
||||
];
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ class ClientTest extends ApiTestCase
|
||||
{
|
||||
return [
|
||||
'request is valid' => [true],
|
||||
'request is not valid' => [false],
|
||||
'request is not valid' => [false]
|
||||
];
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ class ClientTest extends ApiTestCase
|
||||
'withHeader',
|
||||
'withAddedHeader',
|
||||
'withoutHeader',
|
||||
'withBody',
|
||||
'withBody'
|
||||
])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
@ -232,7 +232,7 @@ class ClientTest extends ApiTestCase
|
||||
$clientMock = $this->getMockBuilder(Client::class)
|
||||
->disableOriginalConstructor()
|
||||
->onlyMethods([
|
||||
'getLoggerHandler',
|
||||
'getLoggerHandler'
|
||||
])
|
||||
->getMock();
|
||||
$clientMock->expects($this->atLeastOnce())
|
||||
|
@ -167,7 +167,7 @@ class RecipientsListTest extends ApiTestCase
|
||||
$this->assertSame(
|
||||
[
|
||||
$this->phoneNumberFixture,
|
||||
$this->phoneNumberFixture,
|
||||
$this->phoneNumberFixture
|
||||
],
|
||||
$this->callMethod(
|
||||
$this->recipientsList,
|
||||
@ -280,7 +280,7 @@ class RecipientsListTest extends ApiTestCase
|
||||
$this->recipientsList,
|
||||
'recipients',
|
||||
[
|
||||
'fixture' => new stdClass(),
|
||||
'fixture' => new stdClass()
|
||||
]
|
||||
);
|
||||
|
||||
@ -333,11 +333,11 @@ class RecipientsListTest extends ApiTestCase
|
||||
$recipientMock = $this->getMockBuilder(Recipient::class)
|
||||
->onlyMethods([
|
||||
'get',
|
||||
'getCountryCode',
|
||||
'getCountryCode'
|
||||
])
|
||||
->setConstructorArgs([
|
||||
$this->phoneNumberFixture,
|
||||
$this->phoneCountryFixture,
|
||||
$this->phoneCountryFixture
|
||||
])
|
||||
->getMock();
|
||||
$recipientMock->method('get')->willReturn($this->phoneNumberFixture);
|
||||
@ -347,11 +347,11 @@ class RecipientsListTest extends ApiTestCase
|
||||
$recipientMock2 = $this->getMockBuilder(Recipient::class)
|
||||
->onlyMethods([
|
||||
'get',
|
||||
'getCountryCode',
|
||||
'getCountryCode'
|
||||
])
|
||||
->setConstructorArgs([
|
||||
$this->phoneNumberFixture,
|
||||
$this->phoneCountryFixture,
|
||||
$this->phoneCountryFixture
|
||||
])
|
||||
->getMock();
|
||||
$recipientMock2->method('get')->willReturn($this->phoneNumberFixture);
|
||||
@ -359,7 +359,7 @@ class RecipientsListTest extends ApiTestCase
|
||||
|
||||
$list = [
|
||||
'fixture' => $recipientMock,
|
||||
'fixture2' => $recipientMock2,
|
||||
'fixture2' => $recipientMock2
|
||||
];
|
||||
|
||||
$this->setValue(
|
||||
|
@ -17,7 +17,6 @@ namespace D3\LinkmobilityClient\Tests\Request;
|
||||
|
||||
use Assert\InvalidArgumentException;
|
||||
use D3\LinkmobilityClient\Client;
|
||||
use D3\LinkmobilityClient\Exceptions\RecipientException;
|
||||
use D3\LinkmobilityClient\RecipientsList\RecipientsListInterface;
|
||||
use D3\LinkmobilityClient\Request\Request;
|
||||
use D3\LinkmobilityClient\Request\RequestInterface;
|
||||
@ -25,7 +24,6 @@ use D3\LinkmobilityClient\SMS\Response;
|
||||
use D3\LinkmobilityClient\Tests\ApiTestCase;
|
||||
use D3\LinkmobilityClient\ValueObject\Recipient;
|
||||
use D3\LinkmobilityClient\ValueObject\Sender;
|
||||
use libphonenumber\NumberParseException;
|
||||
use libphonenumber\PhoneNumberFormat;
|
||||
use libphonenumber\PhoneNumberType;
|
||||
use libphonenumber\PhoneNumberUtil;
|
||||
@ -117,13 +115,10 @@ abstract class AbstractRequest extends ApiTestCase
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::validate
|
||||
* @covers \D3\LinkmobilityClient\SMS\TextRequest::validate
|
||||
* @covers \D3\LinkmobilityClient\Request\Request::validate
|
||||
* @return void
|
||||
* @throws ReflectionException
|
||||
* @throws RecipientException
|
||||
* @throws NumberParseException
|
||||
*/
|
||||
public function validatePassedTest()
|
||||
{
|
||||
@ -154,12 +149,9 @@ abstract class AbstractRequest extends ApiTestCase
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::validate
|
||||
* @covers \D3\LinkmobilityClient\SMS\TextRequest::validate
|
||||
* @return void
|
||||
* @throws NumberParseException
|
||||
* @throws RecipientException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function validateFailedTest()
|
||||
{
|
||||
@ -261,17 +253,17 @@ abstract class AbstractRequest extends ApiTestCase
|
||||
['json' => [
|
||||
'contentCategory' => 'informational',
|
||||
'messageContent' => 'messageContent',
|
||||
'priority' => 0,
|
||||
]],
|
||||
'priority' => 0
|
||||
]]
|
||||
],
|
||||
'other' => [
|
||||
'other',
|
||||
[
|
||||
'contentCategory' => 'informational',
|
||||
'messageContent' => 'messageContent',
|
||||
'priority' => 0,
|
||||
],
|
||||
],
|
||||
'priority' => 0
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@ -292,20 +284,20 @@ abstract class AbstractRequest extends ApiTestCase
|
||||
['json' => [
|
||||
'contentCategory' => 'informational',
|
||||
'messageContent' => 'messageContent',
|
||||
'priority' => 0,
|
||||
'priority' => 0
|
||||
]]
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
['headers' => [
|
||||
'Accept' => 'application/json',
|
||||
'Content-Type' => 'application/json',
|
||||
'Content-Type' => 'application/json'
|
||||
],
|
||||
'json' => [
|
||||
'contentCategory' => 'informational',
|
||||
'messageContent' => 'messageContent',
|
||||
'priority' => 0,
|
||||
], ],
|
||||
'priority' => 0
|
||||
]],
|
||||
$this->callMethod(
|
||||
$requestMock,
|
||||
'getOptions'
|
||||
@ -679,7 +671,7 @@ abstract class AbstractRequest extends ApiTestCase
|
||||
/** @var StreamInterface|MockObject $streamMock */
|
||||
$streamMock = $this->getMockBuilder(StreamInterface::class)
|
||||
->onlyMethods(['getContents', '__toString', 'close', 'detach', 'getSize', 'tell', 'eof', 'isSeekable',
|
||||
'seek', 'rewind', 'isWritable', 'write', 'isReadable', 'read', 'getMetadata', ])
|
||||
'seek', 'rewind', 'isWritable', 'write', 'isReadable', 'read', 'getMetadata'])
|
||||
->getMock();
|
||||
$streamMock->method('getContents')->willReturn('{}');
|
||||
|
||||
@ -688,12 +680,12 @@ abstract class AbstractRequest extends ApiTestCase
|
||||
->onlyMethods([
|
||||
'getBody', 'getStatusCode', 'withStatus', 'getReasonphrase', 'getProtocolVersion',
|
||||
'withProtocolVersion', 'getHeaders', 'hasHeader', 'getHeader', 'getHeaderLine',
|
||||
'withHeader', 'withAddedHeader', 'withoutHeader', 'withBody', ])
|
||||
'withHeader', 'withAddedHeader', 'withoutHeader', 'withBody'])
|
||||
->getMock();
|
||||
$rawResponseMock->method('getBody')->willReturn($streamMock);
|
||||
|
||||
return [
|
||||
'SMS Response' => [$rawResponseMock],
|
||||
'SMS Response' => [$rawResponseMock]
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ abstract class AbstractResponse extends ApiTestCase
|
||||
/** @var StreamInterface|MockObject $streamMock */
|
||||
$streamMock = $this->getMockBuilder(StreamInterface::class)
|
||||
->onlyMethods(['getContents', '__toString', 'close', 'detach', 'getSize', 'tell', 'eof', 'isSeekable',
|
||||
'seek', 'rewind', 'isWritable', 'write', 'isReadable', 'read', 'getMetadata', ])
|
||||
'seek', 'rewind', 'isWritable', 'write', 'isReadable', 'read', 'getMetadata'])
|
||||
->getMock();
|
||||
$streamMock->expects($this->atLeastOnce())->method('getContents')->willReturn(
|
||||
'{
|
||||
@ -53,7 +53,7 @@ abstract class AbstractResponse extends ApiTestCase
|
||||
->onlyMethods([
|
||||
'getBody', 'getStatusCode', 'withStatus', 'getReasonphrase', 'getProtocolVersion',
|
||||
'withProtocolVersion', 'getHeaders', 'hasHeader', 'getHeader', 'getHeaderLine',
|
||||
'withHeader', 'withAddedHeader', 'withoutHeader', 'withBody', ])
|
||||
'withHeader', 'withAddedHeader', 'withoutHeader', 'withBody'])
|
||||
->getMock();
|
||||
$rawResponseMock->method('getBody')->willReturn($streamMock);
|
||||
|
||||
@ -226,7 +226,7 @@ abstract class AbstractResponse extends ApiTestCase
|
||||
{
|
||||
return [
|
||||
'successful' => [true, ''],
|
||||
'not successful'=> [false, 'fixtureMessage'],
|
||||
'not successful'=> [false, 'fixtureMessage']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -100,8 +100,8 @@ class RequestFactoryTest extends ApiTestCase
|
||||
public function getTextSmsRequestDataProvider(): array
|
||||
{
|
||||
return [
|
||||
'binary' => [SmsLength::ENCODING_UCS2, BinaryRequest::class],
|
||||
'ascii' => [SmsLength::ENCODING_7BIT, TextRequest::class],
|
||||
'binary' => [RequestFactory::GSM_UCS2, BinaryRequest::class],
|
||||
'ascii' => [RequestFactory::GSM_7BIT, TextRequest::class]
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ class RecipientTest extends ApiTestCase
|
||||
'invalid country code' => [$phoneNumberFixture, 'DEX', true, PhoneNumberType::MOBILE, InvalidArgumentException::class],
|
||||
'unparsable' => ['abc', 'DE', true, PhoneNumberType::MOBILE, NumberParseException::class],
|
||||
'invalid number' => ['abcd', 'DE', false, PhoneNumberType::MOBILE, RecipientException::class],
|
||||
'not mobile number' => ['abcd', 'DE', true, PhoneNumberType::FIXED_LINE, RecipientException::class],
|
||||
'not mobile number' => ['abcd', 'DE', true, PhoneNumberType::FIXED_LINE, RecipientException::class]
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
namespace D3\LinkmobilityClient\Tests\ValueObject;
|
||||
|
||||
use Assert\InvalidArgumentException;
|
||||
use D3\LinkmobilityClient\Exceptions\NoSenderDefinedException;
|
||||
use D3\LinkmobilityClient\Exceptions\RecipientException;
|
||||
use D3\LinkmobilityClient\Tests\ApiTestCase;
|
||||
use D3\LinkmobilityClient\ValueObject\Sender;
|
||||
@ -111,7 +112,7 @@ class SenderTest extends ApiTestCase
|
||||
return [
|
||||
'null number' => [null, $this->phoneCountryFixture, false],
|
||||
'null country' => [$this->phoneNumberFixture, null, false],
|
||||
'all values' => [$this->phoneNumberFixture, $this->phoneCountryFixture, true],
|
||||
'all values' => [$this->phoneNumberFixture, $this->phoneCountryFixture, true]
|
||||
];
|
||||
}
|
||||
|
||||
@ -121,9 +122,11 @@ class SenderTest extends ApiTestCase
|
||||
* @param $country
|
||||
* @param $validNumber
|
||||
* @param $expectedException
|
||||
* @throws ReflectionException
|
||||
*
|
||||
* @throws NumberParseException
|
||||
* @throws RecipientException
|
||||
* @dataProvider constructInvalidDataProvider
|
||||
* @covers \D3\LinkmobilityClient\ValueObject\Sender::__construct
|
||||
* @covers \D3\LinkmobilityClient\ValueObject\Sender::__construct
|
||||
*/
|
||||
public function testConstructInvalid($number, $country, $validNumber, $expectedException)
|
||||
{
|
||||
@ -171,7 +174,7 @@ class SenderTest extends ApiTestCase
|
||||
'empty number' => ['', 'DE', true, InvalidArgumentException::class],
|
||||
'invalid country code' => [$phoneNumberFixture, 'DEX', true, InvalidArgumentException::class],
|
||||
'unparsable' => ['abc', 'DE', true, NumberParseException::class],
|
||||
'invalid number' => ['abcd', 'DE', false, RecipientException::class],
|
||||
'invalid number' => ['abcd', 'DE', false, RecipientException::class]
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ class SmsBinaryMessageTest extends ApiTestCase
|
||||
{
|
||||
return [
|
||||
'empty message' => ['', true, InvalidArgumentException::class],
|
||||
'invalid sms message' => ['abc', false, \Phlib\SmsLength\Exception\InvalidArgumentException::class],
|
||||
'invalid sms message' => ['abc', false, \Phlib\SmsLength\Exception\InvalidArgumentException::class]
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -16,8 +16,13 @@ declare(strict_types=1);
|
||||
namespace D3\LinkmobilityClient\Tests\ValueObject;
|
||||
|
||||
use Assert\InvalidArgumentException;
|
||||
use D3\LinkmobilityClient\Exceptions\NoSenderDefinedException;
|
||||
use D3\LinkmobilityClient\Exceptions\RecipientException;
|
||||
use D3\LinkmobilityClient\Tests\ApiTestCase;
|
||||
use D3\LinkmobilityClient\ValueObject\Sender;
|
||||
use D3\LinkmobilityClient\ValueObject\ValueObject;
|
||||
use libphonenumber\NumberParseException;
|
||||
use libphonenumber\PhoneNumber;
|
||||
use libphonenumber\PhoneNumberFormat;
|
||||
use libphonenumber\PhoneNumberType;
|
||||
use libphonenumber\PhoneNumberUtil;
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "d3/linkmobility-php-client",
|
||||
"type": "library",
|
||||
"description": "PHP client for LINK Mobility Austria API",
|
||||
"description": "PHP client for LINK Mobility API",
|
||||
"keywords": [
|
||||
"LINK Mobility",
|
||||
"php",
|
||||
@ -21,18 +21,18 @@
|
||||
"GPL-3.0-or-later"
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.3 || ^8.0",
|
||||
"beberlei/assert": "^3.3",
|
||||
"guzzlehttp/guzzle": "^7.4",
|
||||
"php": "^7.0 || ^8.0",
|
||||
"beberlei/assert": "^2.9.9",
|
||||
"guzzlehttp/guzzle": "~6.2 || ^7.4",
|
||||
"psr/http-message": "~1.0",
|
||||
"phlib/sms-length": "^2.0",
|
||||
"phlib/sms-length": "^1.1.0 || ^2.0.0",
|
||||
"giggsey/libphonenumber-for-php": "^8.12.50",
|
||||
"ext-json": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"php": "^7.4",
|
||||
"phpunit/phpunit" : "^9.5",
|
||||
"friendsofphp/php-cs-fixer": "^3.9"
|
||||
"php": "^7.2",
|
||||
"phpunit/phpunit" : "^8.0",
|
||||
"friendsofphp/php-cs-fixer": "^2.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
40
phpunit.xml
40
phpunit.xml
@ -1,20 +1,22 @@
|
||||
<?xml version="1.0"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
bootstrap="vendor/autoload.php"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
|
||||
<coverage>
|
||||
<include>
|
||||
<directory suffix=".php">src</directory>
|
||||
</include>
|
||||
<report>
|
||||
<clover outputFile="build/logs/clover.xml"/>
|
||||
</report>
|
||||
</coverage>
|
||||
<testsuite name="linkmobility">
|
||||
<directory>./Tests</directory>
|
||||
</testsuite>
|
||||
<logging/>
|
||||
|
||||
<phpunit
|
||||
bootstrap="vendor/autoload.php"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true">
|
||||
|
||||
<testsuite name="linkmobility">
|
||||
<directory>./Tests</directory>
|
||||
</testsuite>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
||||
<logging>
|
||||
<log type="coverage-clover" target="build/logs/clover.xml"/>
|
||||
</logging>
|
||||
|
||||
</phpunit>
|
||||
|
@ -20,10 +20,14 @@ use Psr\Log\NullLogger;
|
||||
|
||||
class LoggerHandler
|
||||
{
|
||||
/** @var LoggerHandler */
|
||||
private static $instance = null;
|
||||
private $logger;
|
||||
|
||||
public static function getInstance(): ?LoggerHandler
|
||||
/**
|
||||
* @return LoggerHandler
|
||||
*/
|
||||
public static function getInstance(): LoggerHandler
|
||||
{
|
||||
if (self::$instance === null) {
|
||||
self::$instance = new self();
|
||||
|
@ -169,7 +169,7 @@ abstract class Request implements RequestInterface
|
||||
'senderAddress' => $this->getSenderAddress() ? $this->getSenderAddress()->getFormatted() : null,
|
||||
'senderAddressType' => $this->getSenderAddressType(),
|
||||
'test' => $this->getTestMode(),
|
||||
'validityPeriode' => $this->getValidityPeriode(),
|
||||
'validityPeriode' => $this->getValidityPeriode()
|
||||
];
|
||||
}
|
||||
|
||||
@ -200,7 +200,7 @@ abstract class Request implements RequestInterface
|
||||
'headers' => [
|
||||
'Accept' => $this->contentType,
|
||||
'Content-Type' => $this->contentType,
|
||||
],
|
||||
]
|
||||
],
|
||||
$this->getBody()
|
||||
);
|
||||
@ -280,7 +280,7 @@ abstract class Request implements RequestInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getClientMessageId(): ?string
|
||||
public function getClientMessageId()
|
||||
{
|
||||
return $this->clientMessageId;
|
||||
}
|
||||
@ -306,7 +306,7 @@ abstract class Request implements RequestInterface
|
||||
{
|
||||
return [
|
||||
RequestInterface::CONTENTCATEGORY_ADVERTISEMENT => RequestInterface::CONTENTCATEGORY_ADVERTISEMENT,
|
||||
RequestInterface::CONTENTCATEGORY_INFORMATIONAL => RequestInterface::CONTENTCATEGORY_INFORMATIONAL,
|
||||
RequestInterface::CONTENTCATEGORY_INFORMATIONAL => RequestInterface::CONTENTCATEGORY_INFORMATIONAL
|
||||
];
|
||||
}
|
||||
|
||||
@ -376,7 +376,7 @@ abstract class Request implements RequestInterface
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getNotificationCallbackUrl(): ?string
|
||||
public function getNotificationCallbackUrl()
|
||||
{
|
||||
return $this->notificationCallbackUrl;
|
||||
}
|
||||
@ -396,7 +396,7 @@ abstract class Request implements RequestInterface
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getPriority(): ?int
|
||||
public function getPriority()
|
||||
{
|
||||
return $this->priority;
|
||||
}
|
||||
@ -444,7 +444,7 @@ abstract class Request implements RequestInterface
|
||||
/**
|
||||
* @return Sender|null
|
||||
*/
|
||||
public function getSenderAddress(): ?Sender
|
||||
public function getSenderAddress()
|
||||
{
|
||||
return $this->senderAddress;
|
||||
}
|
||||
@ -464,7 +464,7 @@ abstract class Request implements RequestInterface
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSenderAddressType(): ?string
|
||||
public function getSenderAddressType()
|
||||
{
|
||||
return $this->getSenderAddress() && $this->getSenderAddress()->get() ? $this->senderAddressType : null;
|
||||
}
|
||||
@ -478,7 +478,7 @@ abstract class Request implements RequestInterface
|
||||
RequestInterface::SENDERADDRESSTYPE_ALPHANUMERIC => RequestInterface::SENDERADDRESSTYPE_ALPHANUMERIC,
|
||||
RequestInterface::SENDERADDRESSTYPE_INTERNATIONAL => RequestInterface::SENDERADDRESSTYPE_INTERNATIONAL,
|
||||
RequestInterface::SENDERADDRESSTYPE_NATIONAL => RequestInterface::SENDERADDRESSTYPE_NATIONAL,
|
||||
RequestInterface::SENDERADDRESSTYPE_SHORTCODE => RequestInterface::SENDERADDRESSTYPE_SHORTCODE,
|
||||
RequestInterface::SENDERADDRESSTYPE_SHORTCODE => RequestInterface::SENDERADDRESSTYPE_SHORTCODE
|
||||
];
|
||||
}
|
||||
|
||||
@ -497,7 +497,7 @@ abstract class Request implements RequestInterface
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getValidityPeriode(): ?int
|
||||
public function getValidityPeriode()
|
||||
{
|
||||
return $this->validityPeriode;
|
||||
}
|
||||
@ -523,7 +523,6 @@ abstract class Request implements RequestInterface
|
||||
|
||||
/**
|
||||
* @param Client $client
|
||||
* @return Request
|
||||
*/
|
||||
public function setClient(Client $client): Request
|
||||
{
|
||||
|
@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
namespace D3\LinkmobilityClient\Request;
|
||||
|
||||
use D3\LinkmobilityClient\Client;
|
||||
use D3\LinkmobilityClient\RecipientsList\RecipientsListInterface;
|
||||
use D3\LinkmobilityClient\ValueObject\SmsMessageInterface;
|
||||
use InvalidArgumentException;
|
||||
use Psr\Http\Message\ResponseInterface as PsrResponseInterface;
|
||||
@ -42,9 +43,18 @@ interface RequestInterface
|
||||
public const SENDERADDRESSTYPE_ALPHANUMERIC = 'alphanumeric';
|
||||
public const SENDERADDRESSTYPE_SHORTCODE = 'shortcode';
|
||||
|
||||
/**
|
||||
* @param SmsMessageInterface $message
|
||||
* @param 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
|
||||
@ -53,6 +63,18 @@ interface RequestInterface
|
||||
*/
|
||||
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
|
||||
*
|
||||
@ -81,6 +103,11 @@ interface RequestInterface
|
||||
*/
|
||||
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)
|
||||
*
|
||||
|
@ -72,7 +72,7 @@ abstract class Response implements ResponseInterface
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getClientMessageId(): ?string
|
||||
public function getClientMessageId()
|
||||
{
|
||||
return $this->getContent()[self::CLIENTMESSAGEID];
|
||||
}
|
||||
@ -80,13 +80,13 @@ abstract class Response implements ResponseInterface
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTransferId(): ?string
|
||||
public function getTransferId()
|
||||
{
|
||||
return $this->getContent()[self::TRANSFERID];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSmsCount(): int
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ class BinaryRequest extends Request implements SmsRequestInterface
|
||||
return array_merge(
|
||||
parent::getRawBody(),
|
||||
[
|
||||
'userDataHeaderPresent' => true,
|
||||
'userDataHeaderPresent' => true
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -20,15 +20,21 @@ use D3\LinkmobilityClient\ValueObject\SmsBinaryMessage;
|
||||
use D3\LinkmobilityClient\ValueObject\SmsTextMessage;
|
||||
use Phlib\SmsLength\SmsLength;
|
||||
|
||||
class RequestFactory implements RequestFactoryInterface
|
||||
class RequestFactory
|
||||
{
|
||||
/**
|
||||
* @deprecated is SmsLength constant from version 2.1
|
||||
*/
|
||||
public const GSM_7BIT = '7-bit';
|
||||
|
||||
/**
|
||||
* @deprecated is SmsLength constant from version 2.1
|
||||
*/
|
||||
public const GSM_UCS2 = 'ucs-2';
|
||||
|
||||
protected $message;
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @param $message
|
||||
* @param Client $client
|
||||
*/
|
||||
public function __construct($message, Client $client)
|
||||
{
|
||||
$this->message = $message;
|
||||
@ -40,7 +46,7 @@ class RequestFactory implements RequestFactoryInterface
|
||||
*/
|
||||
public function getSmsRequest(): SmsRequestInterface
|
||||
{
|
||||
if ($this->getSmsLength()->getEncoding() === SmsLength::ENCODING_7BIT) {
|
||||
if ($this->getSmsLength()->getEncoding() === self::GSM_7BIT) {
|
||||
$message = new SmsTextMessage($this->message);
|
||||
return new TextRequest($message, $this->client);
|
||||
}
|
||||
|
@ -15,11 +15,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace D3\LinkmobilityClient\SMS;
|
||||
|
||||
use D3\LinkmobilityClient\Client;
|
||||
|
||||
interface RequestFactoryInterface
|
||||
{
|
||||
public function __construct($message, Client $client);
|
||||
public function __construct($message);
|
||||
|
||||
public function getSmsRequest(): SmsRequestInterface;
|
||||
public function getRequest(): SmsRequestInterface;
|
||||
}
|
||||
|
@ -15,8 +15,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace D3\LinkmobilityClient\SMS;
|
||||
|
||||
use D3\LinkmobilityClient\Response\Response as BaseResponse;
|
||||
|
||||
class Response extends BaseResponse
|
||||
class Response extends \D3\LinkmobilityClient\Response\Response
|
||||
{
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class Url implements UrlInterface
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTextSmsUri(): string
|
||||
public function getTextSmsUri()
|
||||
{
|
||||
return '/rest/smsmessaging/text';
|
||||
}
|
||||
@ -38,7 +38,7 @@ class Url implements UrlInterface
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBinarySmsUri(): string
|
||||
public function getBinarySmsUri()
|
||||
{
|
||||
return '/rest/smsmessaging/binary';
|
||||
}
|
||||
|
@ -18,8 +18,4 @@ namespace D3\LinkmobilityClient\Url;
|
||||
interface UrlInterface
|
||||
{
|
||||
public function getBaseUri(): string;
|
||||
|
||||
public function getTextSmsUri(): string;
|
||||
|
||||
public function getBinarySmsUri(): string;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class Recipient extends StringValueObject
|
||||
*/
|
||||
protected $allowedNumberTypes = [
|
||||
PhoneNumberType::MOBILE,
|
||||
PhoneNumberType::FIXED_LINE_OR_MOBILE,
|
||||
PhoneNumberType::FIXED_LINE_OR_MOBILE
|
||||
];
|
||||
|
||||
/**
|
||||
@ -86,7 +86,7 @@ class Recipient extends StringValueObject
|
||||
return $this->countryCode;
|
||||
}
|
||||
|
||||
public function getFormatted(): string
|
||||
public function getFormatted()
|
||||
{
|
||||
return ltrim(parent::getFormatted(), '+');
|
||||
}
|
||||
|
@ -27,11 +27,11 @@ use libphonenumber\PhoneNumberUtil;
|
||||
class Sender extends ValueObject
|
||||
{
|
||||
/**
|
||||
* @param string|null $number
|
||||
* @param string|null $iso2CountryCode
|
||||
* @param string $number
|
||||
* @param string $iso2CountryCode
|
||||
*
|
||||
* @throws NumberParseException
|
||||
* @throws RecipientException
|
||||
* @throws NumberParseException
|
||||
*/
|
||||
public function __construct(string $number = null, string $iso2CountryCode = null)
|
||||
{
|
||||
@ -67,7 +67,7 @@ class Sender extends ValueObject
|
||||
return PhoneNumberUtil::getInstance();
|
||||
}
|
||||
|
||||
public function getFormatted(): string
|
||||
public function getFormatted()
|
||||
{
|
||||
return ltrim(parent::getFormatted(), '+');
|
||||
}
|
||||
|
@ -43,9 +43,6 @@ abstract class SmsMessageAbstract extends StringValueObject implements SmsMessag
|
||||
return $this->getSmsLength()->getSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMessageContent()
|
||||
{
|
||||
return $this->get();
|
||||
|
@ -15,6 +15,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace D3\LinkmobilityClient\ValueObject;
|
||||
|
||||
use Assert\Assert;
|
||||
|
||||
abstract class StringValueObject extends ValueObject
|
||||
{
|
||||
public function __toString()
|
||||
|
@ -33,7 +33,7 @@ abstract class ValueObject
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function getFormatted(): string
|
||||
public function getFormatted()
|
||||
{
|
||||
return $this->get();
|
||||
}
|
||||
|
Reference in New Issue
Block a user