feature #35688 [Notifier] Simplify OVH implementation (fabpot)

This PR was merged into the 5.1-dev branch.

Discussion
----------

[Notifier] Simplify OVH implementation

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | n/a <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | n/a <!-- required for new features -->
<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/roadmap):
 - Always add tests and ensure they pass.
 - Never break backward compatibility (see https://symfony.com/bc).
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too.)
 - Features and deprecations must be submitted against branch master.
-->

Commits
-------

39f9ac2620 [Notifier] Simplify OVH implementation
This commit is contained in:
Fabien Potencier 2020-02-12 17:30:07 +01:00
commit 3fb89ef179
2 changed files with 3 additions and 12 deletions

View File

@ -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',

View File

@ -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());