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

34 lines
879 B
Go

package wordpress
import (
"encoding/json"
"federated.computer/wp-sync-slowtwitch/utilities"
)
type CreateUser struct {
Username string `json:"username"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Name string `json:"name"`
Email string `json:"email"`
Roles string `json:"roles"`
Password string `json:"password"`
}
type CreateUserResponse struct {
Id int `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
}
func (parameters *CreateUser) Execute(baseUrl, user, pass string) UserData {
endpoint := baseUrl + "users"
body := utilities.PostHttpRequestToWordpress(endpoint, user, pass, parameters)
var userData UserData
err := json.Unmarshal(body, &userData)
utilities.CheckError(err)
return userData
}