package dolar

import (
	"context"

	"github.com/maximotejeda/msvc-proto/golang/dolar"
	"github.com/maximotejeda/us_dop_scrapper/internal/application/core/domain"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
)

type Adapter struct {
	dolar dolar.DollarClient
}

func NewAdapter(dolarServiceURL string) (*Adapter, error) {
	var opts []grpc.DialOption
	opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
	conn, err := grpc.Dial(dolarServiceURL, opts...)
	if err != nil {
		return nil, err
	}
	defer conn.Close()
	client := dolar.NewDollarClient(conn)
	return &Adapter{dolar: client}, nil
}
