Skip to content
This repository was archived by the owner on Jun 8, 2019. It is now read-only.

Commit f286f03

Browse files
roblablaunknwon
authored andcommitted
Add AddCollaborator API Endpoint (#24)
1 parent d1020b4 commit f286f03

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

repo_collaborator.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2016 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package gogs
6+
7+
import (
8+
"encoding/json"
9+
"bytes"
10+
"fmt"
11+
)
12+
13+
type AddCollaboratorOption struct {
14+
Permission *string `json:"permission"`
15+
}
16+
17+
func (c *Client) AddCollaborator(user, repo, collaborator string, opt AddCollaboratorOption) error {
18+
body, err := json.Marshal(&opt)
19+
if err != nil {
20+
return err
21+
}
22+
_, err = c.getResponse("PUT", fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), nil, bytes.NewReader(body))
23+
return err
24+
}

0 commit comments

Comments
 (0)