package com.gcsc.connection.apihub.dto;

import com.gcsc.connection.service.entity.SnpServiceApi;

import java.time.LocalDateTime;

public record RecentApiResponse(
    Long apiId,
    String apiName,
    String apiPath,
    String apiMethod,
    String apiDomain,
    String description,
    Long serviceId,
    String serviceCode,
    String serviceName,
    LocalDateTime createdAt
) {

    public static RecentApiResponse from(SnpServiceApi api) {
        return new RecentApiResponse(
            api.getApiId(),
            api.getApiName(),
            api.getApiPath(),
            api.getApiMethod(),
            api.getApiDomain(),
            api.getDescription(),
            api.getService().getServiceId(),
            api.getService().getServiceCode(),
            api.getService().getServiceName(),
            api.getCreatedAt()
        );
    }
}
