refresh questrade client if it's nil
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Steven Polley 2024-02-23 23:01:36 -07:00
parent 65d4780a3b
commit 13d3c2e77c
1 changed files with 1 additions and 1 deletions

View File

@ -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)