forked from sogko/go-wordpress
-
Notifications
You must be signed in to change notification settings - Fork 2
/
taxonomies.go
33 lines (29 loc) · 1.11 KB
/
taxonomies.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
package wordpress
import (
"fmt"
"net/http"
)
type Taxonomy struct {
Description string `json:"description,omitempty"`
Hierarchical bool `json:"hierarchical,omitempty"`
Labels map[string]interface{} `json:"labels,omitempty"`
Name string `json:"name,omitempty"`
Slug string `json:"slug,omitempty"`
ShowCloud bool `json:"show_cloud,omitempty"`
Types []string `json:"types,omitempty"`
}
type TaxonomiesCollection struct {
client *Client
url string
}
func (col *TaxonomiesCollection) List(params interface{}) (map[string]Taxonomy, *http.Response, []byte, error) {
var taxonomies map[string]Taxonomy
resp, body, err := col.client.List(col.url, params, &taxonomies)
return taxonomies, resp, body, err
}
func (col *TaxonomiesCollection) Get(slug string, params interface{}) (*Taxonomy, *http.Response, []byte, error) {
var taxonomy Taxonomy
entityURL := fmt.Sprintf("%v/%v", col.url, slug)
resp, body, err := col.client.Get(entityURL, params, &taxonomy)
return &taxonomy, resp, body, err
}