package com.gcsc.connection.apikey.dto;

import com.gcsc.connection.apikey.entity.SnpApiPermission;

import java.time.LocalDateTime;

public record PermissionResponse(
    Long permissionId,
    Long apiId,
    String apiPath,
    String apiMethod,
    String apiName,
    String serviceName,
    Boolean isActive,
    LocalDateTime grantedAt
) {

    public static PermissionResponse from(SnpApiPermission perm) {
        return new PermissionResponse(
            perm.getPermissionId(),
            perm.getApi().getApiId(),
            perm.getApi().getApiPath(),
            perm.getApi().getApiMethod(),
            perm.getApi().getApiName(),
            perm.getApi().getService().getServiceName(),
            perm.getIsActive(),
            perm.getGrantedAt()
        );
    }
}
