import LS2Request from "./LS2Request";

export const getConnectionStatus = ({ onSuccess, onFailure, onComplete }) => {
  if (process.env.REACT_APP_MODE === "DEBUG") {
    console.log("LUNA SEND getConnectionStatus");
    return "Some Hard Coded Mock Data";
  } else {
    return new LS2Request().send({
      service: "luna://com.webos.service.connectionmanager",
      method: "getStatus",
      subscribe: true,
      parameters: {},
      onSuccess,
      onFailure,
      onComplete,
    });
  }
};

export const createToast = (message) => {
	if (typeof window === 'object' && !window.PalmSystem) {
    console.log("LUNA SEND createToast message", message);
		return;
	}
	return new LS2Request().send({
		service: 'luna://com.webos.notification',
		method: 'createToast',
		parameters:  {
			message: message,
			iconUrl: '',
			noaction: true
		},
		onSuccess: (res) => {
			console.log("LUNA SEND createToast success", message);
		},
		onFailure: (err) => {
			console.log("LUNA SEND createToast failed", err);
		}
	});
};