package com.lingniu.ingest.protocol.jsatl12.inbound;

import java.time.Instant;

public record Jsatl12ArchivedChunk(
        String archiveRef,
        String archiveKey,
        String fileName,
        long fileOffset,
        long declaredSizeBytes,
        long sizeBytes,
        String peer,
        Instant archivedAt,
        String phone,
        String vin,
        boolean identityResolved,
        String identitySource
) {
    public Jsatl12ArchivedChunk {
        phone = phone == null ? "" : phone.trim();
        vin = vin == null || vin.isBlank() ? "unknown" : vin.trim();
        identitySource = identitySource == null || identitySource.isBlank() ? "UNKNOWN" : identitySource.trim();
    }

    public Jsatl12ArchivedChunk(String archiveRef,
                                String archiveKey,
                                String fileName,
                                long fileOffset,
                                long declaredSizeBytes,
                                long sizeBytes,
                                String peer,
                                Instant archivedAt) {
        this(archiveRef, archiveKey, fileName, fileOffset, declaredSizeBytes, sizeBytes, peer, archivedAt,
                "", "unknown", false, "UNKNOWN");
    }

    public Jsatl12ArchivedChunk(String archiveRef,
                                String archiveKey,
                                long sizeBytes,
                                String peer,
                                Instant archivedAt) {
        this(archiveRef, archiveKey, "", 0, sizeBytes, sizeBytes, peer, archivedAt,
                "", "unknown", false, "UNKNOWN");
    }
}
