Post-Migrator/services/wordpress/create-category.go

22 lines
570 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-json/wp/v2/categories"
body := utilities.PostHttpRequestToWordpress(endpoint, user, pass, parameters)
var category CategoryData
err := json.Unmarshal(body, &category)
utilities.CheckError(err)
return category
}