Add the AddOrgMembership API endpoint (#21)
This commit is contained in:
parent
d725743594
commit
3a3b83760f
1 changed files with 26 additions and 0 deletions
26
org_members.go
Normal file
26
org_members.go
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
// Copyright 2015 The Gogs Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package gogs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AddOrgMembershipOption struct {
|
||||||
|
Role string `json:"role"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) AddOrgMembership(orgname string, username string, opt AddOrgMembershipOption) error {
|
||||||
|
body, err := json.Marshal(&opt)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = c.getResponse("PUT", fmt.Sprintf("/orgs/%s/membership/%s", orgname, username),
|
||||||
|
http.Header{"content-type": []string{"application/json"}}, bytes.NewReader(body))
|
||||||
|
return err
|
||||||
|
}
|
Loading…
Reference in a new issue