package it.com.atlassian.bitbucket.contract.consumer.importer;

import com.atlassian.bitbucket.test.DefaultFuncTestData;
import com.google.common.collect.ImmutableMap;

import java.util.Map;

public class ImporterConsumerHelper {

    public static Map<String, Object> createCredentialBody(String username, String password) {
        return ImmutableMap.of(
                "username", username,
                "password", password
        );
    }

    public static Map<String, Object> createExternalRequestBody(String username, String password, String sourceType) {
        return ImmutableMap.of(
                "credential", createCredentialBody(username, password),
                "source", createSourceBody(sourceType)
        );
    }

    public static Map<String, Object> createReposBody(String ownerName,  Map<String, Object> credential,  Map<String, Object> source) {
        return ImmutableMap.of(
                "ownerName", ownerName,
                "credential", credential,
                "source", source
        );
    }

    public static Map<String, Object> createSourceBody(String sourceType) {
        return ImmutableMap.of(
                "type", sourceType
        );
    }

    public static String getImporterUrl() {
        return DefaultFuncTestData.getRestURL("importer", "latest") + "/external-source";
    }

    public static String getMissingOAuthScopesUrl() {
        return getImporterUrl() + "/missing-oauth-scopes";
    }

    public static String getOwnersUrl() {
        return getImporterUrl() + "/owners";
    }

    public static String getRepositoriesUrl() {
        return getImporterUrl() + "/repos";
    }

    public static String getUserUrl() {
        return getImporterUrl() + "/user";
    }
}
