package dev.photosync.core.provider;

import java.util.Objects;

/**
 * What the settings screen needs in order to render a provider's connection
 * form without knowing which provider it is looking at.
 *
 * <p>The point of this type is that adding a second backend means writing a
 * {@link ProviderFactory} and a language file -- not editing the GUI. The UI
 * resolves labels by appending fixed suffixes to {@link #translationPrefix()}:
 *
 * <ul>
 *   <li>{@code .name} -- provider name in the picker</li>
 *   <li>{@code .endpoint} / {@code .endpoint.hint} -- first credential field</li>
 *   <li>{@code .secret} / {@code .secret.hint} -- second credential field</li>
 * </ul>
 */
public record ProviderDescriptor(ProviderId id, String translationPrefix, boolean supportsAlbums) {

    public ProviderDescriptor {
        Objects.requireNonNull(id, "id");
        Objects.requireNonNull(translationPrefix, "translationPrefix");
    }

    public String nameKey() {
        return translationPrefix + ".name";
    }

    public String endpointKey() {
        return translationPrefix + ".endpoint";
    }

    public String endpointHintKey() {
        return translationPrefix + ".endpoint.hint";
    }

    public String secretKey() {
        return translationPrefix + ".secret";
    }

    public String secretHintKey() {
        return translationPrefix + ".secret.hint";
    }
}
