org_member.go 591 B

123456789101112131415161718192021222324
  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. package gogs
  5. import (
  6. "bytes"
  7. "encoding/json"
  8. "fmt"
  9. )
  10. type AddOrgMembershipOption struct {
  11. Role string `json:"role" binding:"Required"`
  12. }
  13. func (c *Client) AddOrgMembership(org, user string, opt AddOrgMembershipOption) error {
  14. body, err := json.Marshal(&opt)
  15. if err != nil {
  16. return err
  17. }
  18. _, err = c.getResponse("PUT", fmt.Sprintf("/orgs/%s/membership/%s", org, user), jsonHeader, bytes.NewReader(body))
  19. return err
  20. }