|
1 | | -# interfax |
2 | | -InterFAX notification channel for Laravel |
| 1 | +# InterFAX notification channel for Laravel 5.8+ and 6.x |
| 2 | + |
| 3 | +[](https://packagist.org/packages/laravel-notification-channels/interfax) |
| 4 | +[](LICENSE.md) |
| 5 | +[](https://travis-ci.org/laravel-notification-channels/interfax) |
| 6 | +[](https://styleci.io/repos/217342993) |
| 7 | +[](https://insight.sensiolabs.com/projects/5c642897-a39d-4a62-8618-2880d818b101) |
| 8 | +[](https://scrutinizer-ci.com/g/laravel-notification-channels/interfax) |
| 9 | +[](https://scrutinizer-ci.com/g/laravel-notification-channels/interfax/?branch=master) |
| 10 | +[](https://packagist.org/packages/laravel-notification-channels/interfax) |
| 11 | + |
| 12 | +This package makes it easy to send notifications using [InterFAX](https://interfax.net) with Laravel 5.8+ and 6.x. |
| 13 | + |
| 14 | +## Contents |
| 15 | + |
| 16 | +- [Installation](#installation) |
| 17 | + - [Setting up the InterFAX service](#setting-up-the-InterFAX-service) |
| 18 | +- [Usage](#usage) |
| 19 | + - [Available Message methods](#available-message-methods) |
| 20 | +- [Changelog](#changelog) |
| 21 | +- [Testing](#testing) |
| 22 | +- [Security](#security) |
| 23 | +- [Contributing](#contributing) |
| 24 | +- [Credits](#credits) |
| 25 | +- [License](#license) |
| 26 | + |
| 27 | + |
| 28 | +## Installation |
| 29 | + |
| 30 | +You can install this package via composer: |
| 31 | + |
| 32 | +```bash |
| 33 | +composer require laravel-notification-channels/interfax |
| 34 | +``` |
| 35 | + |
| 36 | +The service provider gets loaded automatically. |
| 37 | + |
| 38 | +### Setting up the InterFAX service |
| 39 | + |
| 40 | +This channel will use your InterFAX username and password. To use the channel, add this to your `config/services.php` file: |
| 41 | + |
| 42 | +```php |
| 43 | +... |
| 44 | +'interfax' => [ |
| 45 | + 'username' => env('INTERFAX_USERNAME'), |
| 46 | + 'password' => env('INTERFAX_PASSWORD'), |
| 47 | + 'pci' => env('INTERFAX_PCI', false), |
| 48 | +], |
| 49 | +... |
| 50 | +``` |
| 51 | + |
| 52 | +This will load your InterFAX credentials from the `.env` file. If your requests must be PCI-DSS-compliant, set `INTERFAX_PCI=true` in your `.env` file. |
| 53 | + |
| 54 | +## Usage |
| 55 | + |
| 56 | +To use this package, you can create a notification class, like `DocumentWasSent` from the example below, in your Laravel application. Make sure to check out [Laravel's documentation](https://laravel.com/docs/master/notifications) for this process. |
| 57 | + |
| 58 | +### Send PDF via fax |
| 59 | + |
| 60 | +```php |
| 61 | +<?php |
| 62 | +use NotificationChannels\Interfax\InterfaxChannel; |
| 63 | +use NotificationChannels\Interfax\InterfaxMessage; |
| 64 | + |
| 65 | +class DocumentWasSent extends Notification |
| 66 | +{ |
| 67 | + |
| 68 | + protected $files; |
| 69 | + |
| 70 | + public function __construct(array $files) |
| 71 | + { |
| 72 | + $this->files = $files; |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * Get the notification's delivery channels. |
| 77 | + * |
| 78 | + * @param mixed $notifiable |
| 79 | + * @return array |
| 80 | + */ |
| 81 | + public function via($notifiable) |
| 82 | + { |
| 83 | + return [InterfaxChannel::class]; |
| 84 | + } |
| 85 | + |
| 86 | + public function toInterfax($notifiable) |
| 87 | + { |
| 88 | + return (new InterfaxMessage) |
| 89 | + ->files($this->files); |
| 90 | + } |
| 91 | +} |
| 92 | +``` |
| 93 | + |
| 94 | +The Notifiable model will need to return a destination fax number. |
| 95 | + |
| 96 | +```php |
| 97 | +public function routeNotificationForInterfax($notification) |
| 98 | +{ |
| 99 | + if($this->fax) |
| 100 | + return preg_replace('/[^\d]/', '', $this->fax); |
| 101 | + |
| 102 | + return null; |
| 103 | +} |
| 104 | +``` |
| 105 | + |
| 106 | +### Available Message methods |
| 107 | + |
| 108 | +`file(string $file)` : Accepts the full path to a single file (full list of supported file types [found here](https://www.interfax.net/en/help/supported_file_types)). |
| 109 | +`files(array $array)` : Accepts an array of file paths. |
| 110 | +`stream(Filestream $stream, string $name)` : Accepts a file stream. |
| 111 | + |
| 112 | +## Changelog |
| 113 | + |
| 114 | +Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. |
| 115 | + |
| 116 | +## Testing |
| 117 | + |
| 118 | +``` bash |
| 119 | +$ composer test |
| 120 | +``` |
| 121 | + |
| 122 | +## Security |
| 123 | + |
| 124 | +If you discover any security related issues, please email [email protected] instead of using the issue tracker. |
| 125 | + |
| 126 | +## Contributing |
| 127 | + |
| 128 | +Please see [CONTRIBUTING](CONTRIBUTING.md) for details. |
| 129 | + |
| 130 | +## Credits |
| 131 | + |
| 132 | +- [Craig Spivack](https://github.com/iv-craig) |
| 133 | +- [All Contributors](../../contributors) |
| 134 | + |
| 135 | +## License |
| 136 | + |
| 137 | +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
0 commit comments