// This file is auto-generated by alef — DO NOT EDIT.
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
// To regenerate: alef generate
// To verify freshness: alef verify --exit-code
// Issues & docs: https://github.com/kreuzberg-dev/alef
package dev.kreuzberg;

import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import org.jspecify.annotations.Nullable;

/**
 * Email extraction result.
 *
 * Complete representation of an extracted email message (.eml or .msg)
 * including headers, body content, and attachments.
 */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = EmailExtractionResult.Builder.class)
public record EmailExtractionResult(
    /**
     * Email subject line
     */
    @Nullable @JsonProperty("subject") String subject,
    /**
     * Sender email address
     */
    @Nullable @JsonProperty("from_email") String fromEmail,
    /**
     * Primary recipient email addresses
     */
    @JsonProperty("to_emails") List<String> toEmails,
    /**
     * CC recipient email addresses
     */
    @JsonProperty("cc_emails") List<String> ccEmails,
    /**
     * BCC recipient email addresses
     */
    @JsonProperty("bcc_emails") List<String> bccEmails,
    /**
     * Email date/timestamp
     */
    @Nullable @JsonProperty("date") String date,
    /**
     * Message-ID header value
     */
    @Nullable @JsonProperty("message_id") String messageId,
    /**
     * Plain text version of the email body
     */
    @Nullable @JsonProperty("plain_text") String plainText,
    /**
     * HTML version of the email body
     */
    @Nullable @JsonProperty("html_content") String htmlContent,
    /**
     * Cleaned/processed text content. Aliased as {@code cleaned_text} for back-compat.
     */
    @JsonProperty("content") String content,
    /**
     * List of email attachments
     */
    @JsonProperty("attachments") List<EmailAttachment> attachments,
    /**
     * Additional email headers and metadata
     */
    @JsonProperty("metadata") Map<String, String> metadata
) {
    public static Builder builder() {
        return new Builder();
    }

    // CPD-OFF
    @JsonPOJOBuilder(withPrefix = "with", buildMethodName = "build")
    public static final class Builder {

private String subject = null;
        @JsonProperty("from_email")
private String fromEmail = null;
        @JsonProperty("to_emails")
private List<String> toEmails = List.of();
        @JsonProperty("cc_emails")
private List<String> ccEmails = List.of();
        @JsonProperty("bcc_emails")
private List<String> bccEmails = List.of();
private String date = null;
        @JsonProperty("message_id")
private String messageId = null;
        @JsonProperty("plain_text")
private String plainText = null;
        @JsonProperty("html_content")
private String htmlContent = null;
private String content = "";
private List<EmailAttachment> attachments = List.of();
private Map<String, String> metadata = Map.of();

        /** Sets the subject field. */
        @JsonProperty("subject")
        public Builder withSubject(final @Nullable String value) {
            this.subject = value;
            return this;
        }

        /** Sets the fromEmail field. */
        @JsonProperty("from_email")
        public Builder withFromEmail(final @Nullable String value) {
            this.fromEmail = value;
            return this;
        }

        /** Sets the toEmails field. */
        @JsonProperty("to_emails")
        public Builder withToEmails(final List<String> value) {
            this.toEmails = value;
            return this;
        }

        /** Sets the ccEmails field. */
        @JsonProperty("cc_emails")
        public Builder withCcEmails(final List<String> value) {
            this.ccEmails = value;
            return this;
        }

        /** Sets the bccEmails field. */
        @JsonProperty("bcc_emails")
        public Builder withBccEmails(final List<String> value) {
            this.bccEmails = value;
            return this;
        }

        /** Sets the date field. */
        @JsonProperty("date")
        public Builder withDate(final @Nullable String value) {
            this.date = value;
            return this;
        }

        /** Sets the messageId field. */
        @JsonProperty("message_id")
        public Builder withMessageId(final @Nullable String value) {
            this.messageId = value;
            return this;
        }

        /** Sets the plainText field. */
        @JsonProperty("plain_text")
        public Builder withPlainText(final @Nullable String value) {
            this.plainText = value;
            return this;
        }

        /** Sets the htmlContent field. */
        @JsonProperty("html_content")
        public Builder withHtmlContent(final @Nullable String value) {
            this.htmlContent = value;
            return this;
        }

        /** Sets the content field. */
        @JsonProperty("content")
        public Builder withContent(final String value) {
            this.content = value;
            return this;
        }

        /** Sets the attachments field. */
        @JsonProperty("attachments")
        public Builder withAttachments(final List<EmailAttachment> value) {
            this.attachments = value;
            return this;
        }

        /** Sets the metadata field. */
        @JsonProperty("metadata")
        public Builder withMetadata(final Map<String, String> value) {
            this.metadata = value;
            return this;
        }

        /** Builds the EmailExtractionResult instance. */
        public EmailExtractionResult build() {
            return new EmailExtractionResult(
                subject,
                fromEmail,
                toEmails,
                ccEmails,
                bccEmails,
                date,
                messageId,
                plainText,
                htmlContent,
                content,
                attachments,
                metadata
            );
        }
    }
    // CPD-ON
}
