// Code generated by django-cfg/django_client - DO NOT EDIT.
// Generated at: {{ generated_at }}

package {{ package_name }}

import (
	"net/http"
{% for subclient in subclients %}
	"{{ module_name }}/{{ subclient.package }}"
{% endfor %}
)

// Client is the main API client with sub-clients for each module.
type Client struct {
	BaseURL    string
	HTTPClient *http.Client
	Token      string

{% for subclient in subclients %}
	// {{ subclient.name }} provides access to {{ subclient.name }} operations
	{{ subclient.name }} *{{ subclient.package }}.Client
{% endfor %}
}

// NewClient creates a new API client.
func NewClient(baseURL string, options ...Option) *Client {
	client := &Client{
		BaseURL:    baseURL,
		HTTPClient: &http.Client{},
	}

	// Apply options
	for _, opt := range options {
		opt(client)
	}

	// Initialize sub-clients
{% for subclient in subclients %}
	client.{{ subclient.name }} = {{ subclient.package }}.NewClient(baseURL, client.HTTPClient, client.Token)
{% endfor %}

	return client
}

// Option is a functional option for configuring the Client.
type Option func(*Client)

// WithHTTPClient sets a custom HTTP client.
func WithHTTPClient(httpClient *http.Client) Option {
	return func(c *Client) {
		c.HTTPClient = httpClient
	}
}

// WithToken sets the authentication token.
func WithToken(token string) Option {
	return func(c *Client) {
		c.Token = token
	}
}
