23 lines
590 B
Go
23 lines
590 B
Go
|
package wordpress
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"federated.computer/wp-sync-slowtwitch/utilities"
|
||
|
)
|
||
|
|
||
|
type CreateCategory struct {
|
||
|
Name string `json:"name"`
|
||
|
Description string `json:"description"`
|
||
|
ParentId int `json:"parent"`
|
||
|
Slug string `json:"slug"`
|
||
|
}
|
||
|
|
||
|
func (parameters *CreateCategory) Execute(baseUrl, user, pass string) CategoryData {
|
||
|
endpoint := baseUrl + "categories"
|
||
|
body := utilities.PostHttpRequestToWordpress(endpoint, user, pass, parameters)
|
||
|
var category CategoryData
|
||
|
err := json.Unmarshal(body, &category)
|
||
|
utilities.CheckError(err)
|
||
|
return category
|
||
|
}
|