// Code generated by Fern. DO NOT EDIT.

package emailtemplates

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 template.
func (c *Client) Create(
	ctx context.Context,
	request *management.CreateEmailTemplateRequestContent,
	opts ...option.RequestOption,
) (*management.CreateEmailTemplateResponseContent, error) {
	response, err := c.WithRawResponse.Create(
		ctx,
		request,
		opts...,
	)
	if err != nil {
		return nil, err
	}
	return response.Body, nil
}

// Retrieve an email template by pre-defined name. These names are `verify_email`, `verify_email_by_code`, `reset_email`, `reset_email_by_code`, `welcome_email`, `blocked_account`, `stolen_credentials`, `enrollment_email`, `mfa_oob_code`, `user_invitation`, and `async_approval`. The names `change_password`, and `password_reset` are also supported for legacy scenarios.
func (c *Client) Get(
	ctx context.Context,
	// Template name. Can be `verify_email`, `verify_email_by_code`, `reset_email`, `reset_email_by_code`, `welcome_email`, `blocked_account`, `stolen_credentials`, `enrollment_email`, `mfa_oob_code`, `user_invitation`, `async_approval`, `change_password` (legacy), or `password_reset` (legacy).
	templateName *management.EmailTemplateNameEnum,
	opts ...option.RequestOption,
) (*management.GetEmailTemplateResponseContent, error) {
	response, err := c.WithRawResponse.Get(
		ctx,
		templateName,
		opts...,
	)
	if err != nil {
		return nil, err
	}
	return response.Body, nil
}

// Update an email template.
func (c *Client) Set(
	ctx context.Context,
	// Template name. Can be `verify_email`, `verify_email_by_code`, `reset_email`, `reset_email_by_code`, `welcome_email`, `blocked_account`, `stolen_credentials`, `enrollment_email`, `mfa_oob_code`, `user_invitation`, `async_approval`, `change_password` (legacy), or `password_reset` (legacy).
	templateName *management.EmailTemplateNameEnum,
	request *management.SetEmailTemplateRequestContent,
	opts ...option.RequestOption,
) (*management.SetEmailTemplateResponseContent, error) {
	response, err := c.WithRawResponse.Set(
		ctx,
		templateName,
		request,
		opts...,
	)
	if err != nil {
		return nil, err
	}
	return response.Body, nil
}

// Modify an email template.
func (c *Client) Update(
	ctx context.Context,
	// Template name. Can be `verify_email`, `verify_email_by_code`, `reset_email`, `reset_email_by_code`, `welcome_email`, `blocked_account`, `stolen_credentials`, `enrollment_email`, `mfa_oob_code`, `user_invitation`, `async_approval`, `change_password` (legacy), or `password_reset` (legacy).
	templateName *management.EmailTemplateNameEnum,
	request *management.UpdateEmailTemplateRequestContent,
	opts ...option.RequestOption,
) (*management.UpdateEmailTemplateResponseContent, error) {
	response, err := c.WithRawResponse.Update(
		ctx,
		templateName,
		request,
		opts...,
	)
	if err != nil {
		return nil, err
	}
	return response.Body, nil
}
