package com.banesco.common.infrastructure.config;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import lombok.Getter;
import org.eclipse.microprofile.config.Config;

@ApplicationScoped
@Getter
public class MessagesConfig {

    private final boolean readFromProps;
    private final String errorMessagesJson;
    private final String messagesKey;

    private static final String KEY = "dom-docservice-file-audit-trace";

    @Inject
    public MessagesConfig(Config config) {
        this.readFromProps = config.getValue("api.read-messages.from-props", Boolean.class);
        this.errorMessagesJson = config.getValue("api." + KEY + ".messages.content", String.class);
        this.messagesKey = config.getValue("api." + KEY + ".messages.key", String.class);
    }

    public String getErrorMessagesJson() {
        if (readFromProps) {
            return errorMessagesJson != null ? errorMessagesJson : "";
        } else {
            return "";
        }
    }
}