Skip to content

Commit

Permalink
feature #35688 [Notifier] Simplify OVH implementation (fabpot)
Browse files Browse the repository at this point in the history
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
-------

39f9ac2 [Notifier] Simplify OVH implementation
  • Loading branch information
fabpot committed Feb 12, 2020
2 parents 5150fc5 + 39f9ac2 commit 3fb89ef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
Expand Up @@ -26,9 +26,7 @@
*/
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;
Expand All @@ -45,13 +43,6 @@ public function __construct(string $applicationKey, string $applicationSecret, s
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);
Expand All @@ -68,7 +59,7 @@ protected function doSend(MessageInterface $message): void
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',
Expand Down
Expand Up @@ -34,7 +34,7 @@ public function create(Dsn $dsn): TransportInterface
$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());
Expand Down

0 comments on commit 3fb89ef

Please sign in to comment.