package com.yidianling.ydl_pay.common.http.utils;

import com.yidianling.ydl_pay.BuildConfig;

/**
 * @author jiucheng
 * @描述:获取api的baseUrl
 * @Copyright Copyright (c) 2018
 * @Company 壹点灵
 * @date 2019/4/23
 */
public class HttpUrlUtils {

    private static final String JAVA_BASE_URL = "https://api.ydl.com/api/";
    private static final String ACTION_BASE_URL = "https://api.ydl.com/api/data/bigdata/";
    private static final String PHP_BASE_URL = "https://app2.yidianling.com/v3/";
    private static final String DEBUG_JAVA_BASE_URL = "http://testapi.ydl.com/api/";
    private static final String DEBUG_PHP_BASE_URL = "https://testapp2.yidianling.com/v3/";
    private static final String DEBUG_ACTION_BASE_URL = "https://testapi.ydl.com/api/data/bigdata/";


    /**
     * 获取baseUrl
     *
     * @param isTestEnvironment 是否是测试环境
     * @param isJava            是否是java url
     * @return
     */
    public static String getBaseUrl(boolean isTestEnvironment, boolean isJava) {
        String baseUrl;
        if (BuildConfig.DEBUG) {//debug包
            if (isTestEnvironment) {//测试环境
                if (isJava) {
                    baseUrl = DEBUG_JAVA_BASE_URL;
                } else {
                    baseUrl = DEBUG_PHP_BASE_URL;
                }
            } else {
                if (isJava) {
                    baseUrl = JAVA_BASE_URL;
                } else {
                    baseUrl = PHP_BASE_URL;
                }
            }
        } else {//release 包
            if (isJava) {
                baseUrl = JAVA_BASE_URL;
            } else {
                baseUrl = PHP_BASE_URL;
            }
        }
        return baseUrl;
    }

    /**
     * 获取埋点的baseurl
     *
     * @param isTestEnvironment 是否是测试环境
     * @return
     */
    public static String geActionUrl(boolean isTestEnvironment) {
        String baseUrl;
        if (BuildConfig.DEBUG) {//debug包
            if (isTestEnvironment) {//测试环境
                baseUrl = DEBUG_ACTION_BASE_URL;
            } else {
                baseUrl = ACTION_BASE_URL;
            }
        } else {//release 包
            baseUrl = DEBUG_ACTION_BASE_URL;
        }
        return baseUrl;
    }

}
