Post-Migrator/services/wordpress/create-user.go
2024-05-07 19:23:21 -06:00

34 lines
899 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) CreateUserResponse {
endpoint := baseUrl + "users"
body := utilities.PostHttpRequestToWordpress(endpoint, user, pass, parameters)
var userData CreateUserResponse
err := json.Unmarshal(body, &userData)
utilities.CheckError(err)
return userData
}