Skip to content

Commit 89ff140

Browse files
bkcsoftunknwon
authored andcommitted
More Repo Collaborator Endpoints (#51)
1 parent 98046bb commit 89ff140

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

repo_collaborator.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,20 @@ import (
1010
"fmt"
1111
)
1212

13+
type Collaborator struct {
14+
*User
15+
Permissions Permission `json:"permissions"`
16+
}
17+
1318
type AddCollaboratorOption struct {
1419
Permission *string `json:"permission"`
1520
}
1621

22+
func (c *Client) ListCollaborator(user, repo string) ([]*Collaborator, error) {
23+
collabs := make([]*Collaborator, 0, 10)
24+
return collabs, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/collaborators", user, repo), nil, nil, &collabs)
25+
}
26+
1727
func (c *Client) AddCollaborator(user, repo, collaborator string, opt AddCollaboratorOption) error {
1828
body, err := json.Marshal(&opt)
1929
if err != nil {
@@ -22,3 +32,13 @@ func (c *Client) AddCollaborator(user, repo, collaborator string, opt AddCollabo
2232
_, err = c.getResponse("PUT", fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), nil, bytes.NewReader(body))
2333
return err
2434
}
35+
36+
func (c *Client) DeleteCollaborator(user, repo, collaborator string) error {
37+
_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), nil, nil)
38+
return err
39+
}
40+
41+
func (c *Client) IsCollaborator(user, repo, collaborator string) error {
42+
_, err := c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), nil, nil)
43+
return err
44+
}

0 commit comments

Comments
 (0)