// Code generated by Fern. DO NOT EDIT.

package client

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

type Client struct {
	WithRawResponse *RawClient
	Deliveries      *deliveries.Client
	Redeliveries    *redeliveries.Client

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

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

func (c *Client) List(
	ctx context.Context,
	request *management.ListEventStreamsRequestParameters,
	opts ...option.RequestOption,
) ([]*management.EventStreamResponseContent, error) {
	response, err := c.WithRawResponse.List(
		ctx,
		request,
		opts...,
	)
	if err != nil {
		return nil, err
	}
	return response.Body, nil
}

func (c *Client) Create(
	ctx context.Context,
	request *management.EventStreamsCreateRequest,
	opts ...option.RequestOption,
) (*management.CreateEventStreamResponseContent, error) {
	response, err := c.WithRawResponse.Create(
		ctx,
		request,
		opts...,
	)
	if err != nil {
		return nil, err
	}
	return response.Body, nil
}

func (c *Client) Get(
	ctx context.Context,
	// Unique identifier for the event stream.
	id string,
	opts ...option.RequestOption,
) (*management.GetEventStreamResponseContent, error) {
	response, err := c.WithRawResponse.Get(
		ctx,
		id,
		opts...,
	)
	if err != nil {
		return nil, err
	}
	return response.Body, nil
}

func (c *Client) Delete(
	ctx context.Context,
	// Unique identifier for the event stream.
	id string,
	opts ...option.RequestOption,
) error {
	_, err := c.WithRawResponse.Delete(
		ctx,
		id,
		opts...,
	)
	if err != nil {
		return err
	}
	return nil
}

func (c *Client) Update(
	ctx context.Context,
	// Unique identifier for the event stream.
	id string,
	request *management.UpdateEventStreamRequestContent,
	opts ...option.RequestOption,
) (*management.UpdateEventStreamResponseContent, 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,
	// Unique identifier for the event stream.
	id string,
	request *management.CreateEventStreamTestEventRequestContent,
	opts ...option.RequestOption,
) (*management.CreateEventStreamTestEventResponseContent, error) {
	response, err := c.WithRawResponse.Test(
		ctx,
		id,
		request,
		opts...,
	)
	if err != nil {
		return nil, err
	}
	return response.Body, nil
}
