// Code generated by Fern. DO NOT EDIT.

package tickets

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,
			},
		),
	}
}

// Create an email verification ticket for a given user. An email verification ticket is a generated URL that the user can consume to verify their email address.
func (c *Client) VerifyEmail(
	ctx context.Context,
	request *management.VerifyEmailTicketRequestContent,
	opts ...option.RequestOption,
) (*management.VerifyEmailTicketResponseContent, error) {
	response, err := c.WithRawResponse.VerifyEmail(
		ctx,
		request,
		opts...,
	)
	if err != nil {
		return nil, err
	}
	return response.Body, nil
}

// Create a password change ticket for a given user. A password change ticket is a generated URL that the user can consume to start a reset password flow.
//
// Note: This endpoint does not verify the given user’s identity. If you call this endpoint within your application, you must design your application to verify the user’s identity.
func (c *Client) ChangePassword(
	ctx context.Context,
	request *management.ChangePasswordTicketRequestContent,
	opts ...option.RequestOption,
) (*management.ChangePasswordTicketResponseContent, error) {
	response, err := c.WithRawResponse.ChangePassword(
		ctx,
		request,
		opts...,
	)
	if err != nil {
		return nil, err
	}
	return response.Body, nil
}
