add configuration registry
Dieser Commit ist enthalten in:
Ursprung
18d9748e64
Commit
8411ed0786
@ -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];
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren