-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathfanfou-sdk.d.ts
157 lines (147 loc) · 5.04 KB
/
fanfou-sdk.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import { Fanfou } from "fanfou-sdk";
declare module "fanfou-sdk" {
declare namespace Fanfou {
export interface FanfouOptions {
consumerKey: string,
consumerSecret: string,
oauthToken?: string,
oauthTokenSecret?: string,
username?: string,
password?: string,
protocol?: string,
fakeHttps?: boolean,
apiDomain?: string,
oauthDomain?: string,
hooks?: {
baseString?: (str: string) => any;
}
}
}
interface DirectMessage {
id: string;
text: string;
sender_id: string;
recipient_id: string;
created_at: string;
sender_screen_name: string;
recipient_screen_name: string;
sender: User;
recipient: User;
in_reply_to?: DirectMessage;
}
interface Conversation {
dm: DirectMessage;
otherid: string;
msg_num: number;
new_conv: boolean;
}
interface User {
id: string;
name: string;
screen_name: string;
unique_id: string;
location: string;
gender: string;
birthday: string;
description: string;
profile_image_url: string;
profile_image_url_large: string;
url: string;
protected: boolean;
followers_count: number;
friends_count: number;
favourites_count: number;
statuses_count: number;
photo_count: number;
following: boolean;
notifications: boolean;
created_at: string;
utc_offset: number;
profile_background_color: string;
profile_text_color: string;
profile_link_color: string;
profile_sidebar_fill_color: string;
profile_sidebar_border_color: string;
profile_background_image_url: string;
profile_background_tile: boolean;
status?: object;
profile_image_origin: string;
profile_image_origin_large: string;
}
interface Photo {
url: string;
imageurl: string;
thumburl: string;
largeurl: string;
originurl: string;
type: string;
isGif(): boolean;
}
interface Status {
created_at: string;
id: string;
rawid: string;
text: string;
source: string;
truncated: string;
in_reply_to_status_id: string;
in_reply_to_user_id: string;
favorited: boolean;
in_reply_to_screen_name: string;
is_self: string;
location: string;
repost_status_id?: string;
repost_user_id?: string;
repost_screen_name?: string;
repost_status?: Status;
user?: User;
photo?: Photo;
isReply(): boolean;
isRepost(): boolean;
isOrigin(): boolean;
isOriginRepost(): boolean;
type: "reply" | "repost" | "origin" | "unknown";
source_url: string;
source_name: string;
txt: string;
plain_text: string;
}
type TimelineURLs = "/search/public_timeline" | "/search/user_timeline" | "/photos/user_timeline" | "/statuses/friends_timeine" | "/statuses/home_timeline" | "/statuses/public_timeline" | "/statuses/replies" | "/statuses/user_timeline" | "/statuses/context_timeline" | "/statuses/mentions" | "/favorites";
type StatusURLs = "/statuses/update" | "/statuses/show" | "/favorites/destroy" | "/favorites/create" | "/photos/upload";
type UsersURLs = "/users/tagged" | "/users/followers" | "/users/friends" | "/friendships/requests";
type UserURLs = "/users/show" | "/friendships/create" | "/friendships/destroy" | "/account/verify_credentials";
type ConversationURLs = "/direct_messages/conversation" | "/direct_messages/inbox" | "/direct_messages/sent";
type ConversationListURLs = "/direct_messages/conversation_list";
type DirectMessageURLs = "/direct_messages/new" | "/direct_messages/destroy";
export type ParsedData<T> =
T extends TimelineURLs ? Status[] :
T extends UsersURLs ? User[] :
T extends ConversationURLs ? DirectMessage[] :
T extends ConversationListURLs ? Conversation[] :
T extends StatusURLs ? Status :
T extends UserURLs ? User :
T extends DirectMessageURLs ? DirectMessage :
object;
export default class Fanfou {
constructor(opt?: Fanfou.FanfouOptions)
getRequestToken(): this;
getAccessToken(token: {
oauthToken: string,
oauthTokenSecret: string
}): this;
xauth(): this;
get<T extends string>(uri: T, params: object): Promise<ParsedData<T>>;
post<T extends string>(uri: T, params: object): Promise<arsedData<T>>;
oauthEndPoint?: string;
apiEndPoint?: string;
consumerKey?: string;
consumerSecret?: string;
oauthToken?: string;
oauthTokenSecret?: string;
username?: string;
password?: string;
protocol?: string;
apiDomain?: string;
oauthDomain?: string;
}
}