package net.northking.cctp.upperComputer.driver.harmony.hyppium;


import net.northking.cctp.upperComputer.deviceManager.HarmonyDeviceManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 对Hyppium Agent的请求数据
 */
public abstract class RequestData<T> {
    private final Logger log = LoggerFactory.getLogger(RequestData.class);
    private final String module = "com.ohos.devicetest.hypiumApiHelper";
    private final String method;
    private final Params<T> params = new Params<>();


    public RequestData(String method, String api, T args) {
        this.method = method;
        this.params.api = api;
        this.params.args = args;
    }

    public String getModule() {
        return module;
    }

    public String getMethod() {
        return method;
    }

    public byte[] toByteArray() {
        String jsonText = HarmonyDeviceManager.gson.toJson(this);
        log.debug("RequestData:{}", jsonText);
        return jsonText.getBytes();
    }

    static class Params<T> {
        String api;
        T args = null;

        private Params() {

        }
    }
}
