33 lines
766 B
Go

package dolar
import (
"context"
"github.com/maximotejeda/dolar/proto/golang/dolar"
"github.com/maximotejeda/us_dop_scrapper/internal/application/core/domain"
"google.golang.org/grpc"
)
type Adapter struct {
dolar dolar.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(),
&dolar.AddDolarRequest{
Institution: &dolar.History{
Name: history.Name,
Compra: float32(history.Compra),
Venta: float32(history.Venta),
Parser: history.Parser,
Parsed: history.Parsed,
}})
return err
}