-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtag.go
42 lines (32 loc) · 801 Bytes
/
tag.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package docbase
import (
"net/http"
"net/url"
)
// TagService implements interface with API /tags endpoint.
// See https://help.docbase.io/posts/45703#%E3%82%BF%E3%82%B0
type TagService interface {
List() (*TagListResponse, *Response, error)
}
// tagService handles communication with API
type tagService struct {
client *Client
}
// Tag represents a docbase Tag
type Tag struct {
Name string `json:"name"`
}
type TagListResponse []Tag
func (s *tagService) List() (*TagListResponse, *Response, error) {
u, err := url.Parse("/tags")
if err != nil {
return nil, nil, err
}
req, err := s.client.NewRequest(http.MethodGet, u.String(), nil)
tagResp := &TagListResponse{}
resp, err := s.client.Do(req, tagResp)
if err != nil {
return nil, resp, err
}
return tagResp, resp, err
}