package client import "net/http" // Builder is a builder for creating a TCGDexClient with customizable options. type Builder struct { language *string baseURL *string httpClient *http.Client } // NewBuilder creates a new Builder instance. // This allows for fluent configuration of the TCGDexClient. func NewBuilder() *Builder { return &Builder{} } // Language sets the language for the TCGDexClient. func (b *Builder) Language(language string) *Builder { b.language = &language return b } // BaseURL sets the base URL for the TCGDexClient. func (b *Builder) BaseURL(baseURL string) *Builder { b.baseURL = &baseURL return b } // HTTPClient sets the custom HTTP client for the TCGDexClient. func (b *Builder) HTTPClient(client *http.Client) *Builder { b.httpClient = client return b } // Builder constructs the TCGDexClient with the specified options. func (b *Builder) Builder() TCGDexClient { httpClient := b.httpClient if httpClient == nil { httpClient = http.DefaultClient } language := b.language if language == nil { language = ptr(defaultLanguage) } baseURL := b.baseURL if baseURL == nil { baseURL = ptr(defaultURL) } return NewClientWithCustomHTTPClient(*baseURL, *language, httpClient) } func ptr[T any](s T) *T { return &s }