package com.nexilissamplecode;

import androidx.annotation.NonNull;

import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;

import io.nexilis.service.API;

public class CallNative extends ReactContextBaseJavaModule {

    CallNative(ReactApplicationContext context) {
        super(context);
    }

    @NonNull
    @Override
    public String getName() {
        return "CallNative";
    }

    @ReactMethod
    public void openContactCenter(Promise promise) {
        String response = API.openContactCenter();
        promise.resolve(response);
    }

    @ReactMethod
    public void openChat(Promise promise) {
        String response = API.openChat();
        promise.resolve(response);
    }

    @ReactMethod
    public void openCall(Promise promise) {
        String response = API.openCall();
        promise.resolve(response);
    }

    @ReactMethod
    public void openStreaming(Promise promise) {
        String response = API.openLiveStreaming();
        promise.resolve(response);
    }

    @ReactMethod
    public void openSetting() {
        API.openSettings();
    }

    @ReactMethod
    public void openWhiteboard(Promise promise) {
        String response = API.openWhiteboard();
        promise.resolve(response);
    }

    @ReactMethod
    public void openChatGPT(Promise promise) {
        String response = API.openSmartChatbot();
        promise.resolve(response);
    }

    @ReactMethod
    public void openContactCenterChat(int category, Promise promise) {
        String response = API.openContactCenter(0, category);
        promise.resolve(response);
    }

    @ReactMethod
    public void openContactCenterAudioCall(int category, Promise promise) {
        String response = API.openContactCenter(1, category);
        promise.resolve(response);
    }

    @ReactMethod
    public void openContactCenterVideoCall(int category, Promise promise) {
        String response = API.openContactCenter(2, category);
        promise.resolve(response);
    }

    @ReactMethod
    public void signInAdmin(String pwd, Promise promise) {
        if(pwd.trim().isEmpty()) {
            promise.reject("signInAdmin error", "pwd is null");
            return;
        }
        String response = API.signInAdmin(pwd);
        promise.resolve(response);
    }

    @ReactMethod
    public void openSetOfficer(Promise promise) {
        String response = API.openSetAsOfficerForm();
        promise.resolve(response);
    }

}
