mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Added simple-cw-node.d.ts and tests
This commit is contained in:
parent
6792863658
commit
22ec65950a
@ -208,6 +208,7 @@ List of Definitions
|
||||
* [Sencha Touch](http://www.sencha.com/products/touch/) (by [Brian Kotek](https://github.com/brian428))
|
||||
* [SharePoint](http://sptypescript.codeplex.com) (by [Stanislav Vyshchepan](http://gandjustas.blogspot.ru) and [Andrey Markeev](http://markeev.com))
|
||||
* [SignalR](http://www.asp.net/signalr) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [simple-cw-node](https://github.com/astronaughts/simple-cw-node) (by [vvakame](https://github.com/vvakame))
|
||||
* [Sinon](http://sinonjs.org/) (by [William Sears](https://github.com/mrbigdog2u))
|
||||
* [SlickGrid](https://github.com/mleibman/SlickGrid) (by [Josh Baldwin](https://github.com/jbaldwin))
|
||||
* [socket.io](http://socket.io) (by [William Orr](https://github.com/worr))
|
||||
|
||||
33
simple-cw-node/simple-cw-node-test.ts
Normal file
33
simple-cw-node/simple-cw-node-test.ts
Normal file
@ -0,0 +1,33 @@
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
/// <reference path="./simple-cw-node.d.ts" />
|
||||
|
||||
import CW = require('simple-cw-node');
|
||||
var client = CW();
|
||||
var Deferred:any = client.Deferred;
|
||||
|
||||
// initialize.
|
||||
client.init({ token: 'YOUR_TOKEN' });
|
||||
|
||||
// get your info.
|
||||
client.get('me', (err, res) => {
|
||||
console.log(arguments);
|
||||
});
|
||||
|
||||
// create room.
|
||||
client.post('rooms', {
|
||||
name: 'room',
|
||||
members_admin_ids: '123456789,987654321',
|
||||
description: 'description'
|
||||
}, (err, res) => {
|
||||
console.log('created.');
|
||||
});
|
||||
|
||||
client
|
||||
.get('me')
|
||||
.done((res:any) => {
|
||||
console.log(res.body)
|
||||
})
|
||||
.fail((err:any) => {
|
||||
console.error(err);
|
||||
});
|
||||
86
simple-cw-node/simple-cw-node.d.ts
vendored
Normal file
86
simple-cw-node/simple-cw-node.d.ts
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
// Type definitions for simple-cw-node
|
||||
// Project: https://github.com/astronaughts/simple-cw-node
|
||||
// Definitions by: vvakame <https://github.com/vvakame>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../superagent/superagent.d.ts" />
|
||||
|
||||
declare module "simple-cw-node" {
|
||||
import superagent = require("superagent");
|
||||
// TODO 1. update superagent with generics
|
||||
// TODO 2. create underscore.deffered .d.ts file
|
||||
// TODO 3. refactor & improve specialized parameter methods
|
||||
|
||||
// Merged declaration, ChatWork is both a callable function and a namespace
|
||||
function ChatWork():ChatWork.ChatWork;
|
||||
|
||||
module ChatWork {
|
||||
interface ChatWorkInitOptions {
|
||||
token:string;
|
||||
}
|
||||
|
||||
interface ChatWork {
|
||||
apiVersion:string;
|
||||
sdkVersion:string;
|
||||
token:string;
|
||||
Deferred: any; // _.Deferred
|
||||
when: any; // _.when
|
||||
|
||||
init(options:ChatWorkInitOptions):void;
|
||||
|
||||
// http://developer.chatwork.com/ja/endpoint_me.html
|
||||
get(api:"me", callback:(err:Error, res:superagent.Response)=>void):void;
|
||||
|
||||
// http://developer.chatwork.com/ja/endpoint_my.html
|
||||
get(api:"my/status", callback:(err:Error, res:superagent.Response)=>void):void;
|
||||
get(api:"my/tasks", callback:(err:Error, res:superagent.Response)=>void):void;
|
||||
|
||||
// http://developer.chatwork.com/ja/endpoint_contacts.html
|
||||
get(api:"contacts", callback:(err:Error, res:superagent.Response)=>void):void;
|
||||
|
||||
// http://developer.chatwork.com/ja/endpoint_rooms.html
|
||||
get(api:"rooms", callback:(err:Error, res:superagent.Response)=>void):void;
|
||||
post(api:"rooms", args:any, callback:(err:Error, res:superagent.Response)=>void):void;
|
||||
|
||||
// can't create specialized parameter
|
||||
// specialized parameter required compile-time constant string literal
|
||||
// GET /rooms/{room_id}
|
||||
// PUT /rooms/{room_id}
|
||||
// DELETE /rooms/{room_id}
|
||||
// GET /rooms/{room_id}/members
|
||||
// PUT /rooms/{room_id}/members
|
||||
// GET /rooms/{room_id}/messages <- not implemented yet
|
||||
// POST /rooms/{room_id}/messages
|
||||
// GET /rooms/{room_id}/messages/{message_id}
|
||||
// GET /rooms/{room_id}/tasks
|
||||
// POST /rooms/{room_id}/tasks
|
||||
// GET /rooms/{room_id}/tasks/{task_id}
|
||||
// GET /rooms/{room_id}/files
|
||||
// GET /rooms/{room_id}/files/{file_id}
|
||||
|
||||
// General functions
|
||||
|
||||
api(method:string, api:string):any; // return same type as _.Deferred()
|
||||
api(method:string, api:string, callback:(err:Error, res:superagent.Response)=>void):void;
|
||||
api(method:string, api:string, args:any, callback:(err:Error, res:superagent.Response)=>void):void;
|
||||
|
||||
get(api:string):any; // return same type as _.Deferred()
|
||||
get(api:string, callback:(err:Error, res:superagent.Response)=>void):void;
|
||||
get(api:string, args:any, callback:(err:Error, res:superagent.Response)=>void):void;
|
||||
|
||||
post(api:string):any; // return same type as _.Deferred()
|
||||
post(api:string, callback:(err:Error, res:superagent.Response)=>void):void;
|
||||
post(api:string, args:any, callback:(err:Error, res:superagent.Response)=>void):void;
|
||||
|
||||
put(api:string):any; // return same type as _.Deferred()
|
||||
put(api:string, callback:(err:Error, res:superagent.Response)=>void):void;
|
||||
put(api:string, args:any, callback:(err:Error, res:superagent.Response)=>void):void;
|
||||
|
||||
del(api:string):any; // return same type as _.Deferred()
|
||||
del(api:string, callback:(err:Error, res:superagent.Response)=>void):void;
|
||||
del(api:string, args:any, callback:(err:Error, res:superagent.Response)=>void):void;
|
||||
}
|
||||
}
|
||||
|
||||
export = ChatWork;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user