func NewClient(options ...ClientOption) (*Client, error) {
	co := &clientOptions{
		baseURL: defaultBaseURL,
		client: &http.Client{
			Timeout: defaultTimeout,
		},
		limiter: ratelimit.New(defaultReqPerSecond),
	}
	for _, option := range options {
		option(co)
	}
	if len(co.clientSecret) != 0 && len(co.grantSecret) != 0 {
		return nil, ErrMultipleSecrets
	}
	var authorization string
	if len(co.clientSecret) != 0 {
		authorization = "Bearer " + co.clientSecret
	}
	if len(co.grantSecret) != 0 {
		authorization = "Bearer " + co.grantSecret
	}
	baseURL, err := url.Parse(co.baseURL)
	if err != nil {
		return nil, err
	}
	c := &Client{
		baseURL:       baseURL,
		authorization: authorization,
		client:        co.client,
		limiter: co.limiter,
	}
	return c, nil
}
NewClient returns a new Scryfall API client.
package scryfall
import (
	"bytes"
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"net/http"
	"net/url"
	"strings"
	"time"
	"go.uber.org/ratelimit"
)
const (
	defaultBaseURL = "https://api.scryfall.com"
	defaultTimeout = 30 * time.Second
	defaultReqPerSecond = 10
	userAgent      = "go-scryfall"
	dateFormat      = "2006-01-02"
	timestampFormat = "2006-01-02T15:04:05.999Z07:00"
)
var ErrMultipleSecrets = errors.New("multiple secrets configured")
type Color string
const (
	ColorWhite Color = "W"
	ColorBlue Color = "U"
	ColorBlack Color = "B"
	ColorRed Color = "R"
	ColorGreen Color = "G"
)
type Date struct {
	time.Time
}
func (d *Date) UnmarshalJSON(b []byte) error {
	s := strings.Trim(string(b), "\"")
	if s == "null" {
		return nil
	}
	parsedTime, err := time.ParseInLocation(dateFormat, s, time.FixedZone("UTC-8", -8*60*60))
	if err != nil {
		return err
	}
	d.Time = parsedTime
	return nil
}
type Timestamp struct {
	time.Time
}
func (t *Timestamp) UnmarshalJSON(b []byte) error {
	s := strings.Trim(string(b), "\"")
	if s == "null" {
		return nil
	}
	parsedTime, err := time.Parse(timestampFormat, s)
	if err != nil {
		return err
	}
	t.Time = parsedTime
	return nil
}
type Error struct {
	Status   int      `json:"status"`
	Code     string   `json:"code"`
	Details  string   `json:"details"`
	Type     *string  `json:"type"`
	Warnings []string `json:"warnings"`
}
func (e *Error) Error() string {
	return fmt.Sprintf("%s: %s", e.Code, e.Details)
}
type clientOptions struct {
	baseURL      string
	clientSecret string
	grantSecret  string
	client       *http.Client
	limiter ratelimit.Limiter
}
type ClientOption func(*clientOptions)
func WithBaseURL(baseURL string) ClientOption {
	return func(o *clientOptions) {
		o.baseURL = baseURL
	}
}
func WithClientSecret(clientSecret string) ClientOption {
	return func(o *clientOptions) {
		o.clientSecret = clientSecret
	}
}
func WithGrantSecret(grantSecret string) ClientOption {
	return func(o *clientOptions) {
		o.grantSecret = grantSecret
	}
}
func WithHTTPClient(client *http.Client) ClientOption {
	return func(o *clientOptions) {
		o.client = client
	}
}
func WithLimiter(limiter ratelimit.Limiter) ClientOption {
	return func(o *clientOptions) {
		o.limiter = limiter
	}
}
type Client struct {
	baseURL       *url.URL
	authorization string
	client *http.Client
	limiter ratelimit.Limiter
}