Skip to content

Commit d3abf92

Browse files
author
Ian Duncan
committed
Add all the things.
1 parent 1611e5e commit d3abf92

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1839
-0
lines changed

src/GitHub.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module GitHub where
2+
import GitHub.Internal

src/GitHub/Activity/Events.hs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{-# LANGUAGE QuasiQuotes #-}
2+
module GitHub.Activity.Events where
3+
import GitHub.Internal
4+
5+
events = "/events"
6+
repoEvents o r = ownerRepo o r <> events
7+
issueEvents o r = ownerRepo o r <> "/issues" <> events
8+
networkEvents o r = [uri| /networks/{o}/{r}/events |]
9+
orgEvents o = [uri|/orgs/{o}/events |]
10+
users u = [uri| /users/{u} |]
11+
12+
-- | GET /events
13+
listPublicEvents ::
14+
GitHub (Request EventsData)
15+
listPublicEvents = get events
16+
17+
-- | GET /repos/:owner/:repo/events
18+
listRepositoryEvents ::
19+
OwnerName ->
20+
RepoName ->
21+
GitHub EventsData
22+
listRepositoryEvents o r = get $ repoEvents o r
23+
24+
-- | GET /repos/:owner/:repo/issues/events
25+
listIssueEvents ::
26+
OwnerName ->
27+
RepoName ->
28+
GitHub EventsData
29+
listIssueEvents o r = get $ issueEvents o r
30+
31+
-- | GET /networks/:owner/:repo/events
32+
listRepositoryNetworkEvents ::
33+
OwnerName ->
34+
RepoName ->
35+
GitHub EventsData
36+
listRepositoryNetworkEvents o r = get $ networkEvents o r
37+
38+
-- | GET /orgs/:org/events
39+
listPublicOrganizationEvents ::
40+
OrgName ->
41+
GitHub EventsData
42+
listPublicOrganizationEvents o = get $ orgEvents o
43+
44+
-- | GET /users/:user/received_events
45+
listUserReceivedEvents ::
46+
UserName ->
47+
GitHub EventsData
48+
listUserReceivedEvents u = get (users u <> "/received_events")
49+
50+
-- | GET /users/:user/received_events/public
51+
listPublicUserReceivedEvents ::
52+
UserName ->
53+
GitHub EventsData
54+
listPublicUserReceivedEvents u = get (user u <> "/received_events/public")
55+
56+
-- | GET /users/:user/events
57+
listUserPerformedEvents ::
58+
UserName ->
59+
GitHub EventsData
60+
listUserPerformedEvents u = get (user u <> events)
61+
62+
-- | GET /users/:user/events/public
63+
listPublicUserPerformedEvents ::
64+
UserName ->
65+
GitHub EventsData
66+
listPublicUserPerformedEvents = get (user u <> events <> "/public")
67+
68+
-- | GET /users/:user/events/orgs/:org
69+
listUserOrganizationEvents ::
70+
UserName ->
71+
OrgName ->
72+
GitHub EventsData
73+
listUserOrganizationEvents = undefined -- TODO TODO TODO
74+
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
module GitHub.Activity.Notifications where
2+
import GitHub.Internal
3+
4+
notifications = "/notifications"
5+
thread i = notifications <> "/threads/" <> i
6+
subscription = thread i <> "/subscription"
7+
repoNotifications o r = ownerRepo o r <> "/notifications"
8+
9+
mParam :: IsString s => s -> Maybe s -> Maybe (s, s)
10+
11+
-- GET /notifications
12+
listNotifications ::
13+
Maybe Bool ->
14+
Maybe Bool ->
15+
Maybe UTCTime ->
16+
GitHub NotificationData
17+
listNotifications a p s = ghGet
18+
[ mParam "all" a
19+
, mParam "participating" p
20+
, mParam "since" s
21+
]
22+
$ notifications
23+
24+
-- GET /repos/:owner/:repo/notifications
25+
listRepositoryNotifications ::
26+
OwnerName ->
27+
RepoName ->
28+
Maybe Bool ->
29+
Maybe Bool ->
30+
Maybe UTCTime ->
31+
GitHub NotificationData
32+
listRepositoryNotifications o r a p s = ghGet
33+
[ mParam "all" a
34+
, mParam "participating" p
35+
, mParam "since" s
36+
]
37+
$ repoNotifications o r
38+
39+
-- PUT /notifications
40+
markNotificationsRead ::
41+
Maybe UTCTime ->
42+
GitHub NotificationData
43+
markNotificationsRead o r s = ghPut' notifications []
44+
45+
-- PUT /repos/:owner/:repo/notifications
46+
markRepositoryNotificationsRead ::
47+
OwnerName ->
48+
RepoName ->
49+
Maybe UTCTime ->
50+
GitHub NotificationData
51+
markRepositoryNotificationsRead o r t = ghPut (repoNotifications o r) $ NotificationsReadOptions t
52+
53+
-- GET /notifications/threads/:id
54+
getNotificationThread ::
55+
Int ->
56+
GitHub NotificationThreadData
57+
getNotificationThread = ghGet [] . thread
58+
59+
-- PATCH /notifications/threads/:id
60+
markNotificationThreadRead ::
61+
Int ->
62+
GitHub ()
63+
markNotificationThreadRead = ghPatch' . thread
64+
65+
-- GET /notifications/threads/:id/subscription
66+
getThreadSubscription ::
67+
Int ->
68+
GitHub ThreadSubscriptionData
69+
getThreadSubscription = ghGet [] . subscription
70+
71+
-- PUT /notifications/threads/:id/subscription
72+
setThreadSubscription ::
73+
Int ->
74+
NewSubscription ->
75+
GitHub ThreadSubscriptionData
76+
setThreadSubscription i = ghPut (subscription i)
77+
78+
-- DELETE /notifications/threads/:id/subscription
79+
deleteThreadSubscription ::
80+
Int ->
81+
GitHub ()
82+
deleteThreadSubscription = ghDelete . subscription

src/GitHub/Activity/Starring.hs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module GitHub.Activity.Starring where
2+
import GitHub.Internal
3+
4+
data Direction = Ascending | Descending
5+
data StarredRepositoriesSortBy = Created | Updated
6+
7+
--| GET /repos/:owner/:repo/stargazers
8+
listStargazers ::
9+
Username ->
10+
Reponame ->
11+
Maybe StarredRepositoriesSortBy ->
12+
Maybe Direction
13+
GitHub StargazersData
14+
15+
--| GET /users/:user/starred
16+
listStarredRepositories ::
17+
Username ->
18+
Maybe StarredRepositoriesSortBy
19+
Maybe Direction
20+
GitHub StarredRepositoriesData
21+
22+
--| GET /user/starred
23+
listCurrentUserStarredRepositories ::
24+
Maybe StarredRepositoriesSortBy
25+
Maybe Direction
26+
GitHub StarredRepositoriesData
27+
28+
--| GET /user/starred/:owner/:repo
29+
isRepositoryStarred ::
30+
Username ->
31+
Reponame ->
32+
GitHub Bool
33+
34+
--| PUT /user/starred/:owner/:repo
35+
starRepository ::
36+
Username ->
37+
Reponame ->
38+
GitHub ()
39+
40+
--| DELETE /user/starred/:owner/:repo
41+
unstarRepository ::
42+
Username ->
43+
Reponame ->
44+
GitHub ()

src/GitHub/Activity/Watching.hs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
module GitHub.Activity.Watching where
2+
import GitHub.Internal
3+
4+
subscription u r = ownedRepo u r <> "/subscription"
5+
6+
--| GET /repos/:owner/:repo/subscribers
7+
listWatchers ::
8+
OwnerName ->
9+
RepoName ->
10+
GitHub WatchersData
11+
listWatchers u r = ghGet (ownedRepo u r <> "/subscribers")
12+
13+
--| GET /users/:user/subscriptions
14+
listWatchedRepositories ::
15+
UserName ->
16+
GitHub WatchedRepoData
17+
18+
--| GET /user/subscriptions
19+
listCurrentUserWatchedRepositories ::
20+
GitHub WatchedRepoData
21+
listCurrentUserWatchedRepositories = ghGet "/user/subscriptions"
22+
23+
--| GET /repos/:owner/:repo/subscription
24+
getRepositorySubscription ::
25+
Username ->
26+
Reponame ->
27+
GitHub RepositorySubscriptionData
28+
getRepositorySubscription u r = ghGet $ subscription u r
29+
30+
--| PUT /repos/:owner/:repo/subscription
31+
setRepositorySubscription ::
32+
Username ->
33+
Reponame ->
34+
RepositorySubscriptionSettings
35+
GitHub RepositorySubscriptionData
36+
setRepositorySubscription u r = ghPut $ subscription u r
37+
38+
--| DELETE /repos/:owner/:repo/subscription
39+
deleteRepositorySubscription ::
40+
Username ->
41+
Reponame ->
42+
GitHub ()
43+
deleteRepositorySubscription u r = ghDelete $ subscription u r

src/GitHub/Gists.hs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
module GitHub.Gists where
2+
import GitHub.Internal
3+
4+
gists = "/gists"
5+
public = gists <> "/public"
6+
starred = gists <> "/starred"
7+
gist i = gists <> "/" <> i
8+
star i = gists i <> "/star"
9+
forks i = gists i <> "/forks"
10+
11+
--| GET /users/:user/gists
12+
listUserGists ::
13+
UserName ->
14+
GitHub GistsData
15+
listUserGists u = ghGet (user u <> gists)
16+
17+
--| GET /gists
18+
listCurrentUserGists ::
19+
GitHub GistsData
20+
listCurrentUserGists = ghGet gists
21+
22+
--| GET /gists/public
23+
listCurrentUserPublicGists ::
24+
GitHub GistsData
25+
listCurrentUserPublicGists = ghGet public
26+
27+
--| GET /gists/starred
28+
listCurrentUserStarredGists ::
29+
GitHub GistsData
30+
listCurrentUserStarredGists = ghGet starred
31+
32+
--| GET /gists/:id
33+
getGist ::
34+
Int ->
35+
GitHub GistData
36+
getGist = ghGet . gist
37+
38+
--| POST /gists
39+
createGist ::
40+
NewGist ->
41+
GitHub GistData
42+
createGist = ghPost gists
43+
44+
--| PATCH /gists/:id
45+
editGist ::
46+
Int ->
47+
GistPatch ->
48+
GitHub GistData
49+
editGist i = ghPatch (gist i)
50+
51+
--| PUT /gists/:id/star
52+
starGist ::
53+
Int ->
54+
GitHub ()
55+
starGist = ghPut' . star
56+
57+
--| DELETE /gists/:id/star
58+
unstarGist ::
59+
Int ->
60+
GitHub ()
61+
unstarGist = ghDelete . star
62+
63+
--| GET /gists/:id/star
64+
isGistStarred ::
65+
Int ->
66+
GitHub Bool
67+
isGistStarred = ghGet . star
68+
69+
--| POST /gists/:id/forks
70+
forkGist ::
71+
Int ->
72+
GitHub GistData
73+
forkGist = ghPost' . forks
74+
75+
--| DELETE /gists/:id
76+
deleteGist ::
77+
Int ->
78+
GitHub ()
79+
deleteGist = ghDelete . gist

src/GitHub/Gists/Comments.hs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module GitHub.Gists.Comments where
2+
import GitHub.Internal
3+
4+
gistComments i = "/gists/" <> i <> "/comments"
5+
gistComment gi ci = gistComments gi <> "/" <> ci
6+
--| GET /gists/:gist_id/comments
7+
listGistComments ::
8+
Int ->
9+
GitHub GistCommentsData
10+
listGistComments = ghGet . gistComments
11+
12+
--| GET /gists/:gist_id/comments/:id
13+
getGistComment ::
14+
Int ->
15+
Int ->
16+
GitHub GistCommentData
17+
getGistComment gi ci = ghGet $ gistComment gi ci
18+
19+
--| POST /gists/:gist_id/comments
20+
createGistComment ::
21+
Int ->
22+
NewGistComment ->
23+
GitHub GistCommentData
24+
createGistComment i = ghPost (gistComments i)
25+
26+
--| PATCH /gists/:gist_id/comments/:id
27+
editGistComment ::
28+
Int ->
29+
Int ->
30+
GistCommentPatch ->
31+
GitHub GistCommentData
32+
editGistComment gi ci = ghPatch $ gistComment gi ci
33+
34+
--| DELETE /gists/:gist_id/comments/:id
35+
deleteGistComment ::
36+
Int ->
37+
Int ->
38+
GitHub ()
39+
deleteGistComment gi ci = ghDelete $ gistComment gi ci

src/GitHub/Git.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module GitHub.Git where
2+
import GitHub.Internal

src/GitHub/Git/Blobs.hs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module GitHub.Git.Blobs where
2+
import GitHub.Internal
3+
4+
--| GET /repos/:owner/:repo/git/blobs/:sha
5+
getBlob ::
6+
OwnerName ->
7+
RepoName ->
8+
Sha ->
9+
GitHub BlobData
10+
getBlob o r s = get [] (ownerRepo o r <> "/git/blobs/" <> s)
11+
12+
--| POST /repos/:owner/:repo/git/blobs
13+
createBlob ::
14+
OwnerName ->
15+
RepoName ->
16+
NewBlob ->
17+
GitHub BlobData
18+
createBlob o r = post [] (ownerRepo o r <> "/git/blobs")

0 commit comments

Comments
 (0)