use crate::model::{ArtifactGroup, GeneratedArtifact, TransportKind};
use std::path::PathBuf;

pub(super) fn build_artifact(
    relative_path: impl Into<PathBuf>,
    service_interface_name: Option<String>,
    artifact_group: ArtifactGroup,
    transport: TransportKind,
    content: String,
) -> GeneratedArtifact {
    let relative_path = relative_path.into();
    let file_name = relative_path
        .file_stem()
        .and_then(|value| value.to_str())
        .unwrap_or("generated")
        .to_string();
    let extension_name = relative_path
        .extension()
        .and_then(|value| value.to_str())
        .unwrap_or("")
        .to_string();
    GeneratedArtifact {
        relative_path,
        package_name: None,
        file_name,
        extension_name,
        content,
        artifact_group,
        transport,
        service_interface_name,
    }
}
