package user

import (
	"context"
	"net/http"
	"strconv"

	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)

// DeleteUsersRequest struct for bulk delete a list of users.
type DeleteUsersRequest struct {
	// List of user ids
	// Required: true
	UserIDs []string `url:"userIds" json:"userIds" validate:"required"`
}

// DeleteUsers bulk delete a list of users.
func (u User) DeleteUsers(ctx context.Context, req DeleteUsersRequest) (bool, error) {
	err := validators.ValidateRequest(req)
	if err != nil {
		return false, validators.ValidationErrors(validators.GetErrors(err))
	}

	url := "/cloudbroker/user/deleteUsers"

	res, err := u.client.DecortApiCall(ctx, http.MethodPost, url, req)
	if err != nil {
		return false, err
	}

	result, err := strconv.ParseBool(string(res))
	if err != nil {
		return false, err
	}

	return result, nil
}
