package epson.print.copy.Component.eremoteoperation;

import org.json.JSONObject;

import java.util.ArrayList;

public class ERemotePrinter extends ERemoteOperation {

    public class ERemotePrinterComponentsResult extends ERemoteOperation.ERemoteOperationResult {
        public ERemotePrinterComponentsResult(JSONObject jSONObject) {
            super(jSONObject);
        }

        public ArrayList<ERemoteOperation.ERemoteParam> components() {
            return getParamsValueOf(ERemoteOperation.ERemoteParam.components);
        }
    }

    public class ERemotePrinterStatusResult extends ERemoteOperation.ERemoteOperationResult {
        public ERemotePrinterStatusResult(JSONObject jSONObject) {
            super(jSONObject);
        }

        public ERemoteOperation.ERemoteParam print_x_disc_try_state() {
            return getParamValueOf(ERemoteOperation.ERemoteParam.print_x_disc_tray_state);
        }

        public ERemoteOperation.ERemoteParam printer_state() {
            return getParamValueOf(ERemoteOperation.ERemoteParam.printer_state);
        }

        public ArrayList<ERemoteOperation.ERemoteParam> printer_state_reasons() {
            return getParamsValueOf(ERemoteOperation.ERemoteParam.printer_state_reasons);
        }
    }

    public ERemotePrinterComponentsResult getComponents(ERemoteOperation.IRemoteOperationParameter iRemoteOperationParameter) {
        ERemoteOperation.ERemoteRequestBuilder requestPrinter = ERemoteOperation.ERemoteRequestBuilder.requestPrinter(this.hostIP, ERemoteOperation.RequestParam.get_components, getRequestConnectionTimeout());
        requestPrinter.add(ERemoteOperation.ERemoteParam.client_id, iRemoteOperationParameter.client_id());
        return new ERemotePrinterComponentsResult(requestPrinter.getRemoteRequest().execute());
    }

    public ERemotePrinterStatusResult getStatus(ERemoteOperation.IRemoteStatusParameter iRemoteStatusParameter) {
        ERemoteOperation.ERemoteRequestBuilder requestPrinter = ERemoteOperation.ERemoteRequestBuilder.requestPrinter(this.hostIP, ERemoteOperation.RequestParam.get_status, getRequestConnectionTimeout());
        requestPrinter.add(ERemoteOperation.ERemoteParam.client_id, iRemoteStatusParameter.client_id());
        requestPrinter.add(ERemoteOperation.ERemoteParam.keys, iRemoteStatusParameter.keys());
        ERemotePrinterStatusResult eRemotePrinterStatusResult = new ERemotePrinterStatusResult(requestPrinter.getRemoteRequest().execute());
        eRemotePrinterStatusResult.setRemoteRequestBuilder(requestPrinter);
        return eRemotePrinterStatusResult;
    }

    public ERemoteOperation.ERemoteOperationResult clearError(ERemoteOperation.IRemoteOperationParameter iRemoteOperationParameter) {
        ERemoteOperation.ERemoteRequestBuilder requestPrinter = ERemoteOperation.ERemoteRequestBuilder.requestPrinter(this.hostIP, ERemoteOperation.RequestParam.clear_error, getRequestConnectionTimeout());
        requestPrinter.add(ERemoteOperation.ERemoteParam.client_id, iRemoteOperationParameter.client_id());
        ERemotePrinterStatusResult eRemotePrinterStatusResult = new ERemotePrinterStatusResult(requestPrinter.getRemoteRequest().execute());
        eRemotePrinterStatusResult.setRemoteRequestBuilder(requestPrinter);
        return eRemotePrinterStatusResult;
    }
}
