From a78fd79c2caca5e76d4f5c137fe543960f55d700 Mon Sep 17 00:00:00 2001 From: Thomas Klein Date: Tue, 17 Apr 2018 17:52:13 +0200 Subject: [PATCH] orange sms notification --- LICENSE | 21 +++++++ README.md | 50 +++++++++++++++ Service/OrangeSmsAdapter.php | 117 +++++++++++++++++++++++++++++++++++ composer.json | 50 +++++++++++++++ etc/adminhtml/system.xml | 35 +++++++++++ etc/di.xml | 27 ++++++++ etc/module.xml | 28 +++++++++ registration.php | 22 +++++++ 8 files changed, 350 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 Service/OrangeSmsAdapter.php create mode 100644 composer.json create mode 100644 etc/adminhtml/system.xml create mode 100644 etc/di.xml create mode 100644 etc/module.xml create mode 100644 registration.php diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..069a691 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2018 Blackbird Agency + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..d4c62c0 --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +# Orange Sms Notification + +[![Latest Stable Version](https://img.shields.io/packagist/v/blackbird/orange-sms-notification.svg?style=flat-square)](https://packagist.org/packages/blackbird/orange-sms-notification) +[![License: MIT](https://img.shields.io/github/license/blackbird-agency/magento-2-orange-sms-notification.svg?style=flat-square)](./LICENSE) + +This module is a free connector for the SmsNotification and the OrangeSms modules. +The free source is available at the [github repository](https://github.com/blackbird-agency/magento-2-orange-sms-notification). + +These modules are available on our [store](https://store.bird.eu/). + +## Setup + +The module is available on packagist, so you can install the module through composer: + +``` +composer require blackbird/orange-sms-notification +``` + +Then, run the following magento command: + +``` +php bin/magento setup:upgrade +``` + +**If you are in production mode, do not forget to recompile and redeploy the static resources.** + +## Settings + +This module add the capability to enable or disable this adapter connector. +The setting is available at the Orange Sms config section. + +Now, your Orange Sms connector is available in the field list of Sms Notification adapters. +Select `Orange Sms` and apply the changes. Now, your notification are sent through Orange Sms. + +## Support + +- If you have any issue with this code, feel free to [open an issue](https://github.com/blackbird-agency/magento-2-orange-sms-notification/issues/new). +- If you wan to contribute to this project, feel free to [create a pull request](https://github.com/blackbird-agency/magento-2-orange-sms-notification/compare). + +## Authors + +- **Thomas Klein** - *Initial work* - [It's me!](https://github.com/thomas-blackbird) +- **Blackbird Team** - *Contributor* - [They're awesome!](https://github.com/blackbird-agency) + +## Licence + +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. + +***That's all folks!*** + diff --git a/Service/OrangeSmsAdapter.php b/Service/OrangeSmsAdapter.php new file mode 100644 index 0000000..4cadbb2 --- /dev/null +++ b/Service/OrangeSmsAdapter.php @@ -0,0 +1,117 @@ +smsFactory = $smsFactory; + $this->smsManagement = $smsManagement; + $this->scopeConfig = $scopeConfig; + } + + /** + * {@inheritdoc} + */ + public function getCode(): string + { + return self::CODE; + } + + /** + * {@inheritdoc} + */ + public function getLabel(): string + { + return (new Phrase('Orange SMS'))->render(); + } + + /** + * {@inheritdoc} + */ + public function isEnabled(): bool + { + return $this->scopeConfig->isSetFlag(self::XML_PATH_ORANGE_SMS_ENABLED, ScopeInterface::SCOPE_STORE); + } + + /** + * {@inheritdoc} + */ + public function sendMessage(MessageInterface $message): bool + { + /** @var \Blackbird\OrangeSms\Api\Data\SmsInterface $sms */ + $sms = $this->smsFactory->create(); + $sms->setTo($message->getTo()); + $sms->setFrom($message->getFrom()); + $sms->setMessage($message->getText()); + + try { + $this->smsManagement->send($sms); + } catch (OrangeSmsSendException $e) { + throw new SendNotificationException(new Phrase('Impossible to send the message.'), $e); + } + + return true; + } +} diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..94e33ad --- /dev/null +++ b/composer.json @@ -0,0 +1,50 @@ +{ + "name": "blackbird/orange-sms-notification", + "description": "Orange Sms connector to the Sms Notificaiton module adapters.", + "keywords": [ + "php", + "magento", + "magento2", + "orange", + "sms", + "notification" + ], + "homepage": "https://github.com/blackbird-agency/magento-2-orange-sms-notification", + "authors": [ + { + "name": "Thomas Klein", + "email": "thomas@bird.eu", + "homepage": "https://www.linkedin.com/in/thomas-klein/", + "role": "lead" + }, + { + "name": "Blackbird Team", + "email": "hello@bird.eu", + "homepage": "https://black.bird.eu/", + "role": "contributor" + } + ], + "support": { + "source": "https://github.com/blackbird-agency/magento-2-orange-sms-notification", + "issues": "https://github.com/blackbird-agency/magento-2-orange-sms-notification/issues" + }, + "require": { + "magento/magento-composer-installer": "*", + "magento/framework": ">=100.0", + "magento/module-backend": ">=100.0", + "magento/module-config": ">=100.0", + "blackbird/sms-notification": ">=0.1.0", + "blackbird/orange-sms": ">=0.1.0" + }, + "type": "magento2-module", + "version": "0.1.0", + "license": "MIT", + "autoload": { + "files": [ + "registration.php" + ], + "psr-4": { + "Blackbird\\OrangeSmsNotification\\": "" + } + } +} diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml new file mode 100644 index 0000000..c511191 --- /dev/null +++ b/etc/adminhtml/system.xml @@ -0,0 +1,35 @@ + + + + +
+ + + + Magento\Config\Model\Config\Source\Enabledisable + + + + + orange_sms/general/enabled + + +
+
+
diff --git a/etc/di.xml b/etc/di.xml new file mode 100644 index 0000000..ecbc15b --- /dev/null +++ b/etc/di.xml @@ -0,0 +1,27 @@ + + + + + + + Blackbird\OrangeSmsNotification\Service\OrangeSmsAdapter + + + + diff --git a/etc/module.xml b/etc/module.xml new file mode 100644 index 0000000..77c754d --- /dev/null +++ b/etc/module.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + diff --git a/registration.php b/registration.php new file mode 100644 index 0000000..6900597 --- /dev/null +++ b/registration.php @@ -0,0 +1,22 @@ +