package org.brapi.test.BrAPITestServer.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "minio")
public class MinioProperties {
	private String endpoint = "minio:9000";
	private String accessKey = "minioadmin";
	private String secretKey = "ChangeMe_Minio_Strong_123456";
	private String bucket = "images";
	private boolean secure = false;
	private boolean localFallbackEnabled = true;
	private String localDirectory = "uploads/images";

	public String getEndpoint() {
		return endpoint;
	}

	public void setEndpoint(String endpoint) {
		this.endpoint = endpoint;
	}

	public String getAccessKey() {
		return accessKey;
	}

	public void setAccessKey(String accessKey) {
		this.accessKey = accessKey;
	}

	public String getSecretKey() {
		return secretKey;
	}

	public void setSecretKey(String secretKey) {
		this.secretKey = secretKey;
	}

	public String getBucket() {
		return bucket;
	}

	public void setBucket(String bucket) {
		this.bucket = bucket;
	}

	public boolean isSecure() {
		return secure;
	}

	public void setSecure(boolean secure) {
		this.secure = secure;
	}

	public boolean isLocalFallbackEnabled() {
		return localFallbackEnabled;
	}

	public void setLocalFallbackEnabled(boolean localFallbackEnabled) {
		this.localFallbackEnabled = localFallbackEnabled;
	}

	public String getLocalDirectory() {
		return localDirectory;
	}

	public void setLocalDirectory(String localDirectory) {
		this.localDirectory = localDirectory;
	}

	public String getEndpointUrl() {
		if (endpoint.startsWith("http://") || endpoint.startsWith("https://")) {
			return endpoint;
		}
		return (secure ? "https://" : "http://") + endpoint;
	}
}
