Add the AddOrgMembership API endpoint (#21)

This commit is contained in:
Robin Lambertz 2016-08-06 05:52:27 +02:00 committed by 无闻
parent d725743594
commit 3a3b83760f

26
org_members.go Normal file
View 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
}