From 13d3c2e77c53a21fb6cd644ae5c9e95e55afc346 Mon Sep 17 00:00:00 2001 From: Steven Polley Date: Fri, 23 Feb 2024 23:01:36 -0700 Subject: [PATCH] refresh questrade client if it's nil --- providers/questrade/providerImpl.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/questrade/providerImpl.go b/providers/questrade/providerImpl.go index 66b9041..7a240d2 100644 --- a/providers/questrade/providerImpl.go +++ b/providers/questrade/providerImpl.go @@ -71,7 +71,7 @@ func (p *Provider) Configure() error { // Returns slices of account balances and mapped YNAB account IDs, along with an error func (p *Provider) GetBalances() ([]int, []string, error) { // Refresh credentials if past half way until expiration - if p.lastRefresh.Add(time.Second * time.Duration(p.client.Credentials.ExpiresIn) / 2).Before(time.Now()) { + if p.lastRefresh.Add(time.Second*time.Duration(p.client.Credentials.ExpiresIn)/2).Before(time.Now()) || p.client == nil { err := p.refresh() if err != nil { return make([]int, 0), make([]string, 0), fmt.Errorf("failed to refresh http client: %v", err)