From 39f9ac26209dcfde0cd3d1e54b03186cb0b3a5a1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 12 Feb 2020 17:24:01 +0100 Subject: [PATCH] [Notifier] Simplify OVH implementation --- .../Notifier/Bridge/OvhCloud/OvhCloudTransport.php | 13 ++----------- .../Bridge/OvhCloud/OvhCloudTransportFactory.php | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php b/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php index 5bf4816c89..6b5e24b622 100644 --- a/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php @@ -26,9 +26,7 @@ use Symfony\Contracts\HttpClient\HttpClientInterface; */ final class OvhCloudTransport extends AbstractTransport { - private $endpoints = [ - 'ovh-eu' => 'https://eu.api.ovh.com/1.0', - ]; + protected const HOST = 'eu.api.ovh.com'; private $applicationKey; private $applicationSecret; @@ -45,13 +43,6 @@ final class OvhCloudTransport extends AbstractTransport parent::__construct($client, $dispatcher); } - public function setEndpointName(?string $endpoint): self - { - $this->host = $this->endpoints[$endpoint] ?: self::HOST; - - return $this; - } - public function __toString(): string { return sprintf('ovhcloud://%s?consumer_key=%s&service_name=%s', $this->getEndpoint(), $this->consumerKey, $this->serviceName); @@ -68,7 +59,7 @@ final class OvhCloudTransport extends AbstractTransport throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, \get_class($message))); } - $endpoint = sprintf('%s/sms/%s/jobs', $this->getEndpoint(), $this->serviceName); + $endpoint = sprintf('https://%s/1.0/sms/%s/jobs', $this->getEndpoint(), $this->serviceName); $content = [ 'charset' => 'UTF-8', diff --git a/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransportFactory.php index 2fde78bcac..84d30a50df 100644 --- a/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransportFactory.php +++ b/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransportFactory.php @@ -34,7 +34,7 @@ final class OvhCloudTransportFactory extends AbstractTransportFactory $port = $dsn->getPort(); if ('ovhcloud' === $scheme) { - return (new OvhCloudTransport($applicationKey, $applicationSecret, $consumerKey, $serviceName, $this->client, $this->dispatcher))->setEndpointName($host)->setPort($port); + return (new OvhCloudTransport($applicationKey, $applicationSecret, $consumerKey, $serviceName, $this->client, $this->dispatcher))->setHost($host)->setPort($port); } throw new UnsupportedSchemeException($dsn, 'ovhcloud', $this->getSupportedSchemes());