move Url classes, get SMS request URIs from URL class

This commit is contained in:
Daniel Seifert 2022-07-14 11:54:08 +02:00
parent 5cbbc8295f
commit bd9c3e6c03
Signed by: DanielS
GPG Key ID: 8A7C4C6ED1915C6F
9 changed files with 78 additions and 10 deletions

View File

@ -23,8 +23,8 @@ use D3\LinkmobilityClient\Request\RequestInterface;
use D3\LinkmobilityClient\Response\Response;
use D3\LinkmobilityClient\Response\ResponseInterface;
use D3\LinkmobilityClient\SMS\TextRequest;
use D3\LinkmobilityClient\Url;
use D3\LinkmobilityClient\UrlInterface;
use D3\LinkmobilityClient\Url\Url;
use D3\LinkmobilityClient\Url\UrlInterface;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\ClientInterface;
use PHPUnit\Framework\MockObject\MockObject;

View File

@ -92,6 +92,20 @@ abstract class AbstractRequest extends ApiTestCase
);
}
/**
* @test
* @throws ReflectionException
*/
public function testGetUri()
{
$this->assertIsString(
$this->callMethod(
$this->request,
'getUri'
)
);
}
/**
* @test
* @throws ReflectionException
@ -228,8 +242,6 @@ abstract class AbstractRequest extends ApiTestCase
];
}
/**
* @test
* @throws ReflectionException

View File

@ -13,9 +13,10 @@
declare(strict_types=1);
namespace D3\LinkmobilityClient\Tests;
namespace D3\LinkmobilityClient\Tests\Url;
use D3\LinkmobilityClient\Url;
use D3\LinkmobilityClient\Tests\ApiTestCase;
use D3\LinkmobilityClient\Url\Url;
use ReflectionException;
class UrlTest extends ApiTestCase
@ -58,4 +59,34 @@ class UrlTest extends ApiTestCase
)
);
}
/**
* @test
* @throws ReflectionException
*/
public function testGetTextSmsUri()
{
$uri = $this->callMethod(
$this->url,
'getTextSmsUri'
);
$this->assertIsString($uri);
$this->assertStringStartsWith('/', $uri);
}
/**
* @test
* @throws ReflectionException
*/
public function testGetBinarySmsUri()
{
$uri = $this->callMethod(
$this->url,
'getBinarySmsUri'
);
$this->assertIsString($uri);
$this->assertStringStartsWith('/', $uri);
}
}

View File

@ -18,6 +18,8 @@ namespace D3\LinkmobilityClient;
use D3\LinkmobilityClient\Exceptions\ApiException;
use D3\LinkmobilityClient\Exceptions\ExceptionMessages;
use D3\LinkmobilityClient\Request\RequestInterface;
use D3\LinkmobilityClient\Url\Url;
use D3\LinkmobilityClient\Url\UrlInterface;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\GuzzleException;
use InvalidArgumentException;

View File

@ -122,6 +122,11 @@ abstract class Request implements RequestInterface
return $this;
}
/**
* @return string
*/
public abstract function getUri(): string;
/**
* @throws InvalidArgumentException
*/

View File

@ -17,6 +17,7 @@ namespace D3\LinkmobilityClient\SMS;
use Assert\Assert;
use D3\LinkmobilityClient\Request\Request;
use D3\LinkmobilityClient\Url\Url;
use D3\LinkmobilityClient\ValueObject\SmsBinaryMessage;
use InvalidArgumentException;
@ -27,7 +28,7 @@ class BinaryRequest extends Request implements SmsRequestInterface
*/
public function getUri(): string
{
return '/rest/smsmessaging/binary';
return (new Url())->getBinarySmsUri();
}
public function getRawBody(): array

View File

@ -17,6 +17,7 @@ namespace D3\LinkmobilityClient\SMS;
use Assert\Assert;
use D3\LinkmobilityClient\Request\Request;
use D3\LinkmobilityClient\Url\Url;
use D3\LinkmobilityClient\ValueObject\SmsTextMessage;
use InvalidArgumentException;
@ -27,7 +28,7 @@ class TextRequest extends Request implements SmsRequestInterface
*/
public function getUri(): string
{
return '/rest/smsmessaging/text';
return (new Url())->getTextSmsUri();
}
/**

View File

@ -13,7 +13,7 @@
declare(strict_types=1);
namespace D3\LinkmobilityClient;
namespace D3\LinkmobilityClient\Url;
class Url implements UrlInterface
{
@ -26,4 +26,20 @@ class Url implements UrlInterface
{
return $this->baseUri;
}
/**
* @return string
*/
public function getTextSmsUri()
{
return '/rest/smsmessaging/text';
}
/**
* @return string
*/
public function getBinarySmsUri()
{
return '/rest/smsmessaging/binary';
}
}

View File

@ -13,7 +13,7 @@
declare(strict_types=1);
namespace D3\LinkmobilityClient;
namespace D3\LinkmobilityClient\Url;
interface UrlInterface
{