Skip to content

Commit 4fc9a21

Browse files
committed
增加接口地址
1 parent 782ed4a commit 4fc9a21

4 files changed

Lines changed: 317 additions & 1 deletion

File tree

‎.gitignore‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ build/
1212

1313
.idea/
1414

15-
.gradle/
15+
.gradle/
16+
17+
ignoreConfig.dart

‎lib/common/config/Config.dart‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Config {
2+
static const PAGE_SIZE = 20;
3+
}

‎lib/common/net/Address.dart‎

Lines changed: 311 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,311 @@
1+
import 'package:gsy_github_app_flutter/common/config/Config.dart';
2+
3+
///地址数据
4+
class Address {
5+
static const String host = "https://api.github.com/";
6+
static const String hostWeb = "https://github.com/";
7+
static const String downloadUrl = 'https://www.pgyer.com/GSYGithubApp';
8+
static const String graphicHost = 'https://ghchart.rshah.org/';
9+
10+
///获取授权 post
11+
static getAuthorization() {
12+
return "${host}authorizations";
13+
}
14+
15+
///搜索 get
16+
static search(q, sort, order, type, page, [pageSize = Config.PAGE_SIZE]) {
17+
if (type == 'user') {
18+
return "${host}search/users?q=$q&page=$page&per_page=$pageSize";
19+
}
20+
if (sort == null) {
21+
sort = "best%20match";
22+
}
23+
if (order == null) {
24+
order = "desc";
25+
}
26+
if (page == null) {
27+
page = 1;
28+
}
29+
if (pageSize == null) {
30+
pageSize = Config.PAGE_SIZE;
31+
}
32+
return "${host}search/repositories?q=$q&sort=$sort&order=$order&page=$page&per_page=$pageSize";
33+
}
34+
35+
///搜索topic tag
36+
static searchTopic(topic) {
37+
return "${host}search/repositories?q=topic:$topic&sort=stars&order=desc";
38+
}
39+
40+
///用户的仓库 get
41+
static userRepos(userName, sort) {
42+
if (sort == null) {
43+
sort = 'pushed';
44+
}
45+
return "${host}users/$userName/repos?sort=$sort";
46+
}
47+
48+
///仓库详情 get
49+
static getReposDetail(reposOwner, reposName) {
50+
return "${host}repos/$reposOwner/$reposName";
51+
}
52+
53+
///仓库活动 get
54+
static getReposEvent(reposOwner, reposName) {
55+
return "${host}networks/$reposOwner/$reposName/events";
56+
}
57+
58+
///仓库Fork get
59+
static getReposForks(reposOwner, reposName) {
60+
return "${host}repos/$reposOwner/$reposName/forks";
61+
}
62+
63+
///仓库Star get
64+
static getReposStar(reposOwner, reposName) {
65+
return "${host}repos/$reposOwner/$reposName/stargazers";
66+
}
67+
68+
///仓库Watch get
69+
static getReposWatcher(reposOwner, reposName) {
70+
return "${host}repos/$reposOwner/$reposName/subscribers";
71+
}
72+
73+
///仓库提交 get
74+
static getReposCommits(reposOwner, reposName) {
75+
return "${host}repos/$reposOwner/$reposName/commits";
76+
}
77+
78+
///仓库提交详情 get
79+
static getReposCommitsInfo(reposOwner, reposName, sha) {
80+
return "${host}repos/$reposOwner/$reposName/commits/$sha";
81+
}
82+
83+
///仓库Issue get
84+
static getReposIssue(reposOwner, reposName, state, sort, direction) {
85+
if (state == null) {
86+
state = 'all';
87+
}
88+
if (sort == null) {
89+
sort = 'created';
90+
}
91+
if (direction == null) {
92+
direction = 'desc';
93+
}
94+
return "${host}repos/$reposOwner/$reposName/issues?state=$state&sort=$sort&direction=$direction";
95+
}
96+
97+
///仓release get
98+
static getReposRelease(reposOwner, reposName) {
99+
return "${host}repos/$reposOwner/$reposName/releases";
100+
}
101+
102+
///仓Tag get
103+
static getReposTag(reposOwner, reposName) {
104+
return "${host}repos/$reposOwner/$reposName/tags";
105+
}
106+
107+
///仓Contributors get
108+
static getReposContributors(reposOwner, reposName) {
109+
return "${host}repos/$reposOwner/$reposName/contributors";
110+
}
111+
112+
///仓库Issue评论 get
113+
static getIssueComment(reposOwner, reposName, issueNumber) {
114+
return "${host}repos/$reposOwner/$reposName/issues/$issueNumber/comments";
115+
}
116+
117+
///仓库Issue get
118+
static getIssueInfo(reposOwner, reposName, issueNumber) {
119+
return "${host}repos/$reposOwner/$reposName/issues/$issueNumber";
120+
}
121+
122+
///增加issue评论 post
123+
124+
static addIssueComment(reposOwner, reposName, issueNumber) {
125+
return "${host}repos/$reposOwner/$reposName/issues/$issueNumber/comments";
126+
}
127+
128+
///编辑issue put
129+
static editIssue(reposOwner, reposName, issueNumber) {
130+
return "${host}repos/$reposOwner/$reposName/issues/$issueNumber";
131+
}
132+
133+
///锁定issue put
134+
static lockIssue(reposOwner, reposName, issueNumber) {
135+
return "${host}repos/$reposOwner/$reposName/issues/$issueNumber/lock";
136+
}
137+
138+
///创建issue post
139+
static createIssue(reposOwner, reposName) {
140+
return "${host}repos/$reposOwner/$reposName/issues";
141+
}
142+
143+
///搜索issue
144+
static repositoryIssueSearch(q) {
145+
return "${host}search/issues?q=$q";
146+
}
147+
148+
///编辑评论 patch, delete
149+
static editComment(reposOwner, reposName, commentId) {
150+
return "${host}repos/$reposOwner/$reposName/issues/comments/$commentId";
151+
}
152+
153+
///自己的star get
154+
static myStar(sort) {
155+
if (sort == null) {
156+
sort = 'updated';
157+
}
158+
return "${host}users/starred?sort=$sort";
159+
}
160+
161+
///用户的star get
162+
static userStar(userName, sort) {
163+
if (sort == null) {
164+
sort = 'updated';
165+
}
166+
return "${host}users/$userName/starred?sort=$sort";
167+
}
168+
169+
///关注仓库 put
170+
static resolveStarRepos(reposOwner, repos) {
171+
return "${host}user/starred/$reposOwner/$repos";
172+
}
173+
174+
///订阅仓库 put
175+
static resolveWatcherRepos(reposOwner, repos) {
176+
return "${host}user/subscriptions/$reposOwner/$repos";
177+
}
178+
179+
///仓库内容数据 get
180+
static reposData(reposOwner, repos) {
181+
return "${host}repos/$reposOwner/$repos/contents";
182+
}
183+
184+
///仓库路径下的内容 get
185+
static reposDataDir(reposOwner, repos, path, [branch = 'master']) {
186+
return "${host}repos/$reposOwner/$repos/contents/$path" + ((branch == null) ? "" : ("?ref=" + branch));
187+
}
188+
189+
///README 文件地址 get
190+
static readmeFile(reposNameFullName, curBranch) {
191+
return host + "repos/" + reposNameFullName + "/" + "readme" + ((curBranch == null) ? "" : ("?ref=" + curBranch));
192+
}
193+
194+
///我的用户信息 GET
195+
static getMyUserInfo() {
196+
return "${host}user";
197+
}
198+
199+
///用户信息 get
200+
static getUserInfo(userName) {
201+
return "${host}users/$userName";
202+
}
203+
204+
/// get 是否关注
205+
static doFollow(name) {
206+
return "${host}user/following/$name";
207+
}
208+
209+
///用户关注 get
210+
static getUserFollow(userName) {
211+
return "${host}users/$userName/following";
212+
}
213+
214+
///我的关注者 get
215+
static getMyFollower() {
216+
return "${host}user/followers";
217+
}
218+
219+
///用户的关注者 get
220+
static getUserFollower(userName) {
221+
return "${host}users/$userName/followers";
222+
}
223+
224+
///create fork post
225+
static createFork(reposOwner, reposName) {
226+
return "${host}repos/$reposOwner/$reposName/forks";
227+
}
228+
229+
///branch get
230+
static getbranches(reposOwner, reposName) {
231+
return "${host}repos/$reposOwner/$reposName/branches";
232+
}
233+
234+
///fork get
235+
static getForker(reposOwner, reposName, sort) {
236+
if (sort == null) {
237+
sort = 'newest';
238+
}
239+
return "${host}repos/$reposOwner/$reposName/forks?sort=$sort";
240+
}
241+
242+
///readme get
243+
static getReadme(reposOwner, reposName) {
244+
return "${host}repos/$reposOwner/$reposName/readme";
245+
}
246+
247+
///用户收到的事件信息 get
248+
static getEventReceived(userName) {
249+
return "${host}users/$userName/received_events";
250+
}
251+
252+
///用户相关的事件信息 get
253+
static getEvent(userName) {
254+
return "${host}users/$userName/events";
255+
}
256+
257+
///组织成员
258+
static getMember(orgs) {
259+
return "${host}orgs/$orgs/members";
260+
}
261+
262+
///获取用户组织
263+
static getUserOrgs(userName) {
264+
return "${host}users/$userName/orgs";
265+
}
266+
267+
///通知 get
268+
static getNotifation(all, participating) {
269+
if (all == null && participating == null) {
270+
return "${host}notifications";
271+
}
272+
if (all == null) {
273+
all = false;
274+
}
275+
if (participating == null) {
276+
participating = false;
277+
}
278+
return "${host}notifications?all=$all&participating=$participating";
279+
}
280+
281+
///patch
282+
static setNotificationAsRead(threadId) {
283+
return "${host}notifications/threads/$threadId";
284+
}
285+
286+
///put
287+
static setAllNotificationAsRead() {
288+
return "${host}notifications";
289+
}
290+
291+
///趋势 get
292+
static trending(since, languageType) {
293+
if (languageType) {
294+
return "https://github.com/trending/$languageType?since=$since";
295+
}
296+
return "https://github.com/trending?since=$since";
297+
}
298+
299+
///处理分页参数
300+
static getPageParams(tab, page, [pageSize = Config.PAGE_SIZE]) {
301+
if (page != null) {
302+
if (pageSize != null) {
303+
return "${tab}page=$page&per_page=$pageSize";
304+
} else {
305+
return "${tab}page=$page";
306+
}
307+
} else {
308+
return "";
309+
}
310+
}
311+
}

‎lib/common/net/Api.dart‎

Whitespace-only changes.

0 commit comments

Comments
 (0)