// Code generated by Fern. DO NOT EDIT.

package userblocks

import (
	context "context"
	management "github.com/auth0/go-auth0/v2/management"
	core "github.com/auth0/go-auth0/v2/management/core"
	internal "github.com/auth0/go-auth0/v2/management/internal"
	option "github.com/auth0/go-auth0/v2/management/option"
)

type Client struct {
	WithRawResponse *RawClient

	options *core.RequestOptions
	baseURL string
	caller  *internal.Caller
}

func NewClient(options *core.RequestOptions) *Client {
	return &Client{
		WithRawResponse: NewRawClient(options),
		options:         options,
		baseURL:         options.BaseURL,
		caller: internal.NewCaller(
			&internal.CallerParams{
				Client:      options.HTTPClient,
				MaxAttempts: options.MaxAttempts,
			},
		),
	}
}

// Retrieve details of all <a href="https://auth0.com/docs/secure/attack-protection/brute-force-protection">Brute-force Protection</a> blocks for a user with the given identifier (username, phone number, or email).
func (c *Client) ListByIdentifier(
	ctx context.Context,
	request *management.ListUserBlocksByIdentifierRequestParameters,
	opts ...option.RequestOption,
) (*management.ListUserBlocksByIdentifierResponseContent, error) {
	response, err := c.WithRawResponse.ListByIdentifier(
		ctx,
		request,
		opts...,
	)
	if err != nil {
		return nil, err
	}
	return response.Body, nil
}

// Remove all <a href="https://auth0.com/docs/secure/attack-protection/brute-force-protection">Brute-force Protection</a> blocks for the user with the given identifier (username, phone number, or email).
//
// Note: This endpoint does not unblock users that were <a href="https://auth0.com/docs/user-profile#block-and-unblock-a-user">blocked by a tenant administrator</a>.
func (c *Client) DeleteByIdentifier(
	ctx context.Context,
	request *management.DeleteUserBlocksByIdentifierRequestParameters,
	opts ...option.RequestOption,
) error {
	_, err := c.WithRawResponse.DeleteByIdentifier(
		ctx,
		request,
		opts...,
	)
	if err != nil {
		return err
	}
	return nil
}

// Retrieve details of all <a href="https://auth0.com/docs/secure/attack-protection/brute-force-protection">Brute-force Protection</a> blocks for the user with the given ID.
func (c *Client) List(
	ctx context.Context,
	// user_id of the user blocks to retrieve.
	id string,
	request *management.ListUserBlocksRequestParameters,
	opts ...option.RequestOption,
) (*management.ListUserBlocksResponseContent, error) {
	response, err := c.WithRawResponse.List(
		ctx,
		id,
		request,
		opts...,
	)
	if err != nil {
		return nil, err
	}
	return response.Body, nil
}

// Remove all <a href="https://auth0.com/docs/secure/attack-protection/brute-force-protection">Brute-force Protection</a> blocks for the user with the given ID.
//
// Note: This endpoint does not unblock users that were <a href="https://auth0.com/docs/user-profile#block-and-unblock-a-user">blocked by a tenant administrator</a>.
func (c *Client) Delete(
	ctx context.Context,
	// The user_id of the user to update.
	id string,
	opts ...option.RequestOption,
) error {
	_, err := c.WithRawResponse.Delete(
		ctx,
		id,
		opts...,
	)
	if err != nil {
		return err
	}
	return nil
}
