From 58af7d8521ea52ba81adcffbc18cc90e61383512 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 5 Aug 2016 20:56:36 -0700 Subject: [PATCH] #21 code cleanup --- gogs.go | 2 +- org_members.go => org_member.go | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) rename org_members.go => org_member.go (54%) diff --git a/gogs.go b/gogs.go index d614e83..0b19afa 100644 --- a/gogs.go +++ b/gogs.go @@ -14,7 +14,7 @@ import ( ) func Version() string { - return "0.10.1" + return "0.10.2" } // Client represents a Gogs API client. diff --git a/org_members.go b/org_member.go similarity index 54% rename from org_members.go rename to org_member.go index 9ff57ba..d7668bb 100644 --- a/org_members.go +++ b/org_member.go @@ -1,4 +1,4 @@ -// Copyright 2015 The Gogs Authors. All rights reserved. +// Copyright 2016 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. @@ -12,15 +12,14 @@ import ( ) type AddOrgMembershipOption struct { - Role string `json:"role"` + Role string `json:"role"` } -func (c *Client) AddOrgMembership(orgname string, username string, opt AddOrgMembershipOption) error { +func (c *Client) AddOrgMembership(org, user 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)) + _, err = c.getResponse("PUT", fmt.Sprintf("/orgs/%s/membership/%s", org, user), jsonHeader, bytes.NewReader(body)) return err }