package tw.com.altob.goodpk.Api;

import com.ga.sdk.api.Params;

import tw.com.altob.goodpk.Util.CryptionUtil;

public class GoodPkApi extends BaseApi {

    //鎖車
    private static final String CARSECURITY = "/CARSECURITY?acct=%1$s&pwd=%2$s&status=%3$s&key=%4$s&station=%5$s";

    //改密碼
    private static final String CHANGEPW = "/change_pwd_40808/%1$s/%2$s/%3$s/%4$s";

    //尋車
    private static final String CARWHERE = "/CARWHERE?carNo=%1$s";

    /*鎖車
    使用者車號
    使用者密碼
    加密後資料
    狀態(0.解鎖 1.鎖車 2.查詢)
     */
    public String getCarSecurity(String acct, String pwd, String status, String key, String station)
            throws Exception {
        Params params = new Params();

        String Nacct = CryptionUtil.aesEncryptBase64(acct, "Altob");
        Nacct = Nacct.replace("\n", "");
        return this.doGet( String.format(CARSECURITY, Nacct, pwd, status, key, station), params.getMap());
    }

    public String changePwd(String acct, String pwd, String npwd, String key)
            throws Exception {
        Params params = new Params();

        return this.doGet( String.format(CHANGEPW, acct, pwd, npwd, key), params.getMap());
    }

    public String getCarWhere(String carNo)
            throws Exception {
        Params params = new Params();

        return this.doGet( String.format(CARWHERE, CryptionUtil.aesEncryptBase64(carNo, "Altob")), params.getMap());
    }
}
