29 lines
764 B
Go
29 lines
764 B
Go
|
package wordpress
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"federated.computer/wp-sync-slowtwitch/utilities"
|
||
|
)
|
||
|
|
||
|
type CreatePost struct {
|
||
|
Title string `json:"title"`
|
||
|
Content string `json:"content"`
|
||
|
Excerpt string `json:"excerpt"`
|
||
|
FeaturedMedia int `json:"featured_media"`
|
||
|
Author int `json:"author"`
|
||
|
Tags []int `json:"tags"`
|
||
|
Status string `json:"status"`
|
||
|
Categories []int `json:"categories"`
|
||
|
Slug string `json:"slug"`
|
||
|
}
|
||
|
|
||
|
func (parameters *CreatePost) Execute(baseUrl, user, pass string) PostData {
|
||
|
endpoint := baseUrl + "posts"
|
||
|
body := utilities.PostHttpRequestToWordpress(endpoint, user, pass, parameters)
|
||
|
var post PostData
|
||
|
err := json.Unmarshal(body, &post)
|
||
|
utilities.CheckError(err)
|
||
|
|
||
|
return post
|
||
|
}
|