|
|
@@ -38,7 +38,8 @@ public class StockService {
|
|
|
quote.setUpdatedAt(now());
|
|
|
|
|
|
if (quote.getName() == null) {
|
|
|
- quote = updateStockInformation(quote);
|
|
|
+ StockInfoResponse info = updateStockInformation(quote.getCode());
|
|
|
+ quote.setName(info.getName());
|
|
|
}
|
|
|
|
|
|
repository.save(quote);
|
|
|
@@ -46,11 +47,9 @@ public class StockService {
|
|
|
return quote;
|
|
|
}
|
|
|
|
|
|
- public Quote updateStockInformation(Quote quote) {
|
|
|
+ public StockInfoResponse updateStockInformation(String code) {
|
|
|
log.info("Current stock's name is null. Requesting latest information...");
|
|
|
- StockInfoResponse info = client.getStockInfo(quote.getCode(), key);
|
|
|
- quote.setName(info.getName());
|
|
|
- return quote;
|
|
|
+ return client.getStockInfo(code, key);
|
|
|
}
|
|
|
|
|
|
private BigDecimal getLastPrice(Quote quote) {
|