Skip to content

Commit e032717

Browse files
authored
fix(Atlar): Allow missing balance in Atlar account response (#1967)
1 parent 854a05a commit e032717

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

components/payments/cmd/connectors/internal/connectors/atlar/task_fetch_accounts.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -157,22 +157,24 @@ func ingestAccountsBatch(
157157
RawData: raw,
158158
})
159159

160-
balance := account.Balance
161-
balanceTimestamp, err := ParseAtlarTimestamp(balance.Timestamp)
162-
if err != nil {
163-
return err
160+
if account.Balance != nil {
161+
balance := account.Balance
162+
balanceTimestamp, err := ParseAtlarTimestamp(balance.Timestamp)
163+
if err != nil {
164+
return err
165+
}
166+
balanceBatch = append(balanceBatch, &models.Balance{
167+
AccountID: models.AccountID{
168+
Reference: *account.ID,
169+
ConnectorID: connectorID,
170+
},
171+
Asset: currency.FormatAsset(supportedCurrenciesWithDecimal, *balance.Amount.Currency),
172+
Balance: big.NewInt(*balance.Amount.Value),
173+
CreatedAt: balanceTimestamp,
174+
LastUpdatedAt: time.Now().UTC(),
175+
ConnectorID: connectorID,
176+
})
164177
}
165-
balanceBatch = append(balanceBatch, &models.Balance{
166-
AccountID: models.AccountID{
167-
Reference: *account.ID,
168-
ConnectorID: connectorID,
169-
},
170-
Asset: currency.FormatAsset(supportedCurrenciesWithDecimal, *balance.Amount.Currency),
171-
Balance: big.NewInt(*balance.Amount.Value),
172-
CreatedAt: balanceTimestamp,
173-
LastUpdatedAt: time.Now().UTC(),
174-
ConnectorID: connectorID,
175-
})
176178
}
177179

178180
if err := ingester.IngestAccounts(ctx, accountsBatch); err != nil {

0 commit comments

Comments
 (0)