forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple-cw-node.d.ts
86 lines (68 loc) · 3.43 KB
/
simple-cw-node.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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;
}