package epson.print.copy.Component.eremoteoperation;

import org.json.JSONObject;

import java.util.ArrayList;

public class ERemoteDevice extends ERemoteOperation {

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

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

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

        public ERemoteOperation.ERemoteParam print_x_disc_tray_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 boolean document_on_adf() {
            return getBooleanValueOf(ERemoteOperation.ERemoteParam.document_on_adf);
        }

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

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

    public ERemoteDeviceFunctionsResult getFunctions(ERemoteOperation.IRemoteOperationParameter iRemoteOperationParameter) {
        ERemoteOperation.ERemoteRequestBuilder requestDevice = ERemoteOperation.ERemoteRequestBuilder.requestDevice(this.hostIP, ERemoteOperation.RequestParam.get_functions, getRequestConnectionTimeout());
        requestDevice.add(ERemoteOperation.ERemoteParam.client_id, iRemoteOperationParameter.client_id());
        ERemoteDeviceFunctionsResult eRemoteDeviceFunctionsResult = new ERemoteDeviceFunctionsResult(requestDevice.getRemoteRequest().execute());
        eRemoteDeviceFunctionsResult.setRemoteRequestBuilder(requestDevice);
        return eRemoteDeviceFunctionsResult;
    }

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

    public ERemoteDeviceFunctionsResult executeGetFunctionsCommand(final String str) {
        return getFunctions(new ERemoteOperation.IRemoteOperationParameter() {
            public String client_id() {
                return str;
            }
        });
    }
}
