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

23 lines
590 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"`
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
}