package com.fs.erp.utils;


import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;


public class ScrmStoreUrlUtils {
    public static String getUrl(String url, String sign, String timeStep) {
        String updatedUrl = updateURLParams(url, "timestep", timeStep);
        updatedUrl = updateURLParams(updatedUrl, "sign", sign);
        return updatedUrl;
    }

    public static String updateURLParams(String url, String param, String value) {
        String encodedValue;
        try {
            encodedValue = URLEncoder.encode(value, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            encodedValue = value;
            e.printStackTrace();
        }

        return url.replaceAll(param + "=", param + "=" + encodedValue);
    }
}
