├── .editorconfig ├── .styleci.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── composer.json └── src ├── Exceptions └── CouldNotSendNotification.php ├── PubnubChannel.php ├── PubnubMessage.php └── PubnubServiceProvider.php /.editorconfig: -------------------------------------------------------------------------------- 1 | ; This file is for unifying the coding style for different editors and IDEs. 2 | ; More information at http://editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | charset = utf-8 8 | indent_size = 4 9 | indent_style = space 10 | end_of_line = lf 11 | insert_final_newline = true 12 | trim_trailing_whitespace = true 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /.styleci.yml: -------------------------------------------------------------------------------- 1 | preset: laravel 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `laravel-notification-channels/pubnub` will be documented in this file 4 | 5 | ## 1.1.0 6 | 7 | - Laravel 5.5 + & 6.0 support 8 | - Drop php < 7.1 support 9 | 10 | ## 1.0.0 11 | 12 | - initial release 13 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | Please read and understand the contribution guide before creating an issue or pull request. 6 | 7 | ## Etiquette 8 | 9 | This project is open source, and as such, the maintainers give their free time to build and maintain the source code 10 | held within. They make the code freely available in the hope that it will be of use to other developers. It would be 11 | extremely unfair for them to suffer abuse or anger for their hard work. 12 | 13 | Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the 14 | world that developers are civilized and selfless people. 15 | 16 | It's the duty of the maintainer to ensure that all submissions to the project are of sufficient 17 | quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. 18 | 19 | ## Viability 20 | 21 | When requesting or submitting new features, first consider whether it might be useful to others. Open 22 | source projects are used by many developers, who may have entirely different needs to your own. Think about 23 | whether or not your feature is likely to be used by other users of the project. 24 | 25 | ## Procedure 26 | 27 | Before filing an issue: 28 | 29 | - Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. 30 | - Check to make sure your feature suggestion isn't already present within the project. 31 | - Check the pull requests tab to ensure that the bug doesn't have a fix in progress. 32 | - Check the pull requests tab to ensure that the feature isn't already in progress. 33 | 34 | Before submitting a pull request: 35 | 36 | - Check the codebase to ensure that your feature doesn't already exist. 37 | - Check the pull requests to ensure that another person hasn't already submitted the feature or fix. 38 | 39 | ## Requirements 40 | 41 | If the project maintainer has any additional requirements, you will find them listed here. 42 | 43 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). 44 | 45 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 46 | 47 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 48 | 49 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. 50 | 51 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 52 | 53 | - **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. 54 | 55 | **Happy coding**! 56 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | 3 | Copyright (c) iWader 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PubNub Notifications Channel for Laravel 2 | [![Latest Version on Packagist](https://img.shields.io/packagist/v/laravel-notification-channels/pubnub.svg?style=flat-square)](https://packagist.org/packages/laravel-notification-channels/pubnub) 3 | [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) 4 | [![Build Status](https://img.shields.io/travis/laravel-notification-channels/pubnub/master.svg?style=flat-square)](https://travis-ci.org/laravel-notification-channels/pubnub) 5 | [![StyleCI](https://styleci.io/repos/65854225/shield)](https://styleci.io/repos/65854225) 6 | [![Quality Score](https://img.shields.io/scrutinizer/g/laravel-notification-channels/pubnub.svg?style=flat-square)](https://scrutinizer-ci.com/g/laravel-notification-channels/pubnub) 7 | [![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/laravel-notification-channels/pubnub/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/laravel-notification-channels/pubnub/?branch=master) 8 | [![Total Downloads](https://img.shields.io/packagist/dt/laravel-notification-channels/pubnub.svg?style=flat-square)](https://packagist.org/packages/laravel-notification-channels/pubnub) 9 | 10 | PubNub Notifications Channel for Laravel 5.5+ & 6.0. This channel allows you to send message payloads as well as push notifications to iOS, Android and Windows using PubNub. 11 | 12 | ## Contents 13 | 14 | - [Installation](#installation) 15 | - [Setting up the PubNub service](#setting-up-the-PubNub-service) 16 | - [Usage](#usage) 17 | - [Available Message methods](#available-message-methods) 18 | - [Changelog](#changelog) 19 | - [Testing](#testing) 20 | - [Security](#security) 21 | - [Contributing](#contributing) 22 | - [Credits](#credits) 23 | - [License](#license) 24 | 25 | ## Installation 26 | 27 | ```bash 28 | composer require laravel-notification-channels/pubnub 29 | ``` 30 | 31 | Add the service provider to your `config/app.php` 32 | 33 | ```php 34 | // config/app.php 35 | 'providers' => [ 36 | ... 37 | NotificationChannels\Pubnub\PubnubServiceProvider::class, 38 | ], 39 | ``` 40 | 41 | ### Setting up the PubNub service 42 | 43 | Add your PubNub Publish Key, Subscribe Key and Secret Key to your `config/services.php` 44 | 45 | ```php 46 | // config/services.php 47 | ... 48 | 49 | 'pubnub' => [ 50 | 'publish_key' => env('PUBNUB_PUBLISH_KEY'), 51 | 'subscribe_key' => env('PUBNUB_SUBSCRIBE_KEY'), 52 | 'secret_key' => env('PUBNUB_SECRET_KEY'), 53 | ], 54 | 55 | ... 56 | ``` 57 | 58 | ## Usage 59 | 60 | ```php 61 | use NotificationChannels\Pubnub\PubnubChannel; 62 | use NotificationChannels\Pubnub\PubnubMessage; 63 | use Illuminate\Notifications\Notification; 64 | 65 | class InvoicePaid extends Notification 66 | { 67 | public function via($notifiable) 68 | { 69 | return [PubnubChannel::class]; 70 | } 71 | 72 | public function toPubnub($notifiable) 73 | { 74 | return (new PubnubMessage()) 75 | ->channel('my_channel') 76 | ->title('My message title') 77 | ->body('My message body'); 78 | } 79 | } 80 | ``` 81 | 82 | Alternatively you may supply a channel specifically related to your notifiable by implementing the `routeNotificationForPubnub()` method. 83 | 84 | ```php 85 | use Illuminate\Database\Eloquent\Model; 86 | use Illuminate\Notifications\Notifiable; 87 | 88 | class User extends Model 89 | { 90 | use Notifiable; 91 | 92 | public function routeNotificationForPubnub() 93 | { 94 | return $this->pubnub_channel; 95 | } 96 | } 97 | ``` 98 | 99 | Sending a push notification. You may chain any of the `withiOS()`, `withAndroid()` and `withWindows()` methods to add push notifications to the message with each of the platforms. 100 | 101 | ```php 102 | use NotificationChannels\Pubnub\PubnubChannel; 103 | use NotificationChannels\Pubnub\PubnubMessage; 104 | use Illuminate\Notifications\Notification; 105 | 106 | class InvoicePaid extends Notification 107 | { 108 | public function via($notifiable) 109 | { 110 | return [PubnubChannel::class]; 111 | } 112 | 113 | public function toPubnub($notifiable) 114 | { 115 | return (new PubnubMessage()) 116 | ->channel('my_channel') 117 | ->title('Alert: Jon Doe Sent You A Message') 118 | ->body('Hi') 119 | ->withiOS( 120 | (new PubnubMessage()) 121 | ->sound('default') 122 | ->badge(1) 123 | ) 124 | ->withAndroid( 125 | (new PubnubMessage()) 126 | ->sound('notification') 127 | ->icon('myicon') 128 | ) 129 | ->withWindows( 130 | (new PubnubMessage()) 131 | ->type('toast') 132 | ->delay(450); 133 | ); 134 | } 135 | } 136 | ``` 137 | 138 | ### Available methods 139 | 140 | - `channel('')`: Specifies the channel the message should be sent to 141 | - `title('')`: Sets the title of the message 142 | - `body('')`: Sets the body of the message 143 | - `storeInHistory(true)`: If the message should be stored in the Pubnub history 144 | - `badge(1)`: Sets the number to display on the push notification's badge (iOS) 145 | - `sound('')`: Sets the sound for the push notification (iOS, Android) 146 | - `icon('')`: Sets the push notification icon (Android) 147 | - `type('')`: Sets the type of push notification (Windows) 148 | - `delay(450)`: Sets the delay in seconds for the push notification (Windows) 149 | - `setData($key, $value)`: Adds any extra data to the payload you may need 150 | - `setOption($key, $value)`: Sets any option to the push notification ([iOS][reference-ios], [Android][reference-android], Windows) 151 | - `withiOS(PubnubMessage $message)`: Sets the push notification for iOS 152 | - `withAndroid(PubnubMessage $message)`: Sets the push notification for Android 153 | - `withWindows(PubnubMessage $message)`: Sets the push notification for Windows 154 | 155 | ## Changelog 156 | 157 | Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. 158 | 159 | ## Testing 160 | 161 | ``` bash 162 | $ composer test 163 | ``` 164 | 165 | ## Security 166 | 167 | If you discover any security related issues, please email wade@iwader.co.uk instead of using the issue tracker. 168 | 169 | ## Contributing 170 | 171 | Please see [CONTRIBUTING](CONTRIBUTING.md) for details. 172 | 173 | ## Credits 174 | 175 | - [iWader](https://github.com/iWader) 176 | - [All Contributors](../../contributors) 177 | 178 | ## License 179 | 180 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 181 | 182 | [reference-ios]: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/TheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH107-SW1 183 | [reference-android]: https://developers.google.com/cloud-messaging/http-server-ref#notification-payload-support 184 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel-notification-channels/pubnub", 3 | "description": "PubNub Notifications Channel for Laravel", 4 | "homepage": "https://github.com/laravel-notification-channels/pubnub", 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "iWader", 9 | "email": "wade@iwader.co.uk", 10 | "homepage": "https://iwader.co.uk/", 11 | "role": "Developer" 12 | } 13 | ], 14 | "require": { 15 | "php": ">=7.3", 16 | "illuminate/notifications": "^8.0", 17 | "illuminate/queue": "^8.0", 18 | "illuminate/support": "^8.0", 19 | "pubnub/pubnub": "^4.1.7" 20 | }, 21 | "require-dev": { 22 | "mockery/mockery": "^1.0", 23 | "phpunit/phpunit": "^9.0" 24 | }, 25 | "autoload": { 26 | "psr-4": { 27 | "NotificationChannels\\Pubnub\\": "src" 28 | } 29 | }, 30 | "autoload-dev": { 31 | "psr-4": { 32 | "NotificationChannels\\Pubnub\\Test\\": "tests" 33 | } 34 | }, 35 | "scripts": { 36 | "test": "vendor/bin/phpunit" 37 | }, 38 | "config": { 39 | "sort-packages": true 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Exceptions/CouldNotSendNotification.php: -------------------------------------------------------------------------------- 1 | getMessage()); 13 | } 14 | 15 | public static function missingChannel() 16 | { 17 | return new static('Notification not sent. No channel specified'); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/PubnubChannel.php: -------------------------------------------------------------------------------- 1 | pubnub = $pubnub; 18 | } 19 | 20 | /** 21 | * Send the given notification. 22 | * 23 | * @param mixed $notifiable 24 | * @param \Illuminate\Notifications\Notification $notification 25 | * 26 | * @throws \NotificationChannels\Pubnub\Exceptions\CouldNotSendNotification 27 | */ 28 | public function send($notifiable, Notification $notification) 29 | { 30 | $message = $notification->toPubnub($notifiable); 31 | 32 | $channel = ! is_null($message->channel) ? $message->channel : $notifiable->routeNotificationFor('pubnub'); 33 | 34 | if (is_null($channel)) { 35 | throw CouldNotSendNotification::missingChannel(); 36 | } 37 | 38 | try { 39 | $this->pubnub->publish($channel, $message->toArray(), $message->storeInHistory); 40 | } catch (PubnubException $exception) { 41 | throw CouldNotSendNotification::pubnubRespondedWithAnError($exception); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/PubnubMessage.php: -------------------------------------------------------------------------------- 1 | 89 | */ 90 | protected $extras; 91 | 92 | /** 93 | * Extra data to add to the payload. 94 | * 95 | * @var array 96 | */ 97 | protected $data = []; 98 | 99 | /** 100 | * Extra options to add to the push notification. 101 | * 102 | * @var array 103 | */ 104 | protected $options = []; 105 | 106 | public function __construct() 107 | { 108 | $this->extras = collect(); 109 | } 110 | 111 | /** 112 | * Set the channel the message should be sent to. 113 | * 114 | * @param string $channel 115 | * @return $this 116 | */ 117 | public function channel($channel) 118 | { 119 | $this->channel = $channel; 120 | 121 | return $this; 122 | } 123 | 124 | /** 125 | * Set the option to store the current message in the Pubnub history. 126 | * 127 | * @param bool $shouldStore 128 | * @return $this 129 | */ 130 | public function storeInHistory($shouldStore = true) 131 | { 132 | $this->storeInHistory = (bool) $shouldStore; 133 | 134 | return $this; 135 | } 136 | 137 | /** 138 | * Sets the platform to iOS. 139 | * 140 | * @return $this 141 | */ 142 | public function iOS() 143 | { 144 | $this->platform = static::PLATFORM_iOS; 145 | 146 | return $this; 147 | } 148 | 149 | /** 150 | * Sets the platform to android. 151 | * 152 | * @return $this 153 | */ 154 | public function android() 155 | { 156 | $this->platform = static::PLATFORM_ANDROID; 157 | 158 | return $this; 159 | } 160 | 161 | /** 162 | * Sets the platform to windows. 163 | * 164 | * @return $this 165 | */ 166 | public function windows() 167 | { 168 | $this->platform = static::PLATFORM_WINDOWS; 169 | 170 | return $this; 171 | } 172 | 173 | /** 174 | * Sets the title of the push notification. 175 | * 176 | * @param string $title 177 | * @return $this 178 | */ 179 | public function title($title) 180 | { 181 | $this->title = $title; 182 | 183 | return $this; 184 | } 185 | 186 | /** 187 | * Sets the body of the push notification. 188 | * 189 | * @param string $body 190 | * @return $this 191 | */ 192 | public function body($body) 193 | { 194 | $this->body = $body; 195 | 196 | return $this; 197 | } 198 | 199 | /** 200 | * Sets the sound of the push notification. 201 | * 202 | * @param string $sound 203 | * @return $this 204 | */ 205 | public function sound($sound) 206 | { 207 | $this->sound = $sound; 208 | 209 | return $this; 210 | } 211 | 212 | /** 213 | * Sets the number to display on the push notification badge (iOS). 214 | * 215 | * @param int $badge 216 | * @return $this 217 | */ 218 | public function badge($badge) 219 | { 220 | $this->badge = $badge; 221 | 222 | return $this; 223 | } 224 | 225 | /** 226 | * Sets the icon to use for the push notification. 227 | * 228 | * @param string $icon 229 | * @return $this 230 | */ 231 | public function icon($icon) 232 | { 233 | $this->icon = $icon; 234 | 235 | return $this; 236 | } 237 | 238 | /** 239 | * Sets the type of notification (Windows). 240 | * 241 | * @throws \InvalidArgumentException 242 | * @param string $type 243 | * @return $this 244 | */ 245 | public function type($type) 246 | { 247 | if (! in_array($type, ['toast', 'flip', 'cycle', 'iconic'])) { 248 | throw new InvalidArgumentException("Invalid type given [{$type}]. Expected 'toast', 'flip', 'cycle' or 'iconic'."); 249 | } 250 | 251 | $this->type = $type; 252 | 253 | return $this; 254 | } 255 | 256 | /** 257 | * Sets the delay for delivering the notification (Windows). 258 | * 259 | * @param int $delay 260 | * @return $this 261 | */ 262 | public function delay($delay) 263 | { 264 | if (! in_array($delay, [0, 450, 900])) { 265 | throw new InvalidArgumentException("Invalid delay give [{$delay}]. Expected 0, 450 or 900."); 266 | } 267 | 268 | $this->delay = $delay; 269 | 270 | return $this; 271 | } 272 | 273 | /** 274 | * Sets optional extra data to add to the payload. 275 | * 276 | * @param $key 277 | * @param $value 278 | * @return $this 279 | */ 280 | public function setData($key, $value) 281 | { 282 | $this->data[$key] = $value; 283 | 284 | return $this; 285 | } 286 | 287 | /** 288 | * Sets optional extra options onto the push notification payload (W. 289 | * 290 | * @param $key 291 | * @param $value 292 | * @return $this 293 | */ 294 | public function setOption($key, $value) 295 | { 296 | $this->options[$key] = $value; 297 | 298 | return $this; 299 | } 300 | 301 | /** 302 | * @return array 303 | */ 304 | protected function getData() 305 | { 306 | if ($this->platform === static::PLATFORM_iOS) { 307 | return $this->data; 308 | } 309 | 310 | return array_merge($this->data, $this->options); 311 | } 312 | 313 | /** 314 | * @return array 315 | */ 316 | protected function getOptions() 317 | { 318 | return $this->options; 319 | } 320 | 321 | /** 322 | * Sets the message used to create the iOS push notification. 323 | * 324 | * @param PubnubMessage $message 325 | * @return $this 326 | */ 327 | public function withiOS(self $message) 328 | { 329 | $this->extras->push($message->iOS()); 330 | 331 | return $this; 332 | } 333 | 334 | /** 335 | * Sets the message used to create the Android push notification. 336 | * 337 | * @param PubnubMessage $message 338 | * @return $this 339 | */ 340 | public function withAndroid(self $message) 341 | { 342 | $this->extras->push($message->android()); 343 | 344 | return $this; 345 | } 346 | 347 | /** 348 | * Sets the message used to create the Windows push notification. 349 | * 350 | * @param PubnubMessage $message 351 | * @return $this 352 | */ 353 | public function withWindows(self $message) 354 | { 355 | $this->extras->push($message->windows()); 356 | 357 | return $this; 358 | } 359 | 360 | /** 361 | * Transforms the message into an suitable payload for Pubnub\Pubnub. 362 | * 363 | * @return array 364 | */ 365 | public function toArray() 366 | { 367 | switch ($this->platform) { 368 | case 'iOS': 369 | return $this->toiOS(); 370 | case 'android': 371 | return $this->toAndroid(); 372 | case 'windows': 373 | return $this->toWindows(); 374 | } 375 | 376 | $payload = array_merge($this->data, [ 377 | 'body' => $this->body, 378 | 'title' => $this->title, 379 | ]); 380 | 381 | $this->extras->each(function (self $message) use (&$payload) { 382 | $payload = array_merge($payload, $message->toArray()); 383 | }); 384 | 385 | return $payload; 386 | } 387 | 388 | /** 389 | * Transforms the message into an array suitable for the payload. 390 | * 391 | * @return array 392 | */ 393 | protected function toiOS() 394 | { 395 | return [ 396 | 'pn_apns' => array_merge($this->getData(), [ 397 | 'aps' => array_merge($this->getOptions(), [ 398 | 'alert' => [ 399 | 'title' => $this->title, 400 | 'body' => $this->body, 401 | ], 402 | 'badge' => $this->badge, 403 | 'sound' => $this->sound, 404 | ]), 405 | ]), 406 | ]; 407 | } 408 | 409 | /** 410 | * Transforms the message into a payload suitable for GCM. 411 | * 412 | * @return array 413 | */ 414 | protected function toAndroid() 415 | { 416 | return [ 417 | 'pn_gmc' => [ 418 | 'data' => array_merge($this->getData(), [ 419 | 'title' => $this->title, 420 | 'body' => $this->body, 421 | 'sound' => $this->sound, 422 | 'icon' => $this->icon, 423 | ]), 424 | ], 425 | ]; 426 | } 427 | 428 | /** 429 | * Transforms the message into a payload suitable for MPNS. 430 | * 431 | * @return array 432 | */ 433 | protected function toWindows() 434 | { 435 | return [ 436 | 'pn_mpns' => array_merge($this->getData(), [ 437 | 'title' => $this->title, 438 | 'body' => $this->body, 439 | 'type' => $this->type, 440 | 'delay' => $this->delay, 441 | ]), 442 | ]; 443 | } 444 | } 445 | -------------------------------------------------------------------------------- /src/PubnubServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->when(PubnubChannel::class) 16 | ->needs(Pubnub::class) 17 | ->give(function () { 18 | $config = config('services.pubnub'); 19 | 20 | return new Pubnub( 21 | $config['publish_key'], 22 | $config['subscribe_key'], 23 | $config['secret_key'] 24 | ); 25 | }); 26 | } 27 | } 28 | --------------------------------------------------------------------------------