GithubHelp home page GithubHelp logo

brightnest / 46elks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from laravel-notification-channels/46elks

0.0 0.0 0.0 32 KB

46Elks notification channel for Laravel

License: MIT License

PHP 100.00%

46elks's Introduction

46Elks notification channel for Laravel

Latest Version on Packagist Software License Build Status

Quality Score Code Coverage Total Downloads

This package makes it easy to send notifications using 46Elks with Laravel.

46Elks has a whole bunch of phone oriented services. This package takes care of:

  • SMS

With more endpoints to come. Feel free to contribute.

Contents

Installation

composer require laravel-notification-channels/46elks

Setting up the 46Elks service

add the following to your config/services.php

	'46elks' => [
		'username' => env('FORTY_SIX_ELKS_USERNAME'),
		'password' => env('FORTY_SIX_ELKS_PASSWORD'),
	],

Also remember to update your .env with correct information:

FORTY_SIX_ELKS_USERNAME=
FORTY_SIX_ELKS_PASSWORD=

You will find your username and password at https://46elks.se/account

Usage

To use this channel simply create a notification that has the following content:


    public function via($notifiable)
    {
        return [FortySixElksChannel::class];
    }

 
    public function to46Elks($notifiable)
    {
        return (new FortySixElksSMS())
	        ->line('Testsms')
	        ->line('Olle')
	        ->to('+46762216234')
	        ->from('Emil');
    }

Available mediums

SMS

The FortySixElksSMS have the following methods, all chainable.

Available Message methods for sms

from($mixed) Accepts a string up to 11 characters or number. Sms will be sent with that name.

to($number) International phone number.

line($string) Every string in a line will be on its own row.

flash() Will set the message type to flash. Will not endup in sms inbox. See This tweet to find out how it looks on an iphone.

dryrun() Enable when you want to verify your API request without actually sending an SMS to a mobile phone. No SMS message will be sent when this is enabled.

whendelivered('http://localhost') This webhook URL will receive a POST request every time the delivery status changes.

dontlog() Enable to avoid storing the message text in your history. The other parameters will still be stored.

MMS

To use MMS simply use new FortySixElksMMS() instead of new FortySixElksSMS()

The FortySixElksMMS have the following methods, all chainable.

Available Message methods

from($mixed). Accepts 'noreply' as a string or a MMS activated number

to($number). International phone number.

line($string). Every string in a line will be on its own row.

image(). URL to the image to send in mms.

Error handling

How to handle notification send errors

If for any reason there would be an error when sending a notification it will fire a Illuminate\Notifications\Events\NotificationFailed event. You can then listen for that.

Example:

Event::listen(NotificationFailed::class, function($event){
    info('Error while sending sms');
});

And the event has $event->notifiable, $event->notification, $event->channel and $event->data(where you have the exception at $event->data['exception'])

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

46elks's People

Contributors

atymic avatar larsemil avatar techtomaz avatar jannejava avatar axelanderk avatar echibi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.