package account

import (
	"context"
	"net/http"

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

// DeleteRequest struct to delete account
type DeleteRequest struct {
	// ID of account to delete
	// Required: true
	AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`

	// Whether to completely delete the account
	// Required: false
	Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`

	// Name of account
	// Required: false
	Name string `url:"name,omitempty" json:"name,omitempty"`
}

// Delete completes delete an account from the system Returns true if account is deleted or was already deleted or never existed
func (a Account) Delete(ctx context.Context, req DeleteRequest) (string, error) {
	err := validators.ValidateRequest(req)
	if err != nil {
		return "", validators.ValidationErrors(validators.GetErrors(err))
	}

	url := "/cloudbroker/account/delete"

	result, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
	if err != nil {
		return "", err
	}

	return string(result), nil
}
