22 lines
562 B
Go
22 lines
562 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"`
|
|
}
|
|
|
|
func (parameters *CreateCategory) Execute(baseUrl, user, pass string) CategoryData {
|
|
endpoint := baseUrl + "wp/v2/categories"
|
|
body := utilities.PostHttpRequestToWordpress(endpoint, user, pass, parameters)
|
|
var category CategoryData
|
|
err := json.Unmarshal(body, &category)
|
|
utilities.CheckError(err)
|
|
return category
|
|
}
|