forked from CarGuo/gsy_github_app_flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddress.dart
More file actions
288 lines (235 loc) · 7.56 KB
/
Address.dart
File metadata and controls
288 lines (235 loc) · 7.56 KB
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
import 'package:gsy_github_app_flutter/common/config/Config.dart';
///地址数据
class Address {
static const String host = "https://api.github.com/";
static const String hostWeb = "https://github.com/";
static const String downloadUrl = 'https://www.pgyer.com/GSYGithubApp';
static const String graphicHost = 'https://ghchart.rshah.org/';
static const String updateUrl = 'https://www.pgyer.com/vj2B';
///获取授权 post
static getAuthorization() {
return "${host}authorizations";
}
///搜索 get
static search(q, sort, order, type, page, [pageSize = Config.PAGE_SIZE]) {
if (type == 'user') {
return "${host}search/users?q=$q&page=$page&per_page=$pageSize";
}
sort ??= "best%20match";
order ??= "desc";
page ??= 1;
pageSize ??= Config.PAGE_SIZE;
return "${host}search/repositories?q=$q&sort=$sort&order=$order&page=$page&per_page=$pageSize";
}
///搜索topic tag
static searchTopic(topic) {
return "${host}search/repositories?q=topic:$topic&sort=stars&order=desc";
}
///用户的仓库 get
static userRepos(userName, sort) {
sort ??= 'pushed';
return "${host}users/$userName/repos?sort=$sort";
}
///仓库详情 get
static getReposDetail(reposOwner, reposName) {
return "${host}repos/$reposOwner/$reposName";
}
///仓库活动 get
static getReposEvent(reposOwner, reposName) {
return "${host}networks/$reposOwner/$reposName/events";
}
///仓库Fork get
static getReposForks(reposOwner, reposName) {
return "${host}repos/$reposOwner/$reposName/forks";
}
///仓库Star get
static getReposStar(reposOwner, reposName) {
return "${host}repos/$reposOwner/$reposName/stargazers";
}
///仓库Watch get
static getReposWatcher(reposOwner, reposName) {
return "${host}repos/$reposOwner/$reposName/subscribers";
}
///仓库提交 get
static getReposCommits(reposOwner, reposName) {
return "${host}repos/$reposOwner/$reposName/commits";
}
///仓库提交详情 get
static getReposCommitsInfo(reposOwner, reposName, sha) {
return "${host}repos/$reposOwner/$reposName/commits/$sha";
}
///仓库Issue get
static getReposIssue(reposOwner, reposName, state, sort, direction) {
state ??= 'all';
sort ??= 'created';
direction ??= 'desc';
return "${host}repos/$reposOwner/$reposName/issues?state=$state&sort=$sort&direction=$direction";
}
///仓release get
static getReposRelease(reposOwner, reposName) {
return "${host}repos/$reposOwner/$reposName/releases";
}
///仓Tag get
static getReposTag(reposOwner, reposName) {
return "${host}repos/$reposOwner/$reposName/tags";
}
///仓Contributors get
static getReposContributors(reposOwner, reposName) {
return "${host}repos/$reposOwner/$reposName/contributors";
}
///仓库Issue评论 get
static getIssueComment(reposOwner, reposName, issueNumber) {
return "${host}repos/$reposOwner/$reposName/issues/$issueNumber/comments";
}
///仓库Issue get
static getIssueInfo(reposOwner, reposName, issueNumber) {
return "${host}repos/$reposOwner/$reposName/issues/$issueNumber";
}
///增加issue评论 post
static addIssueComment(reposOwner, reposName, issueNumber) {
return "${host}repos/$reposOwner/$reposName/issues/$issueNumber/comments";
}
///编辑issue put
static editIssue(reposOwner, reposName, issueNumber) {
return "${host}repos/$reposOwner/$reposName/issues/$issueNumber";
}
///锁定issue put
static lockIssue(reposOwner, reposName, issueNumber) {
return "${host}repos/$reposOwner/$reposName/issues/$issueNumber/lock";
}
///创建issue post
static createIssue(reposOwner, reposName) {
return "${host}repos/$reposOwner/$reposName/issues";
}
///搜索issue
static repositoryIssueSearch(q) {
return "${host}search/issues?q=$q";
}
///编辑评论 patch, delete
static editComment(reposOwner, reposName, commentId) {
return "${host}repos/$reposOwner/$reposName/issues/comments/$commentId";
}
///自己的star get
static myStar(sort) {
sort ??= 'updated';
return "${host}users/starred?sort=$sort";
}
///用户的star get
static userStar(userName, sort) {
sort ??= 'updated';
return "${host}users/$userName/starred?sort=$sort";
}
///关注仓库 put
static resolveStarRepos(reposOwner, repos) {
return "${host}user/starred/$reposOwner/$repos";
}
///订阅仓库 put
static resolveWatcherRepos(reposOwner, repos) {
return "${host}user/subscriptions/$reposOwner/$repos";
}
///仓库内容数据 get
static reposData(reposOwner, repos) {
return "${host}repos/$reposOwner/$repos/contents";
}
///仓库路径下的内容 get
static reposDataDir(reposOwner, repos, path, [branch = 'master']) {
return "${host}repos/$reposOwner/$repos/contents/$path" + ((branch == null) ? "" : ("?ref=" + branch));
}
///README 文件地址 get
static readmeFile(reposNameFullName, curBranch) {
return host + "repos/" + reposNameFullName + "/" + "readme" + ((curBranch == null) ? "" : ("?ref=" + curBranch));
}
///我的用户信息 GET
static getMyUserInfo() {
return "${host}user";
}
///用户信息 get
static getUserInfo(userName) {
return "${host}users/$userName";
}
/// get 是否关注
static doFollow(name) {
return "${host}user/following/$name";
}
///用户关注 get
static getUserFollow(userName) {
return "${host}users/$userName/following";
}
///我的关注者 get
static getMyFollower() {
return "${host}user/followers";
}
///用户的关注者 get
static getUserFollower(userName) {
return "${host}users/$userName/followers";
}
///create fork post
static createFork(reposOwner, reposName) {
return "${host}repos/$reposOwner/$reposName/forks";
}
///branch get
static getbranches(reposOwner, reposName) {
return "${host}repos/$reposOwner/$reposName/branches";
}
///fork get
static getForker(reposOwner, reposName, sort) {
sort ??= 'newest';
return "${host}repos/$reposOwner/$reposName/forks?sort=$sort";
}
///readme get
static getReadme(reposOwner, reposName) {
return "${host}repos/$reposOwner/$reposName/readme";
}
///用户收到的事件信息 get
static getEventReceived(userName) {
return "${host}users/$userName/received_events";
}
///用户相关的事件信息 get
static getEvent(userName) {
return "${host}users/$userName/events";
}
///组织成员
static getMember(orgs) {
return "${host}orgs/$orgs/members";
}
///获取用户组织
static getUserOrgs(userName) {
return "${host}users/$userName/orgs";
}
///通知 get
static getNotifation(all, participating) {
if ((all == null && participating == null) || (all == false && participating == false)) {
return "${host}notifications";
}
all ??= false;
participating ??= false;
return "${host}notifications?all=$all&participating=$participating";
}
///patch
static setNotificationAsRead(threadId) {
return "${host}notifications/threads/$threadId";
}
///put
static setAllNotificationAsRead() {
return "${host}notifications";
}
///趋势 get
static trending(since, languageType) {
if (languageType != null) {
return "https://github.com/trending/$languageType?since=$since";
}
return "https://github.com/trending?since=$since";
}
///处理分页参数
static getPageParams(tab, page, [pageSize = Config.PAGE_SIZE]) {
if (page != null) {
if (pageSize != null) {
return "${tab}page=$page&per_page=$pageSize";
} else {
return "${tab}page=$page";
}
} else {
return "";
}
}
}