Skip to content

Commit 9044a4c

Browse files
committed
Initial commit
0 parents  commit 9044a4c

File tree

15 files changed

+923
-0
lines changed

15 files changed

+923
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
composer.lock
2+
phpunit.xml
3+
vendor

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
language: php
2+
3+
php:
4+
- 5.3
5+
- 5.4
6+
- 5.5
7+
8+
before_script: composer install --dev --prefer-source

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2013-2014 Rémi Marseille <[email protected]>
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

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
Flowdock library
2+
================
3+
4+
This library allows you to interact with the Flowdock API.
5+
6+
**Basic Docs**
7+
8+
* [Installation](#installation)
9+
* [Push API](#push-api)
10+
* [Contribution](#contribution)
11+
12+
<a name="installation"></a>
13+
14+
## Installation
15+
16+
Only 1 step:
17+
18+
### Download Flowdock using composer
19+
20+
Add Flowdock in your composer.json:
21+
22+
```js
23+
{
24+
"require": {
25+
"mremi/flowdock": "dev-master"
26+
}
27+
}
28+
```
29+
30+
Now tell composer to download the library by running the command:
31+
32+
``` bash
33+
$ php composer.phar update mremi/flowdock
34+
```
35+
36+
Composer will install the library to your project's `vendor/mremi` directory.
37+
38+
<a name="push-api"></a>
39+
40+
## Push API
41+
42+
### Chat
43+
44+
```php
45+
<?php
46+
47+
use Mremi\Flowdock\Api\Push\Chat\Chat;
48+
use Mremi\Flowdock\Api\Push\Chat\Message;
49+
50+
$message = new Message;
51+
$message
52+
->setContent('This message has been sent with mremi/flowdock PHP library')
53+
->setExternalUserName('mremi')
54+
->addTag('#hello-world');
55+
56+
$chat = new Chat('your_flow_api_token');
57+
58+
if (!$chat->sendMessage($message)) {
59+
// handle errors...
60+
$message->getErrors();
61+
}
62+
```
63+
64+
<a name="contribution"></a>
65+
66+
## Contribution
67+
68+
Any question or feedback? Open an issue and I will try to reply quickly.
69+
70+
A feature is missing here? Feel free to create a pull request to solve it!
71+
72+
I hope this has been useful and has helped you. If so, share it and recommend
73+
it! :)
74+
75+
[@mremitsme](https://twitter.com/mremitsme)

composer.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "mremi/flowdock",
3+
"type": "library",
4+
"description": "A PHP5 library to interact with the Flowdock API",
5+
"keywords": ["flowdock", "api"],
6+
"homepage": "https://github.com/mremi/Flowdock",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Rémi Marseille",
11+
"email": "[email protected]"
12+
}
13+
],
14+
"require": {
15+
"php": ">=5.3.3",
16+
"guzzle/guzzle": "~3.7"
17+
},
18+
"require-dev":{
19+
"phpunit/phpunit": "~4.1"
20+
},
21+
"autoload": {
22+
"psr-0": { "Mremi\\Flowdock": "src" }
23+
}
24+
}

phpunit.xml.dist

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
syntaxCheck="false"
12+
bootstrap="vendor/autoload.php"
13+
>
14+
<testsuites>
15+
<testsuite name="Flowdock Test Suite">
16+
<directory>./tests</directory>
17+
</testsuite>
18+
</testsuites>
19+
20+
<filter>
21+
<whitelist>
22+
<directory>./src</directory>
23+
<exclude>
24+
<directory>./tests</directory>
25+
<directory>./vendor</directory>
26+
</exclude>
27+
</whitelist>
28+
</filter>
29+
30+
</phpunit>
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Mremi\Flowdock library.
5+
*
6+
* (c) Rémi Marseille <[email protected]>
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 Mremi\Flowdock\Api\Push;
13+
14+
/**
15+
* Base push message class
16+
*
17+
* @author Rémi Marseille <[email protected]>
18+
*/
19+
abstract class BaseMessage implements BaseMessageInterface
20+
{
21+
/**
22+
* @var string
23+
*/
24+
protected $content;
25+
26+
/**
27+
* @var array
28+
*/
29+
protected $tags = array();
30+
31+
/**
32+
* @var array
33+
*/
34+
protected $errors = array();
35+
36+
/**
37+
* {@inheritdoc}
38+
*/
39+
public function setContent($content)
40+
{
41+
$this->content = $content;
42+
43+
return $this;
44+
}
45+
46+
/**
47+
* {@inheritdoc}
48+
*/
49+
public function getContent()
50+
{
51+
return $this->content;
52+
}
53+
54+
/**
55+
* {@inheritdoc}
56+
*/
57+
public function addTag($tag)
58+
{
59+
$this->tags[] = $tag;
60+
61+
return $this;
62+
}
63+
64+
/**
65+
* {@inheritdoc}
66+
*/
67+
public function getTags()
68+
{
69+
return $this->tags;
70+
}
71+
72+
/**
73+
* {@inheritdoc}
74+
*/
75+
public function addError($error)
76+
{
77+
$this->errors[] = $error;
78+
79+
return $this;
80+
}
81+
82+
/**
83+
* {@inheritdoc}
84+
*/
85+
public function getErrors()
86+
{
87+
return $this->errors;
88+
}
89+
90+
/**
91+
* {@inheritdoc}
92+
*/
93+
public function hasErrors()
94+
{
95+
return count($this->errors) > 0;
96+
}
97+
98+
/**
99+
* {@inheritdoc}
100+
*/
101+
public function toArray()
102+
{
103+
return array(
104+
'content' => $this->content,
105+
'tags' => $this->tags,
106+
);
107+
}
108+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Mremi\Flowdock library.
5+
*
6+
* (c) Rémi Marseille <[email protected]>
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 Mremi\Flowdock\Api\Push;
13+
14+
/**
15+
* Base push message interface
16+
*
17+
* @author Rémi Marseille <[email protected]>
18+
*/
19+
interface BaseMessageInterface
20+
{
21+
/**
22+
* Sets the content of the message
23+
*
24+
* @param string $content
25+
*
26+
* @return BaseMessageInterface
27+
*/
28+
public function setContent($content);
29+
30+
/**
31+
* Gets the content of the message
32+
*
33+
* @return string
34+
*/
35+
public function getContent();
36+
37+
/**
38+
* Adds a tag to the message
39+
*
40+
* @param string $tag
41+
*
42+
* @return BaseMessageInterface
43+
*/
44+
public function addTag($tag);
45+
46+
/**
47+
* Gets the message tags
48+
*
49+
* @return array
50+
*/
51+
public function getTags();
52+
53+
/**
54+
* Adds an error to the message
55+
*
56+
* @param string $error
57+
*
58+
* @return BaseMessageInterface
59+
*/
60+
public function addError($error);
61+
62+
/**
63+
* Gets the message errors
64+
*
65+
* @return array
66+
*/
67+
public function getErrors();
68+
69+
/**
70+
* Returns TRUE whether the message has some errors
71+
*
72+
* @return boolean
73+
*/
74+
public function hasErrors();
75+
76+
/**
77+
* Returns an array representation of the message
78+
*
79+
* @return array
80+
*/
81+
public function toArray();
82+
}

0 commit comments

Comments
 (0)