package com.cameleer.server.app.outbound.dto;

import com.cameleer.server.core.http.TrustMode;
import com.cameleer.server.core.outbound.OutboundAuthKind;
import com.cameleer.server.core.outbound.OutboundConnection;
import com.cameleer.server.core.outbound.OutboundMethod;

import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.UUID;

public record OutboundConnectionDto(
        UUID id, String name, String description, String url,
        OutboundMethod method, Map<String, String> defaultHeaders, String defaultBodyTmpl,
        TrustMode tlsTrustMode, List<String> tlsCaPemPaths,
        boolean hmacSecretSet,
        OutboundAuthKind authKind,
        List<UUID> allowedEnvironmentIds,
        Instant createdAt, String createdBy, Instant updatedAt, String updatedBy
) {
    public static OutboundConnectionDto from(OutboundConnection c) {
        return new OutboundConnectionDto(
                c.id(), c.name(), c.description(), c.url(), c.method(),
                c.defaultHeaders(), c.defaultBodyTmpl(),
                c.tlsTrustMode(), c.tlsCaPemPaths(),
                c.hmacSecretCiphertext() != null,
                c.auth().kind(), c.allowedEnvironmentIds(),
                c.createdAt(), c.createdBy(), c.updatedAt(), c.updatedBy());
    }
}
