move Url classes, get SMS request URIs from URL class
This commit is contained in:
parent
5cbbc8295f
commit
bd9c3e6c03
@ -23,8 +23,8 @@ use D3\LinkmobilityClient\Request\RequestInterface;
|
|||||||
use D3\LinkmobilityClient\Response\Response;
|
use D3\LinkmobilityClient\Response\Response;
|
||||||
use D3\LinkmobilityClient\Response\ResponseInterface;
|
use D3\LinkmobilityClient\Response\ResponseInterface;
|
||||||
use D3\LinkmobilityClient\SMS\TextRequest;
|
use D3\LinkmobilityClient\SMS\TextRequest;
|
||||||
use D3\LinkmobilityClient\Url;
|
use D3\LinkmobilityClient\Url\Url;
|
||||||
use D3\LinkmobilityClient\UrlInterface;
|
use D3\LinkmobilityClient\Url\UrlInterface;
|
||||||
use GuzzleHttp\Client as GuzzleClient;
|
use GuzzleHttp\Client as GuzzleClient;
|
||||||
use GuzzleHttp\ClientInterface;
|
use GuzzleHttp\ClientInterface;
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
|
@ -92,6 +92,20 @@ abstract class AbstractRequest extends ApiTestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @throws ReflectionException
|
||||||
|
*/
|
||||||
|
public function testGetUri()
|
||||||
|
{
|
||||||
|
$this->assertIsString(
|
||||||
|
$this->callMethod(
|
||||||
|
$this->request,
|
||||||
|
'getUri'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
@ -228,8 +242,6 @@ abstract class AbstractRequest extends ApiTestCase
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
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;
|
use ReflectionException;
|
||||||
|
|
||||||
class UrlTest extends ApiTestCase
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
@ -18,6 +18,8 @@ namespace D3\LinkmobilityClient;
|
|||||||
use D3\LinkmobilityClient\Exceptions\ApiException;
|
use D3\LinkmobilityClient\Exceptions\ApiException;
|
||||||
use D3\LinkmobilityClient\Exceptions\ExceptionMessages;
|
use D3\LinkmobilityClient\Exceptions\ExceptionMessages;
|
||||||
use D3\LinkmobilityClient\Request\RequestInterface;
|
use D3\LinkmobilityClient\Request\RequestInterface;
|
||||||
|
use D3\LinkmobilityClient\Url\Url;
|
||||||
|
use D3\LinkmobilityClient\Url\UrlInterface;
|
||||||
use GuzzleHttp\ClientInterface;
|
use GuzzleHttp\ClientInterface;
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
@ -122,6 +122,11 @@ abstract class Request implements RequestInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public abstract function getUri(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
|
@ -17,6 +17,7 @@ namespace D3\LinkmobilityClient\SMS;
|
|||||||
|
|
||||||
use Assert\Assert;
|
use Assert\Assert;
|
||||||
use D3\LinkmobilityClient\Request\Request;
|
use D3\LinkmobilityClient\Request\Request;
|
||||||
|
use D3\LinkmobilityClient\Url\Url;
|
||||||
use D3\LinkmobilityClient\ValueObject\SmsBinaryMessage;
|
use D3\LinkmobilityClient\ValueObject\SmsBinaryMessage;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ class BinaryRequest extends Request implements SmsRequestInterface
|
|||||||
*/
|
*/
|
||||||
public function getUri(): string
|
public function getUri(): string
|
||||||
{
|
{
|
||||||
return '/rest/smsmessaging/binary';
|
return (new Url())->getBinarySmsUri();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRawBody(): array
|
public function getRawBody(): array
|
||||||
|
@ -17,6 +17,7 @@ namespace D3\LinkmobilityClient\SMS;
|
|||||||
|
|
||||||
use Assert\Assert;
|
use Assert\Assert;
|
||||||
use D3\LinkmobilityClient\Request\Request;
|
use D3\LinkmobilityClient\Request\Request;
|
||||||
|
use D3\LinkmobilityClient\Url\Url;
|
||||||
use D3\LinkmobilityClient\ValueObject\SmsTextMessage;
|
use D3\LinkmobilityClient\ValueObject\SmsTextMessage;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ class TextRequest extends Request implements SmsRequestInterface
|
|||||||
*/
|
*/
|
||||||
public function getUri(): string
|
public function getUri(): string
|
||||||
{
|
{
|
||||||
return '/rest/smsmessaging/text';
|
return (new Url())->getTextSmsUri();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient;
|
namespace D3\LinkmobilityClient\Url;
|
||||||
|
|
||||||
class Url implements UrlInterface
|
class Url implements UrlInterface
|
||||||
{
|
{
|
||||||
@ -26,4 +26,20 @@ class Url implements UrlInterface
|
|||||||
{
|
{
|
||||||
return $this->baseUri;
|
return $this->baseUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTextSmsUri()
|
||||||
|
{
|
||||||
|
return '/rest/smsmessaging/text';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBinarySmsUri()
|
||||||
|
{
|
||||||
|
return '/rest/smsmessaging/binary';
|
||||||
|
}
|
||||||
}
|
}
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient;
|
namespace D3\LinkmobilityClient\Url;
|
||||||
|
|
||||||
interface UrlInterface
|
interface UrlInterface
|
||||||
{
|
{
|
Loading…
x
Reference in New Issue
Block a user