2024-12-02 15:55:46 -04:00

33 lines
764 B
Go

package dolar
import (
"context"
dl "git.maximotejeda.com/maximo/dolar/proto/golang/dolar"
"github.com/maximotejeda/us_dop_scrapper/internal/application/core/domain"
"google.golang.org/grpc"
)
type Adapter struct {
dolar dl.DollarClient
conn *grpc.ClientConn
}
func NewAdapter(conn *grpc.ClientConn) (*Adapter, error) {
client := dolar.NewDollarClient(conn)
return &Adapter{dolar: client, conn: conn}, nil
}
func (a *Adapter) NewHistory(history *domain.History) error {
_, err := a.dolar.NewHistory(context.Background(),
&dl.AddDolarRequest{
Institution: &dl.History{
Name: history.Name,
Compra: float32(history.Compra),
Venta: float32(history.Venta),
Parser: history.Parser,
Parsed: history.Parsed,
}})
return err
}