5
5
package gitea
6
6
7
7
import (
8
- "bytes"
9
- "encoding/json"
10
8
"fmt"
11
9
)
12
10
@@ -44,13 +42,9 @@ type CreateLabelOption struct {
44
42
45
43
// CreateLabel create one label of repository
46
44
func (c * Client ) CreateLabel (owner , repo string , opt CreateLabelOption ) (* Label , error ) {
47
- body , err := json .Marshal (& opt )
48
- if err != nil {
49
- return nil , err
50
- }
51
45
label := new (Label )
52
46
return label , c .getParsedResponse ("POST" , fmt .Sprintf ("/repos/%s/%s/labels" , owner , repo ),
53
- jsonHeader , bytes . NewReader ( body ) , label )
47
+ jsonHeader , opt , label )
54
48
}
55
49
56
50
// EditLabelOption options for editing a label
@@ -61,12 +55,8 @@ type EditLabelOption struct {
61
55
62
56
// EditLabel modify one label with options
63
57
func (c * Client ) EditLabel (owner , repo string , id int64 , opt EditLabelOption ) (* Label , error ) {
64
- body , err := json .Marshal (& opt )
65
- if err != nil {
66
- return nil , err
67
- }
68
58
label := new (Label )
69
- return label , c .getParsedResponse ("PATCH" , fmt .Sprintf ("/repos/%s/%s/labels/%d" , owner , repo , id ), jsonHeader , bytes . NewReader ( body ) , label )
59
+ return label , c .getParsedResponse ("PATCH" , fmt .Sprintf ("/repos/%s/%s/labels/%d" , owner , repo , id ), jsonHeader , opt , label )
70
60
}
71
61
72
62
// DeleteLabel delete one label of repository by id
@@ -90,22 +80,14 @@ func (c *Client) GetIssueLabels(owner, repo string, index int64) ([]*Label, erro
90
80
91
81
// AddIssueLabels add one or more labels to one issue
92
82
func (c * Client ) AddIssueLabels (owner , repo string , index int64 , opt IssueLabelsOption ) ([]* Label , error ) {
93
- body , err := json .Marshal (& opt )
94
- if err != nil {
95
- return nil , err
96
- }
97
83
var labels []* Label
98
- return labels , c .getParsedResponse ("POST" , fmt .Sprintf ("/repos/%s/%s/issues/%d/labels" , owner , repo , index ), jsonHeader , bytes . NewReader ( body ) , & labels )
84
+ return labels , c .getParsedResponse ("POST" , fmt .Sprintf ("/repos/%s/%s/issues/%d/labels" , owner , repo , index ), jsonHeader , opt , & labels )
99
85
}
100
86
101
87
// ReplaceIssueLabels replace old labels of issue with new labels
102
88
func (c * Client ) ReplaceIssueLabels (owner , repo string , index int64 , opt IssueLabelsOption ) ([]* Label , error ) {
103
- body , err := json .Marshal (& opt )
104
- if err != nil {
105
- return nil , err
106
- }
107
89
var labels []* Label
108
- return labels , c .getParsedResponse ("PUT" , fmt .Sprintf ("/repos/%s/%s/issues/%d/labels" , owner , repo , index ), jsonHeader , bytes . NewReader ( body ) , & labels )
90
+ return labels , c .getParsedResponse ("PUT" , fmt .Sprintf ("/repos/%s/%s/issues/%d/labels" , owner , repo , index ), jsonHeader , opt , & labels )
109
91
}
110
92
111
93
// DeleteIssueLabel delete one label of one issue by issue id and label id
0 commit comments