Add Ovh Soap Support
This commit is contained in:
parent
fdde9b5bfa
commit
8503e34961
@ -33,12 +33,18 @@ class Configuration implements ConfigurationInterface
|
||||
->booleanNode('verbose_curl')
|
||||
->defaultFalse()
|
||||
->end()
|
||||
->scalarNode('sms_account_id')
|
||||
->defaultFalse()
|
||||
->end()
|
||||
->scalarNode('username')
|
||||
->isRequired()
|
||||
->end()
|
||||
->scalarNode('password')
|
||||
->isRequired()
|
||||
->end()
|
||||
->scalarNode('from')
|
||||
->isRequired()
|
||||
->end()
|
||||
->end();
|
||||
|
||||
return $treeBuilder;
|
||||
|
@ -28,5 +28,7 @@ class GergelyPolonkaiSmsSenderExtension extends Extension
|
||||
$container->setParameter('verbose_curl', $config['verbose_curl']);
|
||||
$container->setParameter('username', $config['username']);
|
||||
$container->setParameter('password', $config['password']);
|
||||
$container->setParameter('sms_account_id', $config['sms_account_id']);
|
||||
$container->setParameter('from', $config['from']);
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,15 @@
|
||||
|
||||
<parameters>
|
||||
<parameter key="gergely_polonkai_sms_sender.sender.class">GergelyPolonkai\SmsSenderBundle\Service\Sender</parameter>
|
||||
<parameter key="gergely_polonkai_sms_sender.ovhSoapSender.class">GergelyPolonkai\SmsSenderBundle\Service\OvhSoapSender</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="gergely_polonkai_sms_sender.sender" class="%gergely_polonkai_sms_sender.sender.class%">
|
||||
<argument type="service" id="service_container" />
|
||||
</service>
|
||||
<service id="gergely_polonkai_sms_sender.ovhSoapSender" class="%gergely_polonkai_sms_sender.ovhSoapSender.class%">
|
||||
<argument type="service" id="service_container" />
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
58
Service/OvhSoapSender.php
Normal file
58
Service/OvhSoapSender.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
namespace GergelyPolonkai\SmsSenderBundle\Service;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use RuntimeException;
|
||||
use GergelyPolonkai\SmsSender\OvhSoapSender as BaseSender;
|
||||
|
||||
/**
|
||||
* @author Gergely Polonkai
|
||||
*
|
||||
* SMS Sending service for OVH Soap based SMS Sender server
|
||||
*/
|
||||
class OvhSoapSender
|
||||
{
|
||||
private $loggedIn;
|
||||
|
||||
private $sender;
|
||||
|
||||
/**
|
||||
* @var Symfony\Component\DependencyInjection\ContainerInterface $container
|
||||
*/
|
||||
private $container;
|
||||
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
|
||||
$this->sender = new BaseSender(
|
||||
$this->container->getParameter('sender_url'),
|
||||
$this->container->getParameter('sms_account_id'),
|
||||
$this->container->getParameter('from'));
|
||||
}
|
||||
|
||||
public function login()
|
||||
{
|
||||
if ($this->sender->login($this->container->getParameter('username'), $this->container->getParameter('password'))){
|
||||
$this->loggedIn = true;
|
||||
} else {
|
||||
throw new \RuntimeException('Unable to login to gateway!');
|
||||
}
|
||||
}
|
||||
|
||||
public function sendMessage($recipient, $message, array $passwordLocations)
|
||||
{
|
||||
if (!$this->loggedIn) {
|
||||
return false;
|
||||
}
|
||||
$this->sender->sendMessage($recipient, $message, $passwordLocations);
|
||||
}
|
||||
|
||||
public function logout()
|
||||
{
|
||||
if (!$this->loggedIn) {
|
||||
return false;
|
||||
}
|
||||
$this->sender->logout();
|
||||
}
|
||||
}
|
@ -3,12 +3,12 @@ namespace GergelyPolonkai\SmsSenderBundle\Service;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use RuntimeException;
|
||||
use GergelyPolonkai\SmsSender\Sender as BaseSender;
|
||||
use GergelyPolonkai\SmsSender\OvhSoapSender as BaseSender;
|
||||
|
||||
/**
|
||||
* @author Gergely Polonkai
|
||||
*
|
||||
* SMS Sending service for JSON-RPC based SMS Sender server
|
||||
* SMS Sending service for OVH Soap based SMS Sender server
|
||||
*/
|
||||
class Sender
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user