Skip to content

Commit 9b9cd9f

Browse files
committed
Add initial endpoint to add collaborator
1 parent 66eb08c commit 9b9cd9f

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

src/GitHub/Endpoints/Repos/Collaborators.hs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ module GitHub.Endpoints.Repos.Collaborators (
1111
collaboratorsOnR,
1212
isCollaboratorOn,
1313
isCollaboratorOnR,
14+
addCollaborator,
15+
addCollaboratorR,
1416
module GitHub.Data,
1517
) where
1618

17-
import GitHub.Data
18-
import GitHub.Internal.Prelude
19-
import GitHub.Request
20-
import Prelude ()
19+
import GitHub.Data
20+
import GitHub.Internal.Prelude
21+
import GitHub.Request
22+
import Prelude ()
2123

2224
-- | All the users who have collaborated on a repo.
2325
--
@@ -60,3 +62,21 @@ isCollaboratorOnR
6062
-> Request k Bool
6163
isCollaboratorOnR user repo coll = StatusQuery statusOnlyOk $
6264
Query ["repos", toPathPart user, toPathPart repo, "collaborators", toPathPart coll] []
65+
66+
addCollaborator
67+
:: Auth
68+
-> Name Owner -- ^ Repository owner
69+
-> Name Repo -- ^ Repository name
70+
-> Name User -- ^ Collaborator to add
71+
-> IO (Either Error Invitation)
72+
addCollaborator auth owner repo coll =
73+
executeRequest auth $ addCollaboratorR owner repo coll
74+
75+
addCollaboratorR
76+
:: Name Owner -- ^ Repository owner
77+
-> Name Repo -- ^ Repository name
78+
-> Name User -- ^ Collaborator to add
79+
-> Request 'RW Invitation
80+
addCollaboratorR owner repo coll =
81+
command Put ["repos", toPathPart owner, toPathPart repo, "collaborators", toPathPart coll] mempty
82+
-- /repos/:owner/:repo/collaborators/:username

0 commit comments

Comments
 (0)