UPDATE code 20-Ago
This commit is contained in:
@@ -30,17 +30,29 @@ public record ConversationEntryDTO(
|
||||
|
||||
public static ConversationEntryDTO forAgent(QueryResultDTO agentQueryResult) {
|
||||
String fulfillmentText = (agentQueryResult != null && agentQueryResult.responseText() != null) ? agentQueryResult.responseText() : "";
|
||||
Map<String, Object> parameters = (agentQueryResult != null) ? agentQueryResult.parameters() : null;
|
||||
|
||||
return new ConversationEntryDTO(
|
||||
ConversationEntryEntity.AGENTE,
|
||||
ConversationEntryType.CONVERSACION,
|
||||
Instant.now(),
|
||||
fulfillmentText,
|
||||
agentQueryResult.parameters(),
|
||||
parameters,
|
||||
null
|
||||
);
|
||||
}
|
||||
public static ConversationEntryDTO forSystem(String text) {
|
||||
|
||||
public static ConversationEntryDTO forAgentWithMessage(String text) {
|
||||
return new ConversationEntryDTO(
|
||||
ConversationEntryEntity.AGENTE,
|
||||
ConversationEntryType.CONVERSACION,
|
||||
Instant.now(),
|
||||
text,
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
public static ConversationEntryDTO forSystem(String text) {
|
||||
return new ConversationEntryDTO(
|
||||
ConversationEntryEntity.SISTEMA,
|
||||
ConversationEntryType.CONVERSACION,
|
||||
|
||||
@@ -6,44 +6,53 @@
|
||||
package com.example.dto.dialogflow.conversation;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
public record ConversationSessionDTO(
|
||||
String sessionId,
|
||||
String userId,
|
||||
String telefono,
|
||||
Instant createdAt,
|
||||
Instant lastModified,
|
||||
List<ConversationEntryDTO> entries
|
||||
List<ConversationEntryDTO> entries,
|
||||
String pantallaContexto
|
||||
) {
|
||||
public ConversationSessionDTO(String sessionId, String userId, String telefono, Instant createdAt, Instant lastModified, List<ConversationEntryDTO> entries) {
|
||||
public ConversationSessionDTO(String sessionId, String userId, String telefono, Instant createdAt, Instant lastModified, List<ConversationEntryDTO> entries, String pantallaContexto) {
|
||||
this.sessionId = sessionId;
|
||||
this.userId = userId;
|
||||
this.telefono = telefono;
|
||||
this.createdAt = createdAt;
|
||||
this.lastModified = lastModified;
|
||||
this.entries = Collections.unmodifiableList(new ArrayList<>(entries));
|
||||
this.pantallaContexto = pantallaContexto;
|
||||
}
|
||||
|
||||
public static ConversationSessionDTO create(String sessionId, String userId, String telefono) {
|
||||
Instant now = Instant.now();
|
||||
return new ConversationSessionDTO(sessionId, userId, telefono, now, now, Collections.emptyList());
|
||||
return new ConversationSessionDTO(sessionId, userId, telefono, now, now, Collections.emptyList(), null);
|
||||
}
|
||||
|
||||
public ConversationSessionDTO withAddedEntry(ConversationEntryDTO newEntry) {
|
||||
List<ConversationEntryDTO> updatedEntries = new ArrayList<>(this.entries);
|
||||
updatedEntries.add(newEntry);
|
||||
return new ConversationSessionDTO(this.sessionId, this.userId, this.telefono, this.createdAt, Instant.now(), updatedEntries);
|
||||
return new ConversationSessionDTO(this.sessionId, this.userId, this.telefono, this.createdAt, Instant.now(), updatedEntries, this.pantallaContexto);
|
||||
}
|
||||
|
||||
public ConversationSessionDTO withTelefono(String newTelefono) {
|
||||
if (newTelefono != null && !newTelefono.equals(this.telefono)) {
|
||||
return new ConversationSessionDTO(this.sessionId, this.userId, newTelefono, this.createdAt, this.lastModified, this.entries);
|
||||
return new ConversationSessionDTO(this.sessionId, this.userId, newTelefono, this.createdAt, this.lastModified, this.entries, this.pantallaContexto);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConversationSessionDTO withPantallaContexto(String pantallaContexto) {
|
||||
return new ConversationSessionDTO(this.sessionId, this.userId, this.telefono, this.createdAt, this.lastModified, this.entries, pantallaContexto);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,8 @@ public record ExternalConvRequestDTO(
|
||||
@JsonProperty("mensaje") String message,
|
||||
@JsonProperty("usuario") UsuarioDTO user,
|
||||
@JsonProperty("canal") String channel,
|
||||
@JsonProperty("tipo") ConversationEntryType tipo
|
||||
@JsonProperty("tipo") ConversationEntryType tipo,
|
||||
@JsonProperty("pantallaContexto") String pantallaContexto //optional field for quick-replies
|
||||
) {
|
||||
public ExternalConvRequestDTO {}
|
||||
}
|
||||
Reference in New Issue
Block a user