34
34
35
35
type payload map [string ]interface {}
36
36
37
- type objInterface interface {
37
+ type responseParams interface {
38
38
error () error
39
39
clearError ()
40
40
}
@@ -124,23 +124,23 @@ func NewClient(email string) *Client {
124
124
return & Client {Email : email , httpClient : new (http.Client )}
125
125
}
126
126
127
- func (c * Client ) get (addr string , auth bool , obj objInterface ) error {
127
+ func (c * Client ) get (addr string , auth bool , obj responseParams ) error {
128
128
req , err := http .NewRequest ("GET" , addr , nil )
129
129
if err != nil {
130
130
return errors .New ("error creating GET request" )
131
131
}
132
132
return c .req (req , auth , obj )
133
133
}
134
134
135
- func (c * Client ) post (addr string , data * bytes.Buffer , auth bool , obj objInterface ) error {
135
+ func (c * Client ) post (addr string , data * bytes.Buffer , auth bool , obj responseParams ) error {
136
136
req , err := http .NewRequest ("POST" , addr , data )
137
137
if err != nil {
138
138
return errors .New ("error creating POST request" )
139
139
}
140
140
return c .req (req , auth , obj )
141
141
}
142
142
143
- func decodeJSONResponse (body io.ReadCloser , obj objInterface ) error {
143
+ func decodeJSONResponse (body io.ReadCloser , obj responseParams ) error {
144
144
if err := json .NewDecoder (body ).Decode (obj ); err != nil {
145
145
return errors .Wrap (err , "JSON decoding failed" )
146
146
}
@@ -151,7 +151,7 @@ func decodeJSONResponse(body io.ReadCloser, obj objInterface) error {
151
151
return nil
152
152
}
153
153
154
- func (c * Client ) req (req * http.Request , auth bool , obj objInterface ) error {
154
+ func (c * Client ) req (req * http.Request , auth bool , obj responseParams ) error {
155
155
req .Header .Set ("User-Agent" , UserAgent )
156
156
if auth {
157
157
req .Header .Set ("Authorization" , fmt .Sprintf ("Token %s" , c .AuthToken ))
0 commit comments