//
//  MyPlugin.swift
//  App
//
//  Created by Akhmad Al Qindi Irsyam on 27/06/23.
//

import Foundation
import Capacitor
import NexilisLite

@objc(NativeCap)
public class NativeCap: CAPPlugin {
    @objc func openContactCenter(_ call: CAPPluginCall) {
        DispatchQueue.main.async {
            APIS.openContactCenter()
        }
    }
    @objc func openChat(_ call: CAPPluginCall) {
        DispatchQueue.main.async {
            APIS.openChat()
        }
    }
    @objc func openCall(_ call: CAPPluginCall) {
        DispatchQueue.main.async {
            APIS.openCall()
        }
    }
    @objc func openStreaming(_ call: CAPPluginCall) {
        DispatchQueue.main.async {
            APIS.openStreaming()
        }
    }
    @objc func openSetOfficer(_ call: CAPPluginCall) {
        DispatchQueue.main.async {
            APIS.openSetAsOfficerForm()
        }
    }
    @objc func openSettings(_ call: CAPPluginCall) {
        DispatchQueue.main.async {
            APIS.openSetting()
        }
    }
    @objc func openProfile(_ call: CAPPluginCall) {
        DispatchQueue.main.async {
            APIS.openProfile()
        }
    }
    @objc func openContactCenterChat(_ call: CAPPluginCall) {
        let media = 0
        let category = call.options["category"]
        print("HEHE \(category)")
        DispatchQueue.main.async {
            APIS.openContactCenter(media: media, category: category as? Int)
        }
    }
    @objc func openContactCenterAudioCall(_ call: CAPPluginCall) {
        let media = 1
        let category = call.options["category"]
        DispatchQueue.main.async {
            APIS.openContactCenter(media: media, category: category as? Int)
        }
    }
    @objc func openContactCenterVideoCall(_ call: CAPPluginCall) {
        let media = 2
        let category = call.options["category"]
        DispatchQueue.main.async {
            APIS.openContactCenter(media: media, category: category as? Int)
        }
    }
    @objc func adminSignIn(_ call: CAPPluginCall) {
        let password = call.options["pwd"] ?? ""
        DispatchQueue.main.async {
            APIS.signInAdmin(password: password as! String)
        }
    }
    @objc func openScreenSharing(_ call: CAPPluginCall) {
        DispatchQueue.main.async {
            APIS.openScreenSharing()
        }
    }
    @objc func openWhiteboard(_ call: CAPPluginCall) {
        DispatchQueue.main.async {
            APIS.openWhiteboard()
        }
    }
}
