# 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
defmodule Kreuzberg.EmailMetadata do
  @moduledoc """
  Email metadata extracted from .eml and .msg files.

  Includes sender/recipient information, message ID, and attachment list.
  """

  @typedoc "Email metadata extracted from .eml and .msg files."
  @type t :: %__MODULE__{
          from_email: String.t() | nil,
          from_name: String.t() | nil,
          to_emails: [String.t()],
          cc_emails: [String.t()],
          bcc_emails: [String.t()],
          message_id: String.t() | nil,
          attachments: [String.t()]
        }

  defstruct from_email: nil,
            from_name: nil,
            to_emails: [],
            cc_emails: [],
            bcc_emails: [],
            message_id: nil,
            attachments: []

  defimpl Jason.Encoder do
    @doc false
    def encode(value, opts) do
      value
      |> Map.from_struct()
      |> Enum.reject(fn {_k, v} -> v == nil end)
      |> Enum.into(%{})
      |> Jason.Encoder.encode(opts)
    end
  end
end
