diff --git a/src/Client.php b/src/Client.php index eb01996..bfae017 100644 --- a/src/Client.php +++ b/src/Client.php @@ -20,8 +20,10 @@ namespace D3\LinkmobilityClient; use D3\LinkmobilityClient\Exceptions\ApiException; use D3\LinkmobilityClient\Exceptions\ExceptionMessages; use D3\LinkmobilityClient\Request\RequestInterface; +use D3\LinkmobilityClient\ValueObject\ValueObject; use GuzzleHttp\Exception\GuzzleException; use InvalidArgumentException; +use phpDocumentor\Reflection\Types\Mixed_; use Psr\Http\Message\ResponseInterface; use Psr\Log\LoggerInterface; use RuntimeException; @@ -33,6 +35,7 @@ class Client public $requestClient; private $logger; + private $configuration = []; public function __construct(string $accessToken, $apiUrl = false, $client = false) { @@ -125,4 +128,35 @@ class Client return $this->logger; } + /** + * @param string $name + * @param $configuration + * + * @return $this + */ + public function setConfiguration( string $name, $configuration ): Client + { + $this->configuration[$name] = oxNew(ValueObject::class, $configuration); + + return $this; + } + + public function hasConfiguration(string $name) + { + return isset($this->configuration[$name]); + } + + /** + * @param string $name + * + * @return mixed + */ + public function getConfiguration(string $name) + { + if (false === isset($this->configuration)) { + throw new InvalidArgumentException('configuration '.$name.' is not set'); + } + + return $this->configuration[$name]; + } } \ No newline at end of file diff --git a/src/Request/Request.php b/src/Request/Request.php index f5b2e92..0681c4c 100644 --- a/src/Request/Request.php +++ b/src/Request/Request.php @@ -137,7 +137,7 @@ abstract class Request implements RequestInterface Assert::that($this->getOptions())->isArray(); Assert::that( $this->getRecipientsList() )->isInstanceOf(RecipientsList::class)->notEmpty(); - Assert::that( $this->getRecipientsList()->getRecipients())->notEmpty('request must contain a recipient'); + Assert::that( $this->getRecipientsList()->getRecipients())->notEmpty('request must contain a valid recipient'); Assert::thatAll( $this->getRecipientsList() )->isInstanceOf( Recipient::class )->notEmpty(); // optional properties diff --git a/src/SMS/RequestFactory.php b/src/SMS/RequestFactory.php index c604e6f..4778ee5 100644 --- a/src/SMS/RequestFactory.php +++ b/src/SMS/RequestFactory.php @@ -35,8 +35,8 @@ class RequestFactory */ const GSM_UCS2 = 'ucs-2'; - private $message; - private $client; + protected $message; + protected $client; public function __construct($message, Client $client) {