package com.iotize.plugin.cordova.zebrarfid;

import org.apache.cordova.PluginResult;

public abstract class AsyncPluginCallCallback implements AsyncMethodCallback<PluginResult, Throwable>{
    private final PluginResponse pluginResponse;

    public AsyncPluginCallCallback(PluginResponse pluginResponse) {
        this.pluginResponse = pluginResponse;
    }

    @Override
    public void onComplete(PluginResult result) throws Exception {
        this.pluginResponse.getCallbackContext().sendPluginResult(result);
    }

    @Override
    public void onError(Throwable error) throws Exception {
        this.pluginResponse.error(PluginError.fromError(error));
    }
}
