package cordova.plugin.DiDi;

import com.sdu.didi.openapi.DiDiWebActivity;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.json.JSONArray;
import org.json.JSONException;

import java.util.HashMap;

/**
 * This class echoes a string called from JavaScript.
 */
public class DiDi extends CordovaPlugin {

    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
        if (action.equals("openDiDi")) {
            String message = args.getString(0);
          //  this.coolMethod(message, callbackContext);
            openDiDi();
            return true;
        }
        return false;
    }

    private void coolMethod(String message, CallbackContext callbackContext) {
        if (message != null && message.length() > 0) {
            callbackContext.success(message);
        } else {
            callbackContext.error("Expected one non-empty string argument.");
        }
    }
    private void openDiDi(){
        DiDiWebActivity.registerApp(this.cordova.getActivity(),"didi6358574A5079702B68447976547377","f14aed32707f69ae23e7858c1fd29e4e");
        DiDiWebActivity.showDDPage(this.cordova.getActivity(), new HashMap<String, String>());
    }
}
