// Code generated by Fern. DO NOT EDIT.

package providers

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 a list of <a href="https://auth0.com/docs/customize/phone-messages/configure-phone-messaging-providers">phone providers</a> details set for a Tenant. A list of fields to include or exclude may also be specified.
func (c *Client) List(
	ctx context.Context,
	request *management.ListBrandingPhoneProvidersRequestParameters,
	opts ...option.RequestOption,
) (*management.ListBrandingPhoneProvidersResponseContent, error) {
	response, err := c.WithRawResponse.List(
		ctx,
		request,
		opts...,
	)
	if err != nil {
		return nil, err
	}
	return response.Body, nil
}

// Create a <a href="https://auth0.com/docs/customize/phone-messages/configure-phone-messaging-providers">phone provider</a>.
// The <code>credentials</code> object requires different properties depending on the phone provider (which is specified using the <code>name</code> property).
func (c *Client) Create(
	ctx context.Context,
	request *management.CreateBrandingPhoneProviderRequestContent,
	opts ...option.RequestOption,
) (*management.CreateBrandingPhoneProviderResponseContent, error) {
	response, err := c.WithRawResponse.Create(
		ctx,
		request,
		opts...,
	)
	if err != nil {
		return nil, err
	}
	return response.Body, nil
}

// Retrieve <a href="https://auth0.com/docs/customize/phone-messages/configure-phone-messaging-providers">phone provider</a> details. A list of fields to include or exclude may also be specified.
func (c *Client) Get(
	ctx context.Context,
	id string,
	opts ...option.RequestOption,
) (*management.GetBrandingPhoneProviderResponseContent, error) {
	response, err := c.WithRawResponse.Get(
		ctx,
		id,
		opts...,
	)
	if err != nil {
		return nil, err
	}
	return response.Body, nil
}

// Delete the configured phone provider.
func (c *Client) Delete(
	ctx context.Context,
	id string,
	opts ...option.RequestOption,
) error {
	_, err := c.WithRawResponse.Delete(
		ctx,
		id,
		opts...,
	)
	if err != nil {
		return err
	}
	return nil
}

// Update a <a href="https://auth0.com/docs/customize/phone-messages/configure-phone-messaging-providers">phone provider</a>.
// The <code>credentials</code> object requires different properties depending on the phone provider (which is specified using the <code>name</code> property).
func (c *Client) Update(
	ctx context.Context,
	id string,
	request *management.UpdateBrandingPhoneProviderRequestContent,
	opts ...option.RequestOption,
) (*management.UpdateBrandingPhoneProviderResponseContent, error) {
	response, err := c.WithRawResponse.Update(
		ctx,
		id,
		request,
		opts...,
	)
	if err != nil {
		return nil, err
	}
	return response.Body, nil
}

func (c *Client) Test(
	ctx context.Context,
	id string,
	request *management.CreatePhoneProviderSendTestRequestContent,
	opts ...option.RequestOption,
) (*management.CreatePhoneProviderSendTestResponseContent, error) {
	response, err := c.WithRawResponse.Test(
		ctx,
		id,
		request,
		opts...,
	)
	if err != nil {
		return nil, err
	}
	return response.Body, nil
}
