package epson.print.copy.Component.eremoteoperation;

import org.json.JSONObject;

import java.util.ArrayList;

public class ERemoteScanner extends ERemoteOperation {

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

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

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

        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 ERemoteScannerComponentsResult getComponents(ERemoteOperation.IRemoteOperationParameter iRemoteOperationParameter) {
        ERemoteOperation.ERemoteRequestBuilder requestScanner = ERemoteOperation.ERemoteRequestBuilder.requestScanner(this.hostIP, ERemoteOperation.RequestParam.get_components, getRequestConnectionTimeout());
        requestScanner.add(ERemoteOperation.ERemoteParam.client_id, iRemoteOperationParameter.client_id());
        ERemoteScannerComponentsResult eRemoteScannerComponentsResult = new ERemoteScannerComponentsResult(requestScanner.getRemoteRequest().execute());
        eRemoteScannerComponentsResult.setRemoteRequestBuilder(requestScanner);
        return eRemoteScannerComponentsResult;
    }

    public ERemoteScannerStatusResult getStatus(ERemoteOperation.IRemoteStatusParameter iRemoteStatusParameter) {
        ERemoteOperation.ERemoteRequestBuilder requestScanner = ERemoteOperation.ERemoteRequestBuilder.requestScanner(this.hostIP, ERemoteOperation.RequestParam.get_status, getRequestConnectionTimeout());
        requestScanner.add(ERemoteOperation.ERemoteParam.keys, iRemoteStatusParameter.keys());
        ERemoteScannerStatusResult eRemoteScannerStatusResult = new ERemoteScannerStatusResult(requestScanner.getRemoteRequest().execute());
        eRemoteScannerStatusResult.setRemoteRequestBuilder(requestScanner);
        return eRemoteScannerStatusResult;
    }

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