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

22 lines
570 B
Go
Raw Normal View History

2024-05-09 21:25:13 +00:00
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"
2024-05-09 21:25:13 +00:00
body := utilities.PostHttpRequestToWordpress(endpoint, user, pass, parameters)
var category CategoryData
err := json.Unmarshal(body, &category)
utilities.CheckError(err)
return category
}