package monetix

import (
	"context"
	"net/http"

	"github.com/tech/sendico/pkg/mlogger"
	"go.uber.org/zap"
)

type Client struct {
	cfg    Config
	client *http.Client
	logger mlogger.Logger
}

func NewClient(cfg Config, httpClient *http.Client, logger mlogger.Logger) *Client {
	client := httpClient
	if client == nil {
		client = &http.Client{Timeout: cfg.timeout()}
	}
	cl := logger
	if cl == nil {
		cl = zap.NewNop()
	}
	return &Client{
		cfg:    cfg,
		client: client,
		logger: cl.Named("client"),
	}
}

func (c *Client) CreateCardPayout(ctx context.Context, req CardPayoutRequest) (*CardPayoutSendResult, error) {
	return c.sendCardPayout(ctx, req)
}

func (c *Client) CreateCardTokenPayout(ctx context.Context, req CardTokenPayoutRequest) (*CardPayoutSendResult, error) {
	return c.sendCardTokenPayout(ctx, req)
}

func (c *Client) CreateCardTokenization(ctx context.Context, req CardTokenizeRequest) (*TokenizationResult, error) {
	return c.sendTokenization(ctx, req)
}
