53 lines
2.2 KiB
Java
53 lines
2.2 KiB
Java
/*
|
|
* Copyright 2025 Google. This software is provided as-is, without warranty or representation for any use or purpose.
|
|
* Your use of it is subject to your agreement with Google.
|
|
*/
|
|
|
|
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;
|
|
|
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
@JsonInclude(Include.NON_NULL)
|
|
public record ConversationSessionDTO(
|
|
String sessionId,
|
|
String userId,
|
|
String telefono,
|
|
Instant createdAt,
|
|
Instant lastModified,
|
|
String lastMessage,
|
|
String pantallaContexto
|
|
) {
|
|
public ConversationSessionDTO(String sessionId, String userId, String telefono, Instant createdAt, Instant lastModified, String lastMessage, String pantallaContexto) {
|
|
this.sessionId = sessionId;
|
|
this.userId = userId;
|
|
this.telefono = telefono;
|
|
this.createdAt = createdAt;
|
|
this.lastModified = lastModified;
|
|
this.lastMessage = lastMessage;
|
|
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, null, null);
|
|
}
|
|
|
|
public ConversationSessionDTO withLastMessage(String lastMessage) {
|
|
return new ConversationSessionDTO(this.sessionId, this.userId, this.telefono, this.createdAt, Instant.now(), lastMessage, 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.lastMessage, this.pantallaContexto);
|
|
}
|
|
return this;
|
|
}
|
|
|
|
public ConversationSessionDTO withPantallaContexto(String pantallaContexto) {
|
|
return new ConversationSessionDTO(this.sessionId, this.userId, this.telefono, this.createdAt, this.lastModified, this.lastMessage, pantallaContexto);
|
|
}
|
|
} |