use of com.nexblocks.authguard.api.dto.entities.ExchangeAttemptDTO in project AuthGuard by AuthGuard.
the class AuthRoute method getExchangeAttempts.
@Override
public void getExchangeAttempts(final Context context) {
final String entityId = context.queryParam("entityId");
final OffsetDateTime fromTimestamp = parseOffsetDateTime(context.queryParam("fromTimestamp"));
final String fromExchange = context.queryParam("fromExchange");
// take care of checking the parameters
if (entityId == null) {
context.status(400).json(new Error(ErrorCode.MISSING_REQUEST_QUERY.getCode(), "Query parameter entityId is required"));
return;
}
if (fromExchange != null && fromTimestamp == null) {
context.status(400).json(new Error(ErrorCode.MISSING_REQUEST_QUERY.getCode(), "Query parameter fromTimestamp is required when fromExchange is set"));
return;
}
// do the real work
final ExchangeAttemptsQueryBO query = ExchangeAttemptsQueryBO.builder().entityId(entityId).fromTimestamp(fromTimestamp).fromExchange(fromExchange).build();
final Collection<ExchangeAttemptDTO> attempts = exchangeAttemptsService.find(query).stream().map(restMapper::toDTO).collect(Collectors.toList());
context.json(attempts);
}
Aggregations