Skip to content

Commit 63faa5b

Browse files
refactor: remove legacy yahoo currency conversion
1 parent 66838e1 commit 63faa5b

File tree

17 files changed

+257
-2105
lines changed

17 files changed

+257
-2105
lines changed

internal/asset/asset_test.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,18 @@ var _ = Describe("Asset", func() {
8585
Currency: "EUR",
8686
},
8787
Reference: c.Reference{
88-
CurrencyRates: map[string]c.CurrencyRate{
89-
"USD": {
90-
FromCurrency: "USD",
91-
ToCurrency: "EUR",
92-
Rate: 1.5,
93-
},
94-
"GBP": {
95-
FromCurrency: "GBP",
96-
ToCurrency: "EUR",
97-
Rate: 2,
98-
},
99-
},
88+
// CurrencyRates: map[string]c.CurrencyRate{
89+
// "USD": {
90+
// FromCurrency: "USD",
91+
// ToCurrency: "EUR",
92+
// Rate: 1.5,
93+
// },
94+
// "GBP": {
95+
// FromCurrency: "GBP",
96+
// ToCurrency: "EUR",
97+
// Rate: 2,
98+
// },
99+
// },
100100
},
101101
}
102102
inputAssetGroupQuote := fixtureAssetGroupQuote
@@ -214,13 +214,13 @@ var _ = Describe("Asset", func() {
214214

215215
inputContext := c.Context{
216216
Reference: c.Reference{
217-
CurrencyRates: map[string]c.CurrencyRate{
218-
"EUR": {
219-
FromCurrency: "EUR",
220-
ToCurrency: "USD",
221-
Rate: 0.5,
222-
},
223-
},
217+
// CurrencyRates: map[string]c.CurrencyRate{
218+
// "EUR": {
219+
// FromCurrency: "EUR",
220+
// ToCurrency: "USD",
221+
// Rate: 0.5,
222+
// },
223+
// },
224224
},
225225
}
226226
inputAssetGroupQuote := fixtureAssetGroupQuote

internal/cli/cli.go

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
"github.com/achannarasappa/ticker/v4/internal/cli/symbol"
99
c "github.com/achannarasappa/ticker/v4/internal/common"
10-
yahooClient "github.com/achannarasappa/ticker/v4/internal/quote/yahoo/client"
1110
"github.com/achannarasappa/ticker/v4/internal/ui/util"
1211

1312
"github.com/adrg/xdg"
@@ -69,9 +68,7 @@ func GetDependencies() c.Dependencies {
6968
return c.Dependencies{
7069
Fs: afero.NewOsFs(),
7170
HttpClients: c.DependenciesHttpClients{
72-
Default: resty.New(),
73-
Yahoo: yahooClient.New(resty.New(), resty.New()),
74-
YahooSession: resty.New(),
71+
Default: resty.New(),
7572
},
7673
}
7774

@@ -85,8 +82,6 @@ func GetContext(d c.Dependencies, config c.Config) (c.Context, error) {
8582
err error
8683
)
8784

88-
err = yahooClient.RefreshSession(d.HttpClients.Yahoo, d.HttpClients.YahooSession)
89-
9085
if err != nil {
9186
return c.Context{}, err
9287
}
@@ -97,7 +92,7 @@ func GetContext(d c.Dependencies, config c.Config) (c.Context, error) {
9792
return c.Context{}, err
9893
}
9994

100-
reference, err = getReference(config, groups, d.HttpClients.Yahoo) // TODO: pass in default client for non-currency conversion requests
95+
reference, err = getReference(config, groups)
10196

10297
if err != nil {
10398
return c.Context{}, err
@@ -135,13 +130,9 @@ func readConfig(fs afero.Fs, configPathOption string) (c.Config, error) {
135130
return config, nil
136131
}
137132

138-
func getReference(config c.Config, assetGroups []c.AssetGroup, client *resty.Client) (c.Reference, error) {
133+
func getReference(config c.Config, assetGroups []c.AssetGroup) (c.Reference, error) {
139134

140135
var err error
141-
// currencyRates, err := quote.GetAssetGroupsCurrencyRates(client, assetGroups, config.Currency)
142-
// if err != nil {
143-
// return c.Reference{}, err
144-
// }
145136

146137
styles := util.GetColorScheme(config.ColorScheme)
147138

@@ -150,7 +141,6 @@ func getReference(config c.Config, assetGroups []c.AssetGroup, client *resty.Cli
150141
}
151142

152143
return c.Reference{
153-
// CurrencyRates: currencyRates,
154144
Styles: styles,
155145
}, err
156146

@@ -170,7 +160,6 @@ func GetConfig(dep c.Dependencies, configPath string, options Options) (c.Config
170160

171161
if len(config.Proxy) > 0 {
172162
dep.HttpClients.Default.SetProxy(config.Proxy)
173-
dep.HttpClients.Yahoo.SetProxy(config.Proxy)
174163
}
175164

176165
config.RefreshInterval = getRefreshInterval(options.RefreshInterval, config.RefreshInterval)

internal/cli/cli_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ var _ = Describe("Cli", func() {
6767
dep = c.Dependencies{
6868
Fs: afero.NewMemMapFs(),
6969
HttpClients: c.DependenciesHttpClients{
70-
Default: client,
71-
Yahoo: client,
72-
YahooSession: client,
70+
Default: client,
7371
},
7472
}
7573

@@ -475,7 +473,6 @@ var _ = Describe("Cli", func() {
475473
Fs: afero.NewMemMapFs(),
476474
HttpClients: c.DependenciesHttpClients{
477475
Default: client,
478-
Yahoo: client,
479476
},
480477
}
481478
afero.WriteFile(depLocal.Fs, ".ticker.yaml", []byte("watchlist:\n - NOK"), 0644)

internal/common/common.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ type AssetGroupQuote struct {
6464

6565
// Reference represents derived configuration for internal use from user defined configuration
6666
type Reference struct {
67-
CurrencyRates CurrencyRates
68-
Styles Styles
67+
Styles Styles
6968
}
7069

7170
// Dependencies represents references to external dependencies
@@ -75,9 +74,7 @@ type Dependencies struct {
7574
}
7675

7776
type DependenciesHttpClients struct { //nolint:golint,stylecheck,revive
78-
Default *resty.Client
79-
Yahoo *resty.Client
80-
YahooSession *resty.Client
77+
Default *resty.Client
8178
}
8279

8380
type Monitor interface {

internal/currency/currency_test.go

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ var _ = Describe("Currency", func() {
1414
It("should return default currency information when a rate is not found in reference data", func() {
1515
inputCtx := c.Context{
1616
Reference: c.Reference{
17-
CurrencyRates: c.CurrencyRates{
18-
"USD": c.CurrencyRate{
19-
FromCurrency: "USD",
20-
ToCurrency: "EUR",
21-
Rate: 4,
22-
},
23-
"GBP": c.CurrencyRate{
24-
FromCurrency: "GBP",
25-
ToCurrency: "EUR",
26-
Rate: 2,
27-
},
28-
},
17+
// CurrencyRates: c.CurrencyRates{
18+
// "USD": c.CurrencyRate{
19+
// FromCurrency: "USD",
20+
// ToCurrency: "EUR",
21+
// Rate: 4,
22+
// },
23+
// "GBP": c.CurrencyRate{
24+
// FromCurrency: "GBP",
25+
// ToCurrency: "EUR",
26+
// Rate: 2,
27+
// },
28+
// },
2929
},
3030
}
3131
outputCurrencyRateByUse := GetCurrencyRateFromContext(inputCtx, "EUR", "USD", 0)
@@ -44,20 +44,20 @@ var _ = Describe("Currency", func() {
4444
Currency: "EUR",
4545
},
4646
Reference: c.Reference{
47-
CurrencyRates: c.CurrencyRates{
48-
"USD": c.CurrencyRate{
49-
FromCurrency: "USD",
50-
ToCurrency: "EUR",
51-
Rate: 1.25,
52-
},
53-
"GBP": c.CurrencyRate{
54-
FromCurrency: "GBP",
55-
ToCurrency: "EUR",
56-
Rate: 2,
57-
},
58-
},
47+
// CurrencyRates: c.CurrencyRates{
48+
// "USD": c.CurrencyRate{
49+
// FromCurrency: "USD",
50+
// ToCurrency: "EUR",
51+
// Rate: 1.25,
52+
// },
53+
// "GBP": c.CurrencyRate{
54+
// FromCurrency: "GBP",
55+
// ToCurrency: "EUR",
56+
// Rate: 2,
57+
// },
5958
},
6059
}
60+
6161
outputCurrencyRateByUse := GetCurrencyRateFromContext(inputCtx, "USD", "EUR", 0)
6262
Expect(outputCurrencyRateByUse.QuotePrice).To(Equal(1.25))
6363
Expect(outputCurrencyRateByUse.PositionCost).To(Equal(1.25))
@@ -74,18 +74,18 @@ var _ = Describe("Currency", func() {
7474
Currency: "",
7575
},
7676
Reference: c.Reference{
77-
CurrencyRates: c.CurrencyRates{
78-
"USD": c.CurrencyRate{
79-
FromCurrency: "USD",
80-
ToCurrency: "EUR",
81-
Rate: 1.25,
82-
},
83-
"GBP": c.CurrencyRate{
84-
FromCurrency: "GBP",
85-
ToCurrency: "EUR",
86-
Rate: 2,
87-
},
88-
},
77+
// CurrencyRates: c.CurrencyRates{
78+
// "USD": c.CurrencyRate{
79+
// FromCurrency: "USD",
80+
// ToCurrency: "EUR",
81+
// Rate: 1.25,
82+
// },
83+
// "GBP": c.CurrencyRate{
84+
// FromCurrency: "GBP",
85+
// ToCurrency: "EUR",
86+
// Rate: 2,
87+
// },
88+
// },
8989
},
9090
}
9191
outputCurrencyRateByUse := GetCurrencyRateFromContext(inputCtx, "USD", "EUR", 0)
@@ -105,18 +105,18 @@ var _ = Describe("Currency", func() {
105105
CurrencyConvertSummaryOnly: true,
106106
},
107107
Reference: c.Reference{
108-
CurrencyRates: c.CurrencyRates{
109-
"USD": c.CurrencyRate{
110-
FromCurrency: "USD",
111-
ToCurrency: "EUR",
112-
Rate: 1.25,
113-
},
114-
"GBP": c.CurrencyRate{
115-
FromCurrency: "GBP",
116-
ToCurrency: "EUR",
117-
Rate: 2,
118-
},
119-
},
108+
// CurrencyRates: c.CurrencyRates{
109+
// "USD": c.CurrencyRate{
110+
// FromCurrency: "USD",
111+
// ToCurrency: "EUR",
112+
// Rate: 1.25,
113+
// },
114+
// "GBP": c.CurrencyRate{
115+
// FromCurrency: "GBP",
116+
// ToCurrency: "EUR",
117+
// Rate: 2,
118+
// },
119+
// },
120120
},
121121
}
122122
outputCurrencyRateByUse := GetCurrencyRateFromContext(inputCtx, "USD", "EUR", 0)
@@ -136,18 +136,18 @@ var _ = Describe("Currency", func() {
136136
CurrencyDisableUnitCostConversion: true,
137137
},
138138
Reference: c.Reference{
139-
CurrencyRates: c.CurrencyRates{
140-
"USD": c.CurrencyRate{
141-
FromCurrency: "USD",
142-
ToCurrency: "EUR",
143-
Rate: 1.25,
144-
},
145-
"GBP": c.CurrencyRate{
146-
FromCurrency: "GBP",
147-
ToCurrency: "EUR",
148-
Rate: 2,
149-
},
150-
},
139+
// CurrencyRates: c.CurrencyRates{
140+
// "USD": c.CurrencyRate{
141+
// FromCurrency: "USD",
142+
// ToCurrency: "EUR",
143+
// Rate: 1.25,
144+
// },
145+
// "GBP": c.CurrencyRate{
146+
// FromCurrency: "GBP",
147+
// ToCurrency: "EUR",
148+
// Rate: 2,
149+
// },
150+
// },
151151
},
152152
}
153153
outputCurrencyRateByUse := GetCurrencyRateFromContext(inputCtx, "USD", "EUR", 0)

internal/print/print_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ var _ = Describe("Print", func() {
3434
inputDependencies = c.Dependencies{
3535
HttpClients: c.DependenciesHttpClients{
3636
Default: client,
37-
Yahoo: client,
3837
},
3938
}
4039
)

0 commit comments

Comments
 (0)