refactor(model): persist date, status, and error description
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.pablotj.restemailbridge.domain.model;
|
||||
|
||||
import java.time.Instant;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -7,9 +8,30 @@ import lombok.Getter;
|
||||
@Builder
|
||||
public class Email {
|
||||
|
||||
private String from;
|
||||
private String to;
|
||||
private String subject;
|
||||
private String body;
|
||||
private final String from;
|
||||
private final String to;
|
||||
private final String subject;
|
||||
private final String body;
|
||||
private EmailStatus status;
|
||||
private final Instant createdAt;
|
||||
private String errorDescription;
|
||||
|
||||
}
|
||||
public void markAsSent() {
|
||||
this.status = EmailStatus.SENT;
|
||||
}
|
||||
|
||||
public void markAsFailed(String errorDescription) {
|
||||
this.status = EmailStatus.FAILED;
|
||||
this.errorDescription = errorDescription;
|
||||
}
|
||||
|
||||
public static Email create(String from, String to, String subject, String body) {
|
||||
return Email.builder()
|
||||
.from(from)
|
||||
.to(to)
|
||||
.subject(subject)
|
||||
.body(body)
|
||||
.status(EmailStatus.PENDING)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.pablotj.restemailbridge.domain.model;
|
||||
|
||||
public enum EmailStatus {
|
||||
SENT, FAILED, PENDING
|
||||
}
|
||||
Reference in New Issue
Block a user