Awesome
Hipchat notifier
Usage
Getting started with a Hello World example.
// Configuration.
$rooms = [
[
'room_id' => '1234',
'auth_token' => '****',
],
];
// Create the required Guzzle client.
$client = new Guzzle\Http\Client;
$hipchat = new Hipchat\Notifier($client, $rooms);
// Send the notification.
$hipchat->notify('Hello world!');
If you would like to send notification to different rooms, add some to the array.
// Configuration.
$rooms = [
'frontenders' => [
'room_id' => '1234',
'auth_token' => '****',
],
'backenders' => [
'room_id' => '5678',
'auth_token' => '****',
],
];
// Create the required Guzzle client.
$client = new Guzzle\Http\Client;
$hipchat = new Hipchat\Notifier($client, $rooms);
// Send the notification.
$hipchat->notifyIn('frontenders', 'Hello world!');
The default room in which the notify
method posts to is the first from the array, or you can
specify which room to use as a default with a third constructor parameter:
Extra configuration.
The constructor accepts a third parameter with extra options.
$config = [
'default' => 'frontenders',
'color' => 'gray',
'pretend' => true,
'notify' => true,
];
default
: The default room to send notifications in with->notify()
.color
: Choose fromyellow
,red
,green
,purple
,gray
orrandom
.pretend
: Don't actually send any messages.notify
: Let hipchat make a sound.
Color
Choose your color depending on the type of message with the second and third parameter of the
notify
and notifyIn
method.
// Example 1
$color = $error ? 'red' : 'green';
$hipchat->notify($message, $color);
// Example 2
$hipchat->notifyIn('frontenders', $message, 'purple');
Laravel 4
This package comes with a Laravel 4 service provider. Add the following line to the
providers array in app.php
.
'Hipchat\Support\ServiceProvider',
It also registers an alias for the Facade class Hipchat\Support\Facades\Hipchat
so you can just use
Hipchat::notify($message)
and Hipchat::notifyIn('frontenders', $message)
.
Publish the default configuration with the following command:
php artisan config:publish hannesvdvreken/hipchat
All configurable options can be found there.
Contributing
Feel free to make a pull request. Please try to be as PSR-2 compliant as possible.