Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanbarlog committed Jun 8, 2017
0 parents commit 05c7d75
Show file tree
Hide file tree
Showing 12 changed files with 538 additions and 0 deletions.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Everlution SendinBlue SMS Bundle

## Installation

### Step 1: Download the Bundle


```console
$ composer require everlutionsk/sendin-blue-sms-bundle
```

### Step 2: Enable the Bundle

```php
<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...

new Everlution\SendinBlueSmsBundle\EverlutionSendinBlueSmsBundle(),
);

// ...
}

// ...
}
```

## Configuration

coming soon

## Usage

coming soon

## TODO

coming soon
22 changes: 22 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "everlutionsk/sendin-blue-sms-bundle",
"description": "Everlution SendinBlue SMS Bundle for Symfony framework",
"keywords": ["email", "symfony", "everlution", "bundle", "sendinblue", "sms"],
"type": "symfony-bundle",
"autoload": {
"psr-4": {
"Everlution\\SendinBlueSmsBundle\\": "src/"
}
},
"require": {
"php": "^7.0",
"symfony/http-kernel": "^3.2",
"symfony/config": "^3.2",
"symfony/dependency-injection": "^3.2",
"mailin-api/mailin-api-php": "^1.0"
},
"license": "MIT",
"authors": [
{"name": "Martin Adamik", "email": "[email protected]"}
]
}
31 changes: 31 additions & 0 deletions src/DependencyInjection/Compiler/SmsSystemCompilerPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace Everlution\SendinBlueSmsBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

/**
* @author Martin Adamik <[email protected]>
*/
class SmsSystemCompilerPass implements CompilerPassInterface
{

public function process(ContainerBuilder $container)
{
$this->registerOutboundSmsTransformers($container, $container->getDefinition('everlution.sendin_blue_sms.sms_system'));
}

protected function registerOutboundSmsTransformers(ContainerBuilder $container, Definition $mailSystemServiceDefinition)
{
$transformerTag = 'everlution.sendin_blue_sms.outbound.sms_transformer';

foreach ($container->findTaggedServiceIds($transformerTag) as $id => $attributes) {
$mailSystemServiceDefinition->addMethodCall('addSmsTransformer', array(new Reference($id)));
}
}
}
46 changes: 46 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

declare(strict_types=1);

namespace Everlution\SendinBlueSmsBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
* @author Martin Adamik <[email protected]>
*/
class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('sendin_blue_sms');

$rootNode
->children()
->scalarNode('api_key')
->isRequired()
->info('SendinBlue API key.')
->end()
->scalarNode('base_url')
->defaultValue('https://api.sendinblue.com/v2.0')
->info('SendinBlue API base url')
->end()
->scalarNode('timeout')
->defaultValue('')
->info('SendinBlue API timeout.')
->end()
->scalarNode('from_name')
->defaultValue('')
->info('The name of the sender. The number of characters is limited to 11 (alphanumeric format)')
->end()
->scalarNode('web_url')
->defaultValue('')
->info('SendinBlue API timeout.')
->end()
->end();

return $treeBuilder;
}
}
31 changes: 31 additions & 0 deletions src/DependencyInjection/SendinBlueSmsExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace Everlution\SendinBlueSmsBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;

/**
* @author Martin Adamik <[email protected]>
*/
class SendinBlueSmsExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$container->setParameter('everlution.sendin_blue_sms.api_key', $config['api_key']);
$container->setParameter('everlution.sendin_blue_sms.base_url', $config['base_url']);
$container->setParameter('everlution.sendin_blue_sms.timeout', $config['timeout']);
$container->setParameter('everlution.sendin_blue_sms.from_name', $config['from_name']);
$container->setParameter('everlution.sendin_blue_sms.web_url', $config['web_url']);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
}
}
175 changes: 175 additions & 0 deletions src/Outbound/Model/OutboundSms.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
<?php

declare(strict_types=1);

namespace Everlution\SendinBlueSmsBundle\Outbound\Model;

/**
* @author Martin Adamik <[email protected]>
*/
class OutboundSms
{
/**
* The mobile number to send SMS to with country code [Mandatory].
*
* @var string
*/
protected $to;

/**
* The name of the sender. The number of characters is limited to 11 ( alphanumeric format ) [Mandatory].
*
* @var string
*/
protected $from;

/**
* The text of the message. The maximum characters used per SMS is 160, if used more than that, it will be counted as more than one SMS [Mandatory].
*
* @var string
*/
protected $text;

/**
* The web URL that can be called once the message is successfully delivered [Optional].
In web_url, we are sending the content using POST method, example: {“status”:”OK”,”number_sent”:1,”to”:”00331234567890″,”sms_count”:1,”credits_used”:1,”remaining_credit”:55,”reference”:{“1″:”a1bcdefghij0klmnopq”}}
*
* @var string
*/
protected $webUrl;

/**
* The tag that you can associate with the message [Optional].
*
* @var string
*/
protected $tag;

/**
* Type of message. Possible values – marketing (default) & transactional [Optional].
It is recommended to use ‘transactional’ type for sending transactional SMS and ‘marketing’ type for sending marketing SMS.
*
* @var string
*/
protected $type;

/**
* @return string
*/
public function getTo()
{
return $this->to;
}

/**
* @param string $to
*
* @return OutboundSms
*/
public function setTo($to)
{
$this->to = $to;

return $this;
}

/**
* @return string
*/
public function getFrom()
{
return $this->from;
}

/**
* @param string $from
*
* @return OutboundSms
*/
public function setFrom($from)
{
$this->from = $from;

return $this;
}

/**
* @return string
*/
public function getText()
{
return $this->text;
}

/**
* @param string $text
*
* @return OutboundSms
*/
public function setText($text)
{
$this->text = $text;

return $this;
}

/**
* @return string
*/
public function getWebUrl()
{
return $this->webUrl;
}

/**
* @param string $webUrl
*
* @return OutboundSms
*/
public function setWebUrl($webUrl)
{
$this->webUrl = $webUrl;

return $this;
}

/**
* @return string
*/
public function getTag()
{
return $this->tag;
}

/**
* @param string $tag
*
* @return OutboundSms
*/
public function setTag($tag)
{
$this->tag = $tag;

return $this;
}

/**
* @return string
*/
public function getType()
{
return $this->type;
}

/**
* @param string $type
*
* @return OutboundSms
*/
public function setType($type)
{
$this->type = $type;

return $this;
}
}
16 changes: 16 additions & 0 deletions src/Outbound/Model/OutboundSmsTransformer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace Everlution\SendinBlueSmsBundle\Outbound\Model;

/**
* @author Martin Adamik <[email protected]>
*/
interface OutboundSmsTransformer
{
/**
* @param OutboundSms $sms
*/
public function transform(OutboundSms $sms);
}
Loading

0 comments on commit 05c7d75

Please sign in to comment.