Skip to content
This repository was archived by the owner on Jan 18, 2018. It is now read-only.

Commit c77ca29

Browse files
Initial commit
0 parents  commit c77ca29

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+3823
-0
lines changed

.gitattributes

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
* text=auto
2+
3+
/tests export-ignore
4+
/.gitattributes export-ignore
5+
/.gitignore export-ignore
6+
/.travis.yml export-ignore
7+
/phpunit.xml.dist export-ignore
8+
/README.md export-ignore

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
composer.lock
2+
phpunit.xml
3+
vendor

.travis.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
language: php
2+
3+
php:
4+
- 5.5.9
5+
- 5.5
6+
- 5.6
7+
- hhvm
8+
9+
sudo: false
10+
11+
install:
12+
- travis_retry composer install --no-interaction --prefer-source
13+
14+
script:
15+
- bash -c 'if [ "$TRAVIS_PHP_VERSION" == "hhvm" ]; then vendor/bin/phpunit; fi;'
16+
- bash -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then vendor/bin/phpunit --coverage-clover build/logs/clover.xml; fi;'
17+
18+
after_script:
19+
- bash -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi;'
20+
- bash -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml; fi;'

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Alt Three Services Limited
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.

README.md

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# NotifyMe
2+
3+
[![StyleCI](https://styleci.io/repos/29053236/shield)](https://styleci.io/repos/29053236)
4+
[![Build Status](https://img.shields.io/travis/notifymehq/notifyme.svg?style=flat-square)](https://travis-ci.org/notifymehq/notifyme)
5+
6+
7+
Common interface for notification services.
8+
9+
10+
## Installation
11+
12+
Either [PHP](https://php.net) 5.5+ or [HHVM](http://hhvm.com) 3.6+ are required.
13+
14+
To get the latest version of NotifyMe, simply require the project using [Composer](https://getcomposer.org):
15+
16+
```bash
17+
$ composer require notifymehq/notifyme
18+
```
19+
20+
Instead, you may of course manually update your require block and run `composer update` if you so choose:
21+
22+
```json
23+
{
24+
"require": {
25+
"notifymehq/notifyme": "^1.0"
26+
}
27+
}
28+
```
29+
30+
If you want, you can require only a single adapter. This works rather like the component system of laravel or symfony. We currently have the following adapters:
31+
32+
* Ballou (`notifymehq/ballou`)
33+
* Campfire (`notifymehq/campfire`)
34+
* Gitter (`notifymehq/gitter`)
35+
* Hipchat (`notifymehq/hipchat`)
36+
* Pagerduty (`notifymehq/pagerduty`)
37+
* Pushover (`notifymehq/pushover`)
38+
* Slack (`notifymehq/slack`)
39+
* Twilio (`notifymehq/twilio`)
40+
* Webhook (`notifymehq/webhook`)
41+
* Yo (`notifymehq/yo`)
42+
43+
Also, note, that our other components are:
44+
45+
* Contracts (`notifymehq/contracts`)
46+
* Factory (`notifymehq/factory`)
47+
* Http (`notifymehq/http`)
48+
* Manager (`notifymehq/manager`)
49+
* Support (`notifymehq/support`)
50+
51+
Finally, we have a totally seperate Laravel bridge available for use by installing `notifyme/laravel`, then adding our service provider: `NotifyMeHQ\Laravel\NotifyMeServiceProvider`.
52+
53+
54+
## Usage
55+
56+
* Create a factory : `$factory = new NotifyMeHQ\Factory\NotifyMeFactory();`
57+
* Make a notifier : `$notifier = $factory->make($config);`
58+
* Notify : `$response = $notifier->notify($to, $message);`
59+
* Check the response : `$response->isSent();`
60+
61+
62+
## Example
63+
64+
Here is an example of a notification with Slack:
65+
66+
```php
67+
<?php
68+
69+
// Create a factory for notifications
70+
$notifierFactory = new NotifyMeHQ\Factory\NotifyMeFactory();
71+
72+
// Create the new notification for slack
73+
$slackNotifier = $notifierFactory->make([
74+
// Specify that we will use slack
75+
'driver' => 'slack',
76+
// Add api token to get access to slack API
77+
'token' => '',
78+
// Who send this message, here is a bot called 'Super Bot'
79+
'from' => 'Super Bot',
80+
]);
81+
82+
/* @var \NotifyMeHQ\Contracts\ResponseInterface $response */
83+
$response = $slackNotifier->notify('#sandbox', 'test message');
84+
85+
echo $response->isSent() ? 'Message sent' : 'Message going nowhere';
86+
```
87+
88+
89+
## License
90+
91+
NotifyMe is licensed under [The MIT License (MIT)](LICENSE).

composer.json

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"name": "notifymehq/notifyme",
3+
"description": "Provides a common interface for notification services",
4+
"license": "MIT",
5+
"keywords": ["notifymehq", "notifyme", "notifications", "integrations"],
6+
"authors": [
7+
{
8+
"name": "James Brooks",
9+
"email": "[email protected]"
10+
},
11+
{
12+
"name": "Graham Campbell",
13+
"email": "[email protected]"
14+
},
15+
{
16+
"name": "Joseph Cohen",
17+
"email": "[email protected]"
18+
}
19+
],
20+
"require": {
21+
"php": ">=5.5.9",
22+
"guzzlehttp/guzzle": "^5.3|^6.0"
23+
},
24+
"require-dev": {
25+
"phpunit/phpunit": "^4.8|^5.0"
26+
},
27+
"autoload": {
28+
"psr-4": {
29+
"NotifyMeHQ\\": "src/"
30+
}
31+
},
32+
"autoload-dev": {
33+
"psr-4": {
34+
"NotifyMeHQ\\Tests\\": "tests/"
35+
}
36+
},
37+
"replace": {
38+
"notifymehq/ballou": "self.version",
39+
"notifymehq/campfire": "self.version",
40+
"notifymehq/contracts": "self.version",
41+
"notifymehq/factory": "self.version",
42+
"notifymehq/gitter": "self.version",
43+
"notifymehq/hipchat": "self.version",
44+
"notifymehq/http": "self.version",
45+
"notifymehq/manager": "self.version",
46+
"notifymehq/pagerduty": "self.version",
47+
"notifymehq/pushover": "self.version",
48+
"notifymehq/slack": "self.version",
49+
"notifymehq/support": "self.version",
50+
"notifymehq/twilio": "self.version",
51+
"notifymehq/webhook": "self.version",
52+
"notifymehq/yo": "self.version"
53+
},
54+
"config": {
55+
"preferred-install": "dist"
56+
},
57+
"extra": {
58+
"branch-alias": {
59+
"dev-master": "1.0-dev"
60+
}
61+
},
62+
"minimum-stability": "dev",
63+
"prefer-stable": true
64+
}

phpunit.xml.dist

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
beStrictAboutTestsThatDoNotTestAnything="true"
5+
beStrictAboutOutputDuringTests="true"
6+
bootstrap="vendor/autoload.php"
7+
colors="true"
8+
convertErrorsToExceptions="true"
9+
convertNoticesToExceptions="true"
10+
convertWarningsToExceptions="true"
11+
processIsolation="false"
12+
stopOnError="false"
13+
stopOnFailure="false"
14+
verbose="true"
15+
>
16+
<testsuites>
17+
<testsuite name="NotifyMe Test Suite">
18+
<directory suffix="Test.php">./tests</directory>
19+
</testsuite>
20+
</testsuites>
21+
<filter>
22+
<whitelist processUncoveredFilesFromWhitelist="true">
23+
<directory suffix=".php">./src</directory>
24+
</whitelist>
25+
</filter>
26+
</phpunit>

src/Adapters/Ballou/BallouFactory.php

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/*
4+
* This file is part of NotifyMe.
5+
*
6+
* (c) Alt Three Services Limited
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace NotifyMeHQ\Adapters\Ballou;
13+
14+
use GuzzleHttp\Client;
15+
use NotifyMeHQ\Contracts\FactoryInterface;
16+
use NotifyMeHQ\Support\Arr;
17+
18+
class BallouFactory implements FactoryInterface
19+
{
20+
/**
21+
* Create a new ballou gateway instance.
22+
*
23+
* @param string[] $config
24+
*
25+
* @return \NotifyMeHQ\Adapters\Ballou\BallouGateway
26+
*/
27+
public function make(array $config)
28+
{
29+
Arr::requires($config, ['token']);
30+
31+
$client = new Client();
32+
33+
return new BallouGateway($client, $config);
34+
}
35+
}

0 commit comments

Comments
 (0)