Skip to content

Commit 3df13df

Browse files
committed
Merge pull request #1 from polidog/v0.2.0
V0.2.0を作りました。
2 parents 2376f8e + a6b5e5f commit 3df13df

File tree

102 files changed

+3015
-2079
lines changed

Some content is hidden

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

102 files changed

+3015
-2079
lines changed

.coveralls.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# for php-coveralls
2-
src_dir: lib
2+
src_dir: src
33
coverage_clover: build/logs/clover.xml
44
json_path: build/logs/coveralls-upload.json

.scrutinizer.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
filter:
2+
paths:
3+
- 'src/*'
4+
tools:
5+
php_cpd:
6+
enabled: true
7+
excluded_dirs: { }
8+
names:
9+
- '*.php'
10+
min_lines: 5
11+
min_tokens: 70
12+
filter:
13+
paths:
14+
- 'src/*'
15+
php_pdepend:
16+
excluded_dirs:
17+
- vendor
18+
enabled: true
19+
configuration_file: null
20+
suffixes:
21+
- php
22+
filter:
23+
paths:
24+
- 'src/*'
25+
php_changetracking:
26+
enabled: true
27+
bug_patterns:
28+
- '\bfix(?:es|ed)?\b'
29+
feature_patterns:
30+
- '\badd(?:s|ed)?\b'
31+
- '\bimplement(?:s|ed)?\b'
32+
filter:
33+
paths:
34+
- 'src/*'

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
language: php
22

33
php:
4-
- 5.4
54
- 5.5
5+
- 5.6
66
before_script:
77
- composer install --prefer-source
88

@@ -12,10 +12,9 @@ before_script:
1212

1313
script:
1414
- mkdir -p build/logs
15+
- mkdir -p build/cov
1516
- php vendor/bin/phpunit -c phpunit.xml.dist
1617

1718
after_script:
18-
- php vendor/bin/coveralls
19-
# or enable logging
2019
- php vendor/bin/coveralls -v
2120

README.md

Lines changed: 58 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,81 @@ php-chatwork-api
33

44
[![Build Status](https://travis-ci.org/polidog/php-chatwork-api.png?branch=develop)](https://travis-ci.org/polidog/php-chatwork-api)
55
[![Coverage Status](https://coveralls.io/repos/polidog/php-chatwork-api/badge.png)](https://coveralls.io/r/polidog/php-chatwork-api)
6-
[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/polidog/php-chatwork-api/badges/quality-score.png?s=56ea782f70ecfbe3de485e4be2a2c585455e44e3)](https://scrutinizer-ci.com/g/polidog/php-chatwork-api/)
6+
[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/polidog/php-chatwork-api/badges/quality-score.png?s=56ea782f70ecfbe3de485e4be2a2c585455e44e3)](https://scrutinizer-ci.com/g/polidog/php-chatwork-api/)
7+
[![Latest Stable Version](https://poser.pugx.org/polidog/php-chatwork-api/v/stable.svg)](https://packagist.org/packages/polidog/php-chatwork-api)
8+
[![Total Downloads](https://poser.pugx.org/polidog/php-chatwork-api/downloads.svg)](https://packagist.org/packages/polidog/php-chatwork-api)
9+
[![License](https://poser.pugx.org/polidog/php-chatwork-api/license.svg)](https://packagist.org/packages/polidog/php-chatwork-api)
710

11+
[Chatwork](http://www.chatwork.com/ja/) APIをPHPから利用するためのライブラリです。
812

9-
みんな大好きChatWorkのAPIの限定プレビューが始まるということで、早速先走ってAPIラッパークラスをPHPで実装してみました。
10-
まだAPIの使えない僕は、妄想しながら実装したので、動くかどうかは責任とれませんw
13+
## 必要
14+
- PHP5.5+
1115

1216

13-
## インストール方法
17+
## Install
1418

19+
composer.jsonに以下の記述を加えてください。
1520

16-
1\. composer.pharを用意します。
1721
```
18-
$ curl -sS https://getcomposer.org/installer | php
22+
{
23+
"require": {
24+
"polidog/php-chatwork-api": "0.2.*@dev"
25+
}
26+
}
1927
```
20-
2\. comoposer.jsonを用意しましょう
28+
29+
30+
## Quick Example
31+
32+
利用する前に必ずChatWorkのAPIキーを用意しておいてください。
33+
[APIキーの確認方法](http://developer.chatwork.com/ja/authenticate.html)を確認してください。
34+
35+
### オブジェクトを取得する
2136

2237
```
23-
{
24-
"require": {
25-
"polidog/php-chatwork-api": "dev-develop",
26-
"kriswallsmith/buzz": "v0.10"
27-
}
28-
}
38+
// ChatWork API Clientオブジェクトの初期化
39+
$client = new \Polidog\Chatwork\Client("chatwork api token");
40+
```
41+
42+
### 自分自身の情報(APIキーの所有者)
2943

3044
```
31-
3\. インストール
45+
$user = $client->api('me')->show();
3246
47+
// APIのレスポンスはすべてオブジェクトの形で取得できます
48+
var_dump($user);
3349
```
34-
php composer.phar install
50+
51+
### チャットルーム一覧を取得する
52+
53+
```
54+
$rooms = $client->api('rooms')->show();
55+
var_dump($rooms);
3556
```
3657

37-
4\. 実際につかってみる
58+
### チャットルームを作成する
59+
ここちょっと面倒くさい感じになってしまってます。。
60+
3861
```
39-
<?php
40-
require './vendor/autoload.php';
62+
// まずはRoomクラスを用意する
63+
$room = new \Polidog\Chatwork\Entity\Room();
64+
$room->name = 'test chat';
4165
42-
$client = new \Chatwork\Client();
43-
$client->authenticate('your api key');
44-
//var_dump($client->api('me')->show());
45-
//var_dump($client->api('my')->status());
46-
var_dump($client->api('my')->tasks());
66+
// 次にメンバー一覧を用意する
67+
$members = new \Polidog\Chatwork\Entity\Collection\MembersCollection();
68+
$member = new \Polidog\Chatwork\Entity\Member();
69+
$member->role = 'admin';
70+
$member->account = $user;
71+
$members->add($member);
72+
```
73+
74+
### チャットルームのメンバー一覧を取得する
75+
```
76+
$members = $client->api('rooms')->members(123456/* roomidを指定します。*/);
77+
var_dump($members);
78+
79+
```
4780

4881

82+
## 関連リンク
83+
- [ChatWork API](http://developer.chatwork.com/ja/)

composer.json

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "polidog/php-chatwork-api",
3+
"version": "0.2.0",
34
"description": "Chatwork api class",
45
"keywords": ["chatwork","api"],
56
"homepage": "https://github.com/polidog/php-chatwork-api",
@@ -11,14 +12,37 @@
1112
"homepage": "http://www.polidog.jp"
1213
}
1314
],
15+
"repositories":[{
16+
"type": "package",
17+
"package": {
18+
"name": "sebastianbergmann/phpcov",
19+
"version": "1.1.0",
20+
"dist": {
21+
"url": "https://github.com/sebastianbergmann/phpcov/archive/1.1.0.zip",
22+
"type": "zip"
23+
},
24+
"source": {
25+
"url": "https://github.com/sebastianbergmann/phpcov.git",
26+
"type": "git",
27+
"reference": "1.1.0"
28+
},
29+
"bin": [
30+
"phpcov.php"
31+
]
32+
}
33+
}],
1434
"require": {
15-
"kriswallsmith/buzz": "v0.10"
35+
"php": ">=5.5.0",
36+
"guzzlehttp/guzzle": "5.1.0",
37+
"cakephp/utility": "3.0.0-beta3"
1638
},
1739
"require-dev": {
18-
"phpunit/phpunit": "3.7.*",
19-
"satooshi/php-coveralls": "dev-master"
40+
"phpunit/phpunit": "4.4.0",
41+
"phake/phake": "2.0.*@dev",
42+
"satooshi/php-coveralls": "dev-master",
43+
"sebastianbergmann/phpcov": "1.1.0"
2044
},
2145
"autoload": {
22-
"psr-0": {"Chatwork\\": "lib/"}
46+
"psr-4": {"Polidog\\Chatwork\\": "src/"}
2347
}
2448
}

demo.php

Lines changed: 0 additions & 11 deletions
This file was deleted.

demos/index.php

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
require '../vendor/autoload.php';
3+
4+
define('TOKEN', 'your api token');
5+
6+
// create client
7+
$client = new \Polidog\Chatwork\Client(TOKEN);
8+
9+
//// api/me
10+
//$meEntity = $client->api('me')->show();
11+
//var_dump($meEntity);
12+
//
13+
//
14+
//// api/contacts
15+
//$contacts = $client->api('contacts')->show();
16+
//var_dump($contacts);
17+
//
18+
//
19+
//// rooms
20+
//$rooms = $client->api('rooms')->show();
21+
//// room
22+
//$room = $client->api('rooms')->detail(1);
23+
24+
// create room
25+
// $user = $client->api('me')->show();
26+
// $room = new \Polidog\Chatwork\Entity\Room();
27+
// $room->name = "test room name";
28+
// $members = new \Polidog\Chatwork\Entity\Collection\MembersCollection();
29+
// $member = new \Polidog\Chatwork\Entity\Member();
30+
// $member->account = $user;
31+
// $member->role = 'admin';
32+
// $members->add($member);
33+
//
34+
// $client->api('rooms')->create($room, $members);
35+
36+
// room update
37+
//$room = $client->api('rooms')->detail(27161215);
38+
//$room->name = "update test2";
39+
//$room->description = "ディスクリプションだお";
40+
//
41+
//$client->api('rooms')->update($room);
42+
43+
// get room messages
44+
//$messages = $client->api('rooms')->messages(27161215)->show();
45+
//var_dump($messages);
46+
47+
// create message
48+
//$message = new \Polidog\Chatwork\Entity\Message();
49+
//$message->body = "test";
50+
//$client->api('rooms')->messages(27161215)->create($message);
51+
52+
// get members
53+
//$members = $client->api('rooms')->members(27161215)->show();
54+
//var_dump($members);
55+
56+
// update members
57+
//$members = $client->api('rooms')->members(27161215)->show();
58+
//$client->api('rooms')->members(27161215)->update($members);
59+
60+
// get tasks
61+
//$tasks = $client->api('rooms')->tasks(27161215)->show();
62+
//var_dump($tasks);
63+
64+
// get task detail
65+
//$task = $client->api('rooms')->tasks(27161215)->detail(19255236);
66+
//var_dump($task);
67+
68+
// file list
69+
//$files = $client->api('rooms')->files(27161215)->show();
70+
//var_dump($files);
71+
72+
// file detail
73+
//$file = $client->api('rooms')->files(27161215)->detail(26652612);
74+
//var_dump($file);
75+
76+

lib/Chatwork/Api/ApiAbstract.php

Lines changed: 0 additions & 58 deletions
This file was deleted.

lib/Chatwork/Api/ApiInterface.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)