From 43e086f7523a7ab4056c1ce72cc38533adcbf5a2 Mon Sep 17 00:00:00 2001 From: Natercio Moniz Date: Sun, 2 Aug 2026 11:20:36 +0100 Subject: [PATCH] update remaining references to internal.OpenFIGI --- cmd/any2anexoj-cli/main.go | 2 +- internal/trading212/record.go | 7 ++++--- internal/trading212/record_test.go | 11 ++++++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cmd/any2anexoj-cli/main.go b/cmd/any2anexoj-cli/main.go index 522b26f..61726e5 100644 --- a/cmd/any2anexoj-cli/main.go +++ b/cmd/any2anexoj-cli/main.go @@ -98,7 +98,7 @@ func run(ctx context.Context) error { func getReader(platform string, ofAPIKey string) (internal.RecordReader, error) { switch platform { case "trading212": - return trading212.NewRecordReader(os.Stdin, ofigi.NewClient(&http.Client{Timeout: 5 * time.Second}, ofAPIKey)), nil + return trading212.NewRecordReader(os.Stdin, ofigi.NewOpenFIGI(&http.Client{Timeout: 5 * time.Second}, ofAPIKey)), nil default: return nil, fmt.Errorf("unsupported platform: %s", platform) } diff --git a/internal/trading212/record.go b/internal/trading212/record.go index 5d456d1..b34f05b 100644 --- a/internal/trading212/record.go +++ b/internal/trading212/record.go @@ -12,6 +12,7 @@ import ( "github.com/biter777/countries" "github.com/nmoniz/any2anexoj/internal" + "github.com/nmoniz/any2anexoj/internal/ofigi" "github.com/shopspring/decimal" ) @@ -70,10 +71,10 @@ func (r Record) Nature() internal.Nature { type RecordReader struct { reader *csv.Reader - figi *internal.OpenFIGI + figi *ofigi.Client } -func NewRecordReader(r io.Reader, f *internal.OpenFIGI) *RecordReader { +func NewRecordReader(r io.Reader, f *ofigi.Client) *RecordReader { return &RecordReader{ reader: csv.NewReader(r), figi: f, @@ -187,7 +188,7 @@ func (rr RecordReader) ReadRecord(ctx context.Context) (internal.Record, error) } } -func figiNatureGetter(ctx context.Context, of *internal.OpenFIGI, isin string) func() internal.Nature { +func figiNatureGetter(ctx context.Context, of *ofigi.Client, isin string) func() internal.Nature { return sync.OnceValue(func() internal.Nature { secType, err := of.SecurityTypeByISIN(ctx, isin) if err != nil { diff --git a/internal/trading212/record_test.go b/internal/trading212/record_test.go index d38d32b..ba53cba 100644 --- a/internal/trading212/record_test.go +++ b/internal/trading212/record_test.go @@ -9,6 +9,7 @@ import ( "time" "github.com/nmoniz/any2anexoj/internal" + "github.com/nmoniz/any2anexoj/internal/ofigi" "github.com/shopspring/decimal" ) @@ -221,7 +222,7 @@ func TestRecordReader_ReadRecord_Split(t *testing.T) { func Test_figiNatureGetter(t *testing.T) { tests := []struct { name string // description of this test case - of *internal.OpenFIGI + of *ofigi.Client want internal.Nature }{ { @@ -272,7 +273,7 @@ func (f RoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error) { return f(req) } -func NewFigiClientSecurityTypeStub(t testing.TB, securityType string) *internal.OpenFIGI { +func NewFigiClientSecurityTypeStub(t testing.TB, securityType string) *ofigi.Client { t.Helper() c := &http.Client{ @@ -287,10 +288,10 @@ func NewFigiClientSecurityTypeStub(t testing.TB, securityType string) *internal. }), } - return internal.NewOpenFIGI(c, "") + return ofigi.NewOpenFIGI(c, "") } -func NewFigiClientErrorStub(t testing.TB, err error) *internal.OpenFIGI { +func NewFigiClientErrorStub(t testing.TB, err error) *ofigi.Client { t.Helper() c := &http.Client{ @@ -300,5 +301,5 @@ func NewFigiClientErrorStub(t testing.TB, err error) *internal.OpenFIGI { }), } - return internal.NewOpenFIGI(c, "") + return ofigi.NewOpenFIGI(c, "") }