├── .coveralls.yml ├── .gitignore ├── .php_cs ├── .styleci.yml ├── .travis.yml ├── changelog.md ├── composer.json ├── config └── sendinblue.php ├── contributing.md ├── license.md ├── phpunit.xml ├── readme.md ├── src ├── Facades │ └── Sendinblue.php ├── Sendinblue.php └── SendinblueServiceProvider.php └── tests └── TestCase.php /.coveralls.yml: -------------------------------------------------------------------------------- 1 | service_name: travis-ci 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | .DS_Store 3 | composer.lock 4 | .php_cs.cache 5 | -------------------------------------------------------------------------------- /.php_cs: -------------------------------------------------------------------------------- 1 | 6 | @link https://github.com/vansteen/laravel-sendinblue 7 | @license https://github.com/vansteen/laravel-sendinblue/blob/master/license.md (MIT License) 8 | 9 | For the full copyright and license information, please view the LICENSE 10 | file that was distributed with this source code. 11 | EOF; 12 | 13 | $finder = PhpCsFixer\Finder::create() 14 | ->in(__DIR__ . '/src') 15 | ->in(__DIR__ . '/tests') 16 | ->in(__DIR__ . '/benchmark') 17 | ->name('*.php') 18 | ->notName('*.blade.php') 19 | ->ignoreDotFiles(true) 20 | ->ignoreVCS(true); 21 | 22 | return PhpCsFixer\Config::create() 23 | ->setRules([ 24 | 'psr0' => false, 25 | '@PSR2' => true, 26 | 'blank_line_after_namespace' => true, 27 | 'braces' => true, 28 | 'class_definition' => true, 29 | 'elseif' => true, 30 | 'function_declaration' => true, 31 | 'indentation_type' => true, 32 | 'line_ending' => true, 33 | 'lowercase_constants' => true, 34 | 'lowercase_keywords' => true, 35 | 'method_argument_space' => [ 36 | 'ensure_fully_multiline' => true, ], 37 | 'no_break_comment' => true, 38 | 'no_closing_tag' => true, 39 | 'no_spaces_after_function_name' => true, 40 | 'no_spaces_inside_parenthesis' => true, 41 | 'no_trailing_whitespace' => true, 42 | 'no_trailing_whitespace_in_comment' => true, 43 | 'single_blank_line_at_eof' => true, 44 | 'single_class_element_per_statement' => [ 45 | 'elements' => ['property'], 46 | ], 47 | 'single_import_per_statement' => true, 48 | 'single_line_after_imports' => true, 49 | 'switch_case_semicolon_to_colon' => true, 50 | 'switch_case_space' => true, 51 | 'visibility_required' => true, 52 | 'encoding' => true, 53 | 'full_opening_tag' => true, 54 | 'concat_space' => ['spacing' => 'one'] 55 | ]) 56 | ->setFinder($finder); 57 | -------------------------------------------------------------------------------- /.styleci.yml: -------------------------------------------------------------------------------- 1 | risky: true 2 | 3 | preset: psr2 4 | 5 | enabled: 6 | - binary_operator_spaces 7 | - blank_line_before_return 8 | - concat_with_spaces 9 | - fully_qualified_strict_types 10 | - function_typehint_space 11 | - hash_to_slash_comment 12 | - include 13 | - lowercase_cast 14 | - method_separation 15 | - native_function_casing 16 | - native_function_invocation 17 | - no_blank_lines_after_class_opening 18 | - no_blank_lines_between_uses 19 | - no_duplicate_semicolons 20 | - no_leading_import_slash 21 | - no_leading_namespace_whitespace 22 | - no_multiline_whitespace_before_semicolons 23 | - no_php4_constructor 24 | - no_short_bool_cast 25 | - no_singleline_whitespace_before_semicolons 26 | - no_trailing_comma_in_singleline_array 27 | - no_unreachable_default_argument_value 28 | - no_unused_imports 29 | - no_whitespace_before_comma_in_array 30 | - ordered_imports 31 | - phpdoc_align 32 | - phpdoc_indent 33 | - phpdoc_inline_tag 34 | - phpdoc_no_access 35 | - phpdoc_no_simplified_null_return 36 | - phpdoc_property 37 | - phpdoc_scalar 38 | - phpdoc_to_comment 39 | - phpdoc_trim 40 | - phpdoc_type_to_var 41 | - phpdoc_types 42 | - phpdoc_var_without_name 43 | - print_to_echo 44 | - short_array_syntax 45 | - short_scalar_cast 46 | - single_quote 47 | - spaces_cast 48 | - standardize_not_equal 49 | - ternary_operator_spaces 50 | - trailing_comma_in_multiline_array 51 | - trim_array_spaces 52 | - unary_operator_spaces 53 | - whitespace_after_comma_in_array 54 | - whitespacy_lines 55 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | php: 3 | - "7.2" 4 | 5 | cache: 6 | directories: 7 | - $HOME/.composer/cache 8 | 9 | env: 10 | - PHPUNIT_VERSION=8.0.* TESTBENCH_VERSION=4.* 11 | 12 | before_script: 13 | - travis_retry composer self-update 14 | - travis_retry composer require "phpunit/phpunit:${PHPUNIT_VERSION}" --no-update 15 | - travis_retry composer require "orchestra/testbench:${TESTBENCH_VERSION}" --no-update 16 | - travis_retry composer update --no-interaction --prefer-source 17 | 18 | script: 19 | - mkdir -p build/logs 20 | - php vendor/bin/phpunit --coverage-clover build/logs/clover.xml 21 | 22 | after_script: 23 | - php vendor/bin/php-coveralls -v 24 | -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `Sendinblue` will be documented in this file. 4 | 5 | ## Version 1.1 6 | 7 | - Support for Laravel 7 8 | - Specify the required version for the package "sendinblue/api-v3-sdk" 9 | 10 | ## Version 1.0 11 | 12 | - Support for Laravel 6 13 | - Add the partner key to the config file 14 | - Remove the prefix key from the config file 15 | 16 | ## Version 0.4 17 | 18 | - Everything 19 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vansteen/laravel-sendinblue", 3 | "type": "library", 4 | "description": "A Laravel 5/6/7/8 service provider, facade and config file for the SendinBlue's API v3 official PHP library.", 5 | "keywords": [ 6 | "laravel", 7 | "sendinblue" 8 | ], 9 | "homepage": "https://github.com/vansteen/laravel-sendinblue", 10 | "license": "MIT", 11 | "authors": [ 12 | { 13 | "name": "Thomas Van Steenwinckel", 14 | "email": "code@1234.pm", 15 | "homepage": "https://github.com/vansteen", 16 | "role": "Developer" 17 | } 18 | ], 19 | "require": { 20 | "illuminate/support": "~5|^6.0|^7.0|^8.0|^9.0", 21 | "sendinblue/api-v3-sdk": "^6.1|^7.0|^8.0" 22 | }, 23 | "require-dev": { 24 | "phpunit/phpunit": "~5.7|^8.0|^9.0", 25 | "orchestra/testbench": "~3.0|^4.0|^5.0|^6.0|^7.0", 26 | "php-coveralls/php-coveralls": "^2.2", 27 | "friendsofphp/php-cs-fixer": "^2.16" 28 | }, 29 | "autoload": { 30 | "psr-4": { 31 | "Vansteen\\Sendinblue\\": "src/" 32 | } 33 | }, 34 | "autoload-dev": { 35 | "psr-4": { 36 | "Vansteen\\Sendinblue\\Tests\\": "tests" 37 | } 38 | }, 39 | "extra": { 40 | "laravel": { 41 | "providers": [ 42 | "Vansteen\\Sendinblue\\SendinblueServiceProvider" 43 | ], 44 | "aliases": { 45 | "Sendinblue": "Vansteen\\Sendinblue\\Facades\\Sendinblue" 46 | } 47 | } 48 | }, 49 | "scripts": { 50 | "phpcs": "php-cs-fixer fix -v --diff --dry-run --allow-risky=yes --ansi", 51 | "phpunit": "vendor/bin/phpunit --coverage-text", 52 | "test": [ 53 | "@phpcs", 54 | "@phpunit" 55 | ] 56 | }, 57 | "minimum-stability": "stable" 58 | } 59 | -------------------------------------------------------------------------------- /config/sendinblue.php: -------------------------------------------------------------------------------- 1 | env('SENDINBLUE_APIKEY', null), 16 | 'partnerkey' => env('SENDINBLUE_PARTNERKEY', null), 17 | ]; 18 | -------------------------------------------------------------------------------- /contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are welcome and will be fully credited. 4 | 5 | Contributions are accepted via Pull Requests on [Github](https://github.com/vansteen/sendinblue). 6 | 7 | # Things you could do 8 | If you want to contribute but do not know where to start, this list provides some starting points. 9 | - Add more tests 10 | - Write a comprehensive ReadMe 11 | 12 | ## Pull Requests 13 | 14 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 15 | 16 | - **Document any change in behaviour** - Make sure the `readme.md` and any other relevant documentation are kept up-to-date. 17 | 18 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 19 | 20 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 21 | 22 | 23 | **Happy coding**! 24 | -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Thomas Van Steenwinckel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | ./tests/ 15 | 16 | 17 | 18 | 19 | src/ 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Laravel Sendinblue 2 | 3 | [![Latest Version on Packagist][ico-version]][link-packagist] 4 | [![Total Downloads][ico-downloads]][link-downloads] 5 | [![Build Status][ico-travis]][link-travis] 6 | [![Coverage Status][ico-coverage]][link-coverage] 7 | [![Quality Score][ico-code-quality]][link-code-quality] 8 | [![StyleCI][ico-styleci]][link-styleci] 9 | [![License][ico-license]][link-license] 10 | 11 | The package simply provides a Laravel service provider, facade and config file for the SendinBlue's API v3 official PHP library. 12 | 13 | ## Installation 14 | 15 | You can install this package via Composer using: 16 | 17 | ```bash 18 | composer require vansteen/laravel-sendinblue 19 | ``` 20 | 21 | For Laravel <5.5, you must also install the service provider and the facade to your `config/app.php`: 22 | 23 | ```php 24 | // config/app.php 25 | 'providers' => [ 26 | ... 27 | Vansteen\Sendinblue\SendinblueServiceProvider::class, 28 | ... 29 | ]; 30 | ``` 31 | 32 | ```php 33 | // config/app.php 34 | 'aliases' => [ 35 | ... 36 | 'Sendinblue' => Vansteen\Sendinblue\Facades\Sendinblue::class, 37 | ]; 38 | ``` 39 | 40 | ## Configuration 41 | 42 | You need to publish the config file to `app/config/sendinblue.php`. To do so, run: 43 | 44 | ```bash 45 | php artisan vendor:publish --tag=sendinblue.config 46 | ``` 47 | 48 | Now you need to set your configuration using **environment variables**. 49 | Go the the Sendinblue API settings and add the v3 API key to your `.env` file. 50 | 51 | ```bash 52 | SENDINBLUE_APIKEY=xkeysib-XXXXXXXXXXXXXXXXXXX 53 | ``` 54 | 55 | ## Usage 56 | 57 | To test it, you can add the folowing code in routes.php. 58 | 59 | ```php 60 | // routes.php 61 | ... 62 | use Vansteen\Sendinblue\Facades\Sendinblue; 63 | 64 | Route::get('/test', function () { 65 | 66 | // Configure API keys authorization according to the config file 67 | $config = Sendinblue::getConfiguration(); 68 | 69 | // Uncomment below to setup prefix (e.g. Bearer) for API keys, if needed 70 | // $config->setApiKeyPrefix('api-key', 'Bearer'); 71 | // $config->setApiKeyPrefix('partner-key', 'Bearer'); 72 | 73 | $apiInstance = new \SendinBlue\Client\Api\ListsApi( 74 | // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. 75 | // This is optional, `GuzzleHttp\Client` will be used as default. 76 | new GuzzleHttp\Client(), 77 | $config 78 | ); 79 | 80 | try { 81 | $result = $apiInstance->getLists(); 82 | dd($result); 83 | } catch (Exception $e) { 84 | echo 'Exception when calling AccountApi->getAccount: ', $e->getMessage(), PHP_EOL; 85 | } 86 | 87 | }); 88 | ``` 89 | 90 | To get a idea of the of the API endpoints, visit the API [readme file](https://github.com/sendinblue/APIv3-php-library#documentation-for-api-endpoints). 91 | 92 | Be sure to visit the SendinBlue official [documentation website](https://sendinblue.readme.io/docs) for additional information about our API. 93 | 94 | ## Change log 95 | 96 | Please see the [changelog](changelog.md) for more information on what has changed recently. 97 | 98 | ## Testing 99 | 100 | ```bash 101 | composer test 102 | ``` 103 | 104 | ## Contributing 105 | 106 | Please see [contributing.md](contributing.md) for details and a todolist. 107 | 108 | ## Security 109 | 110 | If you discover any security related issues, please email author email instead of using the issue tracker. 111 | 112 | ## License 113 | 114 | license. Please see the [license file](license.md) for more information. 115 | 116 | [ico-version]: https://poser.pugx.org/vansteen/laravel-sendinblue/v/stable 117 | [ico-downloads]: https://poser.pugx.org/vansteen/laravel-sendinblue/downloads 118 | [ico-travis]: https://travis-ci.org/vansteen/laravel-sendinblue.svg?branch=master 119 | [ico-coverage]: https://coveralls.io/repos/github/vansteen/laravel-sendinblue/badge.svg?branch=master 120 | [ico-code-quality]: https://scrutinizer-ci.com/g/vansteen/laravel-sendinblue/badges/quality-score.png?b=master 121 | [ico-styleci]: https://github.styleci.io/repos/134865450/shield?style=flat 122 | [ico-license]: https://poser.pugx.org/vansteen/laravel-sendinblue/license 123 | [link-packagist]: https://packagist.org/packages/vansteen/laravel-sendinblue 124 | [link-downloads]: https://packagist.org/packages/vansteen/laravel-sendinblue 125 | [link-travis]: https://travis-ci.org/vansteen/laravel-sendinblue 126 | [link-code-quality]: https://scrutinizer-ci.com/g/vansteen/laravel-sendinblue 127 | [link-styleci]: https://styleci.io/repos/134865450 128 | [link-coverage]: https://coveralls.io/github/vansteen/laravel-sendinblue?branch=master 129 | [link-license]: https://github.com/vansteen/laravel-sendinblue/blob/HEAD/license.md 130 | -------------------------------------------------------------------------------- /src/Facades/Sendinblue.php: -------------------------------------------------------------------------------- 1 | 6 | * @link https://github.com/vansteen/laravel-sendinblue 7 | * @license https://github.com/vansteen/laravel-sendinblue/blob/master/license.md (MIT License) 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace Vansteen\Sendinblue\Facades; 14 | 15 | use Illuminate\Support\Facades\Facade; 16 | 17 | class Sendinblue extends Facade 18 | { 19 | /** 20 | * Get the registered name of the component. 21 | * 22 | * @return string 23 | */ 24 | protected static function getFacadeAccessor() 25 | { 26 | return 'sendinblue'; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Sendinblue.php: -------------------------------------------------------------------------------- 1 | 6 | * @link https://github.com/vansteen/laravel-sendinblue 7 | * @license https://github.com/vansteen/laravel-sendinblue/blob/master/license.md (MIT License) 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace Vansteen\Sendinblue; 14 | 15 | use SendinBlue\Client\Configuration; 16 | 17 | /** 18 | * Wrapper for the Sendinblue's Configuration class. 19 | * 20 | * @category Class 21 | * @author Thomas Van Steenwinckel 22 | * @link https://github.com/vansteen/sendinblue 23 | */ 24 | class Sendinblue 25 | { 26 | /** 27 | * An instance of the Sendinblue's Configuration class. 28 | * @var \SendinBlue\Client\Configuration 29 | */ 30 | protected $configuration; 31 | 32 | /** 33 | * Constructor. 34 | */ 35 | public function __construct() 36 | { 37 | $apikey = config('sendinblue.apikey'); 38 | $partnerkey = config('sendinblue.partnerkey'); 39 | 40 | // Configure API key authorization: api-key 41 | $this->configuration = Configuration::getDefaultConfiguration()->setApiKey('api-key', $apikey); 42 | 43 | if ($partnerkey) { 44 | // (Optional) The partner key should be passed in the request headers as 45 | // partner-key along with api-key pair for successful authentication of partner. 46 | $this->configuration->setApiKey('partner-key', $partnerkey); 47 | } 48 | } 49 | 50 | /** 51 | * Gets the default configuration instance. 52 | * 53 | * @return \SendinBlue\Client\Configuration 54 | */ 55 | public function getConfiguration() 56 | { 57 | return $this->configuration; 58 | } 59 | 60 | /** 61 | * Sets the detault configuration instance. 62 | * 63 | * @param \SendinBlue\Client\Configuration $configuration An instance of the Configuration Object 64 | */ 65 | public function setConfiguration(Configuration $configuration) 66 | { 67 | $this->configuration = $configuration; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/SendinblueServiceProvider.php: -------------------------------------------------------------------------------- 1 | 6 | * @link https://github.com/vansteen/laravel-sendinblue 7 | * @license https://github.com/vansteen/laravel-sendinblue/blob/master/license.md (MIT License) 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace Vansteen\Sendinblue; 14 | 15 | use Illuminate\Support\ServiceProvider; 16 | 17 | class SendinblueServiceProvider extends ServiceProvider 18 | { 19 | /** 20 | * Perform post-registration booting of services. 21 | */ 22 | public function boot() 23 | { 24 | // Publishing is only necessary when using the CLI. 25 | if ($this->app->runningInConsole()) { 26 | // Publishing the configuration file. Use : 27 | // php artisan vendor:publish --provider="Vansteen\Sendinblue\SendinblueServiceProvider" 28 | $this->publishes([ 29 | __DIR__ . '/../config/sendinblue.php' => config_path('sendinblue.php'), 30 | ], 'sendinblue.config'); 31 | } 32 | } 33 | 34 | /** 35 | * Register any application services. 36 | */ 37 | public function register() 38 | { 39 | // Merge the package configuration file with the application's published copy. 40 | $this->mergeConfigFrom(__DIR__ . '/../config/sendinblue.php', 'sendinblue'); 41 | 42 | // The singleton method binds a class or interface into the container 43 | // that should only be resolved one time. Once a singleton binding is resolved, 44 | // the same object instance will be returned on subsequent calls into the container 45 | $this->app->singleton('sendinblue', function () { 46 | return new Sendinblue(); 47 | }); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | 6 | * @link https://github.com/vansteen/laravel-sendinblue 7 | * @license https://github.com/vansteen/laravel-sendinblue/blob/master/license.md (MIT License) 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace Vansteen\Sendinblue\Tests; 14 | 15 | use Orchestra\Testbench\TestCase as OrchestraTestCase; 16 | use SendinBlue\Client\Configuration; 17 | use Vansteen\Sendinblue\Facades\Sendinblue; 18 | use Vansteen\Sendinblue\SendinblueServiceProvider; 19 | 20 | /** 21 | * This is the abstract test case class. 22 | * 23 | * @category Class 24 | * @author Thomas Van Steenwinckel 25 | * @link https://github.com/vansteen/sendinblue 26 | */ 27 | class TestCase extends OrchestraTestCase 28 | { 29 | /** 30 | * Set up the environment. 31 | * 32 | * @param \Illuminate\Foundation\Application $app 33 | */ 34 | protected function getEnvironmentSetUp($app) 35 | { 36 | config(['sendinblue.apikey' => 'test_apikey']); 37 | config(['sendinblue.partnerkey' => 'test_partnerkey']); 38 | } 39 | 40 | /** 41 | * Get the service provider class. 42 | * 43 | * @param \Illuminate\Contracts\Foundation\Application $app 44 | * 45 | * @return array 46 | */ 47 | protected function getPackageProviders($app) 48 | { 49 | return [SendinblueServiceProvider::class]; 50 | } 51 | 52 | /** 53 | * Get the facade class. 54 | * 55 | * @param \Illuminate\Contracts\Foundation\Application $app 56 | * 57 | * @return array 58 | */ 59 | protected function getPackageAliases($app) 60 | { 61 | return [ 62 | 'Sendinblue' => Sendinblue::class, 63 | ]; 64 | } 65 | 66 | public function testGetConfigurationisSendinBlueClient() 67 | { 68 | $config = Sendinblue::getConfiguration(); 69 | $this->assertEquals(\SendinBlue\Client\Configuration::class, \get_class($config)); 70 | } 71 | 72 | public function testSetConfigurationisDone() 73 | { 74 | $config = new Configuration(); 75 | $sendinblue = new Sendinblue(); 76 | $sendinblue::setConfiguration($config); 77 | $this->assertEquals($config, $sendinblue::getConfiguration()); 78 | } 79 | 80 | public function testKeysAreSet() 81 | { 82 | $config = Sendinblue::getConfiguration(); 83 | $this->assertEquals($config->getApiKey('api-key'), config('sendinblue.apikey')); 84 | $this->assertEquals($config->getApiKey('partner-key'), config('sendinblue.partnerkey')); 85 | } 86 | } 87 | --------------------------------------------------------------------------------