package org.example.petshopdesktop.api;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ApiConfig {
    private static final ApiConfig INSTANCE = new ApiConfig();
    private final String baseUrl;

    private ApiConfig() {
        Properties props = new Properties();
        String url = "http://localhost:8080";

        try (InputStream input = getClass().getClassLoader().getResourceAsStream("connectionpetstore.properties")) {
            if (input != null) {
                props.load(input);
                url = props.getProperty("api.baseUrl", "http://localhost:8080");
            }
        } catch (IOException e) {
            System.err.println("Failed to load api.baseUrl from properties: " + e.getMessage());
        }

        this.baseUrl = url;
    }

    public static ApiConfig getInstance() {
        return INSTANCE;
    }

    public String getBaseUrl() {
        return baseUrl;
    }
}
