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

Commit 3a3b837

Browse files
roblablaunknwon
authored andcommitted
Add the AddOrgMembership API endpoint (#21)
1 parent d725743 commit 3a3b837

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

org_members.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2015 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+
"bytes"
9+
"encoding/json"
10+
"fmt"
11+
"net/http"
12+
)
13+
14+
type AddOrgMembershipOption struct {
15+
Role string `json:"role"`
16+
}
17+
18+
func (c *Client) AddOrgMembership(orgname string, username string, opt AddOrgMembershipOption) error {
19+
body, err := json.Marshal(&opt)
20+
if err != nil {
21+
return err
22+
}
23+
_, err = c.getResponse("PUT", fmt.Sprintf("/orgs/%s/membership/%s", orgname, username),
24+
http.Header{"content-type": []string{"application/json"}}, bytes.NewReader(body))
25+
return err
26+
}

0 commit comments

Comments
 (0)