Skip to content

Commit

Permalink
add favorites apis; add jscoverage result to readme.md.
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Sep 30, 2012
1 parent 49cd414 commit 637b0cb
Show file tree
Hide file tree
Showing 18 changed files with 2,536 additions and 635 deletions.
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -19,6 +19,7 @@ test-g:
test-cov: test-cov:
@rm -rf ./lib-cov @rm -rf ./lib-cov
@$(MAKE) lib-cov @$(MAKE) lib-cov
@WEIBO_COV=1 $(MAKE) test REPORTER=dot
@WEIBO_COV=1 $(MAKE) test REPORTER=html-cov > coverage.html @WEIBO_COV=1 $(MAKE) test REPORTER=html-cov > coverage.html


lib-cov: lib-cov:
Expand Down
9 changes: 9 additions & 0 deletions README.md
Expand Up @@ -165,6 +165,15 @@ app.listen(8088);
console.log('Server start on http://localhost:8088/'); console.log('Server start on http://localhost:8088/');
``` ```


## Test

```bash
$ npm install
$ npm test
```

jscoverage: [79%](http://fengmk2.github.com/coverage/node-weibo.html)

## Authors ## Authors


Below is the output from `git-summary`. Below is the output from `git-summary`.
Expand Down
109 changes: 109 additions & 0 deletions api.md
Expand Up @@ -31,6 +31,13 @@ All apis and data in `node-weibo` will convert to this unity format.
| * [comments_timeline](#comments_timeline)(user[, cursor], callback)|List comments to my statues|[weibo], [tqq]| | * [comments_timeline](#comments_timeline)(user[, cursor], callback)|List comments to my statues|[weibo], [tqq]|
| * [comments_to_me](#comments_to_me)(user[, cursor], callback)|List comments to me|[weibo]| | * [comments_to_me](#comments_to_me)(user[, cursor], callback)|List comments to me|[weibo]|
| * [comments_by_me](#comments_by_me)(user[, cursor], callback)|List comments by me|[weibo]| | * [comments_by_me](#comments_by_me)(user[, cursor], callback)|List comments by me|[weibo]|
| **[Favorite](#favorite) APIs** |||
| Write |||
| * [favorite_create](#favorite_create)(user, id, callback)|Add a status to favorites|[weibo], [tqq]|
| * [favorite_destroy](#favorite_destroy)(user, id, callback)|Remove the status from favorites|[weibo], [tqq]|
| Read |||
| * [favorites](#favorites)(user[, cursor], callback)|List favorites|[weibo], [tqq]|
| * [favorite_show](#favorite_show)(user, id, callback)|Show a favorite item|[weibo], [tqq]|
| **[Message](#message) APIs** ||| | **[Message](#message) APIs** |||
| Write ||| | Write |||
| * [message_create](#message_create)(user, text, id, callback)|post a message to some one|-| | * [message_create](#message_create)(user, text, id, callback)|post a message to some one|-|
Expand Down Expand Up @@ -578,6 +585,80 @@ comment_reply: function (user, cid, id, comment, callback)
comment_destroy: function (user, cid, callback) { comment_destroy: function (user, cid, callback) {
``` ```
## Favorite APIs
### favorites
```js
/**
* List favorites.
*
* @param {User} user
* @param {Cursor} [cursor]
* - {String} since_id
* - {String} max_id
* - {String} [since_time], only for tqq
* - {String} [max_time], only for tqq
* - {Number} count, default is `20`
* - {Number} page
* @param {Function(err, result)} callback
* {Object} result:
* - {Array} items, [Favorite, ...]
* - {Cursor} cursor
* - ...
* @return {Context} this
*/
favorites: function (user, cursor, callback)
```

### favorite_show

```js
/**
* Show a favorite item by item id.
*
* @param {User} user
* @param {String} id, favorite item's id.
* @param {Function(err, favorite)} callback
* @return {Context} this
*/
favorite_show: function (user, id, callback)
```

### favorite_create

```js
/**
* Add a status to favorites.
*
* @param {User} user
* @param {String} id, status's id.
* @param {Function(err, result)} callback
* - {Object} result
* - {String} id, relation item's id.
* - addtional infomation maybe.
* @return {Context} this
*/
favorite_create: function (user, id, callback)
```

### favorite_destroy

```js
/**
* Remove the status from favorites.
*
* @param {User} user
* @param {String} id, the favorite item's id.
* @param {Function(err, result)} callback
* - {Object} result
* - {String} id, relation item's id.
* - addtional infomation maybe.
* @return {Context} this
*/
favorite_destroy: function (user, id, callback)
```

## Data Structure ## Data Structure


### Status ### Status
Expand Down Expand Up @@ -942,6 +1023,34 @@ Demo:
] ]
``` ```


### Favorite

|Field name|Data Type|Description|Demo|
|----------|---------|-----------|----|
|status|[Status]|Status detail infomation|`{id: "123123", text: "foo", ...}`|
|[tags]|Array|Favorite item's tag list|`[{id: '123', tag: 'funny'}, ...]`|
|[created_at]|Date|favorite item create time|`new Date("Thu Jun 02 15:16:16 +0800 2011")`|
Demo:
```js
{
"status": {
"id": "11488058246",
"text": "求关注。",
// ...
},
"tags": [
{
"id": 23,
"tag": "80后"
},
// ...
],
"favorited_time": new Date("Thu Jun 02 15:16:16 +0800 2011")
}
```
## OAuth ## OAuth
### RequestToken ### RequestToken
Expand Down

0 comments on commit 637b0cb

Please sign in to comment.