assaqqaf/zendesk-laravel-notification

Zendesk Notifications driver

v0.4.2 2017-01-17 12:28 UTC

This package is not auto-updated.

Last update: 2022-09-17 07:48:41 UTC


README

Software License Build Status StyleCI SensioLabsInsight Scrutinizer Code Quality Code Coverage Build Status

This package makes it easy to create Zendesk API with Laravel 5.3.

Contents

Installation

You can install the package via composer:

composer require assaqqaf/zendesk-laravel-notification

Add the service provider to config/app.php:

// config/app.php
'providers' => [
    ...
    NotificationChannels\Zendesk\ZendeskServiceProvider::class,
],

Setting up the Zendesk service

Add your Zendesk REST API Key to your config/services.php:

// config/services.php
...
'zendesk' => [
    'subdomin' => env('ZENDESK_API_SUBDOMIN'),
    'username' => env('ZENDESK_API_USERNAME'),
    'token' => env('ZENDESK_API_TOKEN'),
],
...

Usage

Now you can use the channel in your via() method inside the notification:

use NotificationChannels\Zendesk\ZendeskChannel;
use NotificationChannels\Zendesk\ZendeskMessage;
use Illuminate\Notifications\Notification;

class ProjectCreated extends Notification
{
    public function via($notifiable)
    {
        return [ZendeskChannel::class];
    }

    public function toZendesk($notifiable)
    {
        return
            (new ZendeskMessage('Test Zendesk Notification', 'This will be sent as ticket body'));
    }
}

In order to let your Notification know which user you are targeting, add the routeNotificationForZendesk method to your Notifiable model.

This method needs to return the access token of the authorized Evernote user.

public function routeNotificationForZendesk()
{
    return [
        'name' => $this->name,
        'email' => $this->email,
    ];
}

Available Message Methods

  • subject(''): Accepts a string value for the Zendesk ticket name.
  • description(''): Accepts a string value for the Zendesk ticket description.
  • content(''): Accepts a string value for the Zendesk ticket content message.
  • from('', ''): Accepts a string value for the Zendesk ticket requester name, and email.
  • type(''): Accepts a string value for the Zendesk ticket type. Allowed values are problem, incident, question, or task.
  • priority(''): Accepts a string value for the Zendesk ticket priority. Allowed values are urgent, high, normal, or low.
  • status(''): Accepts a string value for the Zendesk ticket status. Allowed values are new, open, pending, hold, solved or closed.
  • visible(): Set the comment to be public.
  • tags([]): Accepts an array value for the Zendesk ticket tags.
  • customField($id, $value): Set a new custom filed. Accept custom filed id as integer, and the value of the filed.
  • group(''): Accepts an integer as the group id, to assign ticket to this group.
  • ticket(): Accepts an integer as the ticket id. If thicket id is set, the notification will update this ticket.

Events

The package trigger and event when the ticket is created or updated. The following event is available:

  • NotificationChannels\Zendesk\Events\ZendeskTicketWasCreated
  • NotificationChannels\Zendesk\Events\ZendeskTicketWasUpdated

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Credits

License

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