package com.reactnativequickomsdk;

import androidx.annotation.Nullable;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.modules.core.DeviceEventManagerModule;

public class DeviceEventModule {
    private ReactApplicationContext reactContext;

    public DeviceEventModule(ReactApplicationContext reactContext) {
        this.reactContext = reactContext;
    }

    private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) {
        reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, params);
    }

    public void registerChatObserver(String params) {
        WritableMap wmParams = Arguments.createMap();
        wmParams.putString("eventProperty", params);
        sendEvent(this.reactContext, "registerChatObserver", wmParams);
    }

    public void initSDK(String params) {
        WritableMap wmParams = Arguments.createMap();
        wmParams.putString("eventProperty", params);
        sendEvent(this.reactContext, "initSDK", wmParams);
    }

    public void registerStatusState(String params) {
        WritableMap wmParams = Arguments.createMap();
        wmParams.putString("eventProperty", params);
        sendEvent(this.reactContext, "registerStatusState", wmParams);
    }
}
