added gk lib for appenablement

This commit is contained in:
2026-04-02 08:29:44 +02:00
parent 586ac4c5c2
commit e8bec486c5
8 changed files with 1938 additions and 6 deletions
+242
View File
@@ -0,0 +1,242 @@
var oAppEnablementConnectorInstance;
// Shorthand syntax to check if the namespace already exists, if not create an empty Object.
var comGkSoftwareGkrAppEnablement = comGkSoftwareGkrAppEnablement || {};
/**
* @class
* @classdesc App Enablement Connector class for all general functionalities that should not
* be accessible via the API. These are only private helper functions.
* @author mluzius
* @since 2.0.0
* @private
* @name com.gk_software.gkr.app_enablement.ConnectorPrivateClass
*/
comGkSoftwareGkrAppEnablement.ConnectorPrivateClass = ( function () {
"use strict";
/**
* @summary This function provides the value for a given URL parameter key.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.ConnectorPrivateClass._fnGetParameter
* @param {string} sParameterName
* Name of the URL parameter for which you want to get the value.
* @private
* @function
* @returns (string) Returns the value for the requested URL parameter key.
*/
var _fnGetParameter = function(sParameterName) {
var sResult = "",
aTmp = null,
aItems = window.location.search.substr(1).split("&"),
index = 0,
iItemsLength = (aItems) ? aItems.length : 0;
for (index; index < iItemsLength; index++) {
aTmp = aItems[index].split("=");
if (aTmp[0] === sParameterName) {
sResult = decodeURIComponent(aTmp[1]);
}
}
return sResult;
};
var _sAppToken = _fnGetParameter("appToken");
var _sPosToken = _fnGetParameter("posToken");
var _sPosOrigin = _fnGetParameter("posOrigin");
/**
* @summary This function validates the origins and tokens of the host and the app.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.ConnectorPrivateClass._fnValidateOrigin
* @param {Object} oEvent
* Object of the receiveMessage event with for example origin, token and event name.
* @private
* @function
* @returns (boolean) Returns true or false if the domain origins and tokens of host and app match.
*/
var _fnValidateOrigin = function(oEvent) {
return (oEvent.origin === _sPosOrigin && oEvent.token === _sPosToken);
};
/**
* @summary A function to process messages received by the global window via postMessage.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.ConnectorPrivateClass._fnReceiveMessage
* @param {Object} oEvent
* Object of the receiveMessage event with for example origin, token and event name.
* @private
* @function
*/
var _fnReceiveMessage = function (oEvent) {
// Do we trust the sender of this message?
if (_fnValidateOrigin(oEvent)) {
return;
}
if (oEvent && typeof oEvent !== "undefined"
&& oEvent.data && typeof oEvent.data !== "undefined"
&& oEvent.data.fnCall && typeof oEvent.data.fnCall !== "undefined"
&& oEvent.data.fnData && typeof oEvent.data.fnData !== "undefined") {
var fn = window[oEvent.data.fnCall](oEvent.data.fnData);
if (typeof fn === 'function') {
fn();
}
}
};
// Setup an event listener that calls _fnReceiveMessage() when the window
// receives a new MessageEvent.
window.addEventListener('message', _fnReceiveMessage);
window._fnHandshakeWithConnectorSuccess = function (result) {
oAppEnablementConnectorInstance._connector = result;
};
/**
* @summary This function will do a handshake between host and client app to make sure that everything was
* initialized and to identify the host type (Java or JavaScript). This function will be
* executed automatically if the class is accessed.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.ConnectorPrivateClass._fnDoHandshake
* @private
* @function
*/
var _fnDoHandshake = function() {
if (_sPosOrigin && typeof _sPosOrigin !== "undefined" && _sPosOrigin !== null) {
var oMessage = {};
oMessage.origin = window.location.protocol + "//" + window.location.hostname + ":" + window.location.port;
oMessage.token = _sAppToken;
oMessage.version = "mobilePOS_5.5.1";
oMessage.onResult = "_fnHandshakeWithConnectorSuccess";
oMessage.onError = "";
oMessage.fnCall = "handshake";
oMessage.fnData = "app";
window.parent.postMessage(oMessage, _sPosOrigin);
}
};
_fnDoHandshake();
return {
/**
* @summary This function will provide the string for the app token. This value is read-only for users
* of the API.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.ConnectorPrivateClass.getAppToken
* @function
*/
getAppToken: function () {
return _sAppToken;
},
/**
* @summary This function will provide the string for the host domain origin. This value is read-only for users
* of the API.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.ConnectorPrivateClass.getPosOrigin
* @function
*/
getPosOrigin: function () {
return _sPosOrigin;
}
};
})();
/**
* @class
* @classdesc App Enablement Connector class for all general functionalities related to API itself like using
* postMessage to enable communication between host and app.
* @author mluzius
* @since 2.0.0
* @public
* @name com.gk_software.gkr.app_enablement.Connector
*/
comGkSoftwareGkrAppEnablement.Connector = function () {
"use strict";
// Empty is default. In that case the omniPOS is used instead of mobilePOS.
this._connector = "";
};
/**
* @summary This function will trigger events for the App Enablement API to exchange data between host and client
* app and also decides whether to use the JavaScript (postMessage) or Java (via own protocol for JX browser) logic.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.Connector.invokeMethod
* @param {string} sCall
* Event name that should be called.
* @param {string} sResultFunction
* Name of the success callback function. Data type is string but internal data type is function.
* @param {string} sErrorFunction
* Name of the error callback function. Data type is string but internal data type is function.
* @param {string} sData
* Stringified Object that is passed to the event.
* @function
*/
comGkSoftwareGkrAppEnablement.Connector.prototype.invokeMethod = function (sCall, sResultFunction, sErrorFunction, sData) {
if (this._connector === "mobilePOS") {
// The following lines are used by JavaScript hosts like mobilePOS.
var oMessage = {};
oMessage.origin = window.location.protocol + "//" + window.location.hostname + ":" + window.location.port;
oMessage.token = comGkSoftwareGkrAppEnablement.ConnectorPrivateClass.getAppToken();
oMessage.version = "mobilePOS_5.5.1";
oMessage.onResult = sResultFunction;
oMessage.onError = sErrorFunction;
oMessage.fnCall = sCall;
oMessage.fnData = sData;
window.parent.postMessage(oMessage, comGkSoftwareGkrAppEnablement.ConnectorPrivateClass.getPosOrigin());
} else if (typeof injected_by_POS__postWebAppRequest !== "undefined" && typeof injected_by_POS__postWebAppRequest.invoke !== "undefined") {
// The following lines are used by the Java POS to send and execute specific events of App Enablement via an own
// protocol to the JX browser.
var request = "jmc://" + sCall;
var sep = "?";
if (sResultFunction && typeof sResultFunction !== "undefined") {
request += sep + "onResult=" + sResultFunction;
sep = "&";
}
if (sErrorFunction && typeof sErrorFunction !== "undefined") {
request += sep + "onError=" + sErrorFunction;
}
if (sData && typeof sData !== "undefined") {
request += sep + "0=" + encodeURIComponent(sData);
}
injected_by_POS__postWebAppRequest.invoke(request);
}
};
oAppEnablementConnectorInstance = new comGkSoftwareGkrAppEnablement.Connector();
+178
View File
@@ -0,0 +1,178 @@
// Shorthand syntax to check if the namespace already exists, if not create an empty Object.
var comGkSoftwareGkrAppEnablementApi = comGkSoftwareGkrAppEnablementApi || {};
/*global oAppEnablementConnectorInstance*/
/**
* @class
* @classdesc App Enablement class for all common used functionalities like registering and unregistering to events
* and to get the session context.
* @author mluzius
* @since 2.0.0
* @public
* @name com.gk_software.gkr.app_enablement.api.Common
*/
comGkSoftwareGkrAppEnablementApi.Common = function () {
"use strict";
this._prefix = "comGkSoftwareGkrAppEnablementApi.Common/";
};
/**
* The internally returned object looks like the following example:
* {
* businessUnitGroupID: "100000000000000001",
* businessUnitID: "9090", // Equivalent to store ID
* isoCurrencyCode: "USD",
* storeLanguage: "en_US",
* tenantID: "004",
* userLanguage: "zh_CN",
* workstationID: "107"
* }
* @summary This function will provide the session context. For example currency, language.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.api.Common.getSessionContext
* @param {string} sResultFunction
* Name of the success callback function. Data type is string but internal data type is function.
* @param {string} sErrorFunction
* Name of the error callback function. Data type is string but internal data type is function.
* @function
*/
comGkSoftwareGkrAppEnablementApi.Common.prototype.getSessionContext = function (sResultFunction, sErrorFunction) {
oAppEnablementConnectorInstance.invokeMethod(this._prefix + "getSessionContext", sResultFunction, sErrorFunction);
};
/**
* @summary This function will create a request object for the function 'registerListener'.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.api.Common.createRegisterListenerRequest
* @param {string} sEventName
* Name of the event that should be registered. For example: 'EVENT_TRANSACTION_UPDATED'.
* @param {string} sEventListenerName
* Name of the event listener function that should be executed when the event is fired.
* @param {boolean} bPassData
* Flag to indicate if the event listener function receives a data parameter. For example needed for
* Scan events to provide the barcodeFormat and the rawScanData.
* @function
* @returns (String) Returns a stringified Object for the registerListener request.
*/
comGkSoftwareGkrAppEnablementApi.Common.prototype.createRegisterListenerRequest = function (sEventName, sEventListenerName, bPassData) {
return JSON.stringify({
"event": sEventName,
"listener": sEventListenerName,
"passData": bPassData
});
};
/**
* @summary This function will register a listener for the given event.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.api.Common.registerListener
* @param {string} oRegisterListenerRequest
* Necessary request object to register event listeners. Data type is string but internal
* data type is Object.
* The internally used object should look like the following example:
* {
* "event": "EVENT_TRANSACTION_UPDATED",
"listener": "returnEventNotification",
"passData": false || true
* }
* @function
*/
comGkSoftwareGkrAppEnablementApi.Common.prototype.registerListener = function (sRegisterListenerRequest) {
oAppEnablementConnectorInstance.invokeMethod(this._prefix + "registerListener", "", "", sRegisterListenerRequest);
};
/**
* @summary This function will create a request object for the function 'unregisterListener'.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.api.Common.createUnregisterListenerRequest
* @param {string} sEventName
* Name of the event that should be unregistered. For example: 'EVENT_TRANSACTION_UPDATED'.
* @param {string} sEventListenerName
* Name of the event listener function that should be unregistered.
* @function
* @returns (String) Returns a stringified Object for the unregisterListener request.
*/
comGkSoftwareGkrAppEnablementApi.Common.prototype.createUnregisterListenerRequest = function (sEventName, sEventListenerName) {
return JSON.stringify({
"event": sEventName,
"listener": sEventListenerName
});
};
/**
* @summary This function will unregister a listener for the given event.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.api.Common.unregisterListener
* @param {string} sUnregisterListenerRequest
* Name of the event that should be unregistered so that it can't be fired any longer.
* Data type is string but internal data type is Object.
* @function
*/
comGkSoftwareGkrAppEnablementApi.Common.prototype.unregisterListener = function (sUnregisterListenerRequest) {
oAppEnablementConnectorInstance.invokeMethod(this._prefix + "unregisterListener", "", "", sUnregisterListenerRequest);
};
/**
* @summary This function will close the app
*
* @author nmankel (Last modified by: nmankel)
* @since 2.1.0
* @name com.gk_software.gkr.app_enablement.api.Common.closeBrowser
* @function
*/
comGkSoftwareGkrAppEnablementApi.Common.prototype.closeBrowser = function () {
oAppEnablementConnectorInstance.invokeMethod(this._prefix + "closeBrowser", "", "");
};
/**
* @summary This function will hide the app
*
* @author nmankel (Last modified by: nmankel)
* @since 2.1.0
* @name com.gk_software.gkr.app_enablement.api.Common.hideBrowser
* @function
*/
comGkSoftwareGkrAppEnablementApi.Common.prototype.hideBrowser = function () {
oAppEnablementConnectorInstance.invokeMethod(this._prefix + "hideBrowser", "", "");
};
/**
* The internally returned object looks like the following example:
* {
* operatorID: "1",
* workerID: "1",
* salutation: "Herr",
* firstName: "Max",
* lastName: "Mustermann",
* rightsSet: ["S.00000000001.00","S.00000000001.01"],
* }
* @summary This function will provide operator data. For example operatorID, name, rights.
*
* @author nmankel (Last modified by: nmankel)
* @since 2.1.0
* @name com.gk_software.gkr.app_enablement.api.Common.getOperatorData
* @param {string} sResultFunction
* Name of the success callback function. Data type is string but internal data type is function.
* @param {string} sErrorFunction
* Name of the error callback function. Data type is string but internal data type is function.
* @function
*/
comGkSoftwareGkrAppEnablementApi.Common.prototype.getOperatorData = function (sResultFunction, sErrorFunction) {
oAppEnablementConnectorInstance.invokeMethod(this._prefix + "getOperatorData", sResultFunction, sErrorFunction);
};
+200
View File
@@ -0,0 +1,200 @@
/*global oAppEnablementConnectorInstance*/
// Shorthand syntax to check if the namespace already exists, if not create an empty Object.
var comGkSoftwareGkrAppEnablementApi = comGkSoftwareGkrAppEnablementApi || {};
/**
* @class
* @classdesc App Enablement class for all functionalities related to external masterdata like searching,
* registering external items and to grab the image url from external webshops.
* @author mluzius
* @since 2.0.0
* @public
* @name com.gk_software.gkr.app_enablement.api.ExternalMasterdata
*/
comGkSoftwareGkrAppEnablementApi.ExternalMasterdata = function () {
"use strict";
this._prefix = "comGkSoftwareGkrAppEnablementApi.ExternalMasterdata/";
};
/**
* @summary This function will create a request object for the function 'getItemByCriteria'.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.api.ExternalMasterdata.createGetItemByCriteriaRequest
* @param {string} sItemID
* Item ID to get the item information for external items.
* @param {string} oContext
* Provides the session context. For example currency, language. Data type is string but internal
* data type is Object.
* The internally used object should look like the following example:
* {
* businessUnitGroupID: "100000000000000001",
* businessUnitID: "9090", // Equivalent to store ID
* isoCurrencyCode: "USD",
* storeLanguage: "en_US",
* tenantID: "004",
* userLanguage: "zh_CN",
* workstationID: "107"
* }
* @function
* @returns (String) Returns a stringified Object for the getItemByCriteria request.
*/
comGkSoftwareGkrAppEnablementApi.ExternalMasterdata.prototype.createGetItemByCriteriaRequest = function (sItemID, oContext) {
return JSON.stringify({
"itemID": sItemID,
"language": (oContext && oContext.userLanguage) ? oContext.userLanguage : null,
"isoCurrencyCode": (oContext && oContext.isoCurrencyCode) ? oContext.isoCurrencyCode : null
});
};
/**
* @summary This function will provide external item information for a given item ID.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.api.ExternalMasterdata.getItemByCriteria
* @param {string} sResultFunction
* Name of the success callback function. Data type is string but internal data type is function.
* @param {string} sErrorFunction
* Name of the error callback function. Data type is string but internal data type is function.
* @param {string} oGetItemByCriteriaRequest
* Stringified Object from the createGetItemByCriteriaRequest.
* Data type is string but internal
* data type is Object.
* The internally used object should look like the following example:
* {
* itemID: "030039",
* language: "en_US",
* isoCurrencyCode: "USD"
* }
* @function
*/
comGkSoftwareGkrAppEnablementApi.ExternalMasterdata.prototype.getItemByCriteria = function (sResultFunction, sErrorFunction, oGetItemByCriteriaRequest) {
oAppEnablementConnectorInstance.invokeMethod(this._prefix + "getItemByCriteria", sResultFunction, sErrorFunction, oGetItemByCriteriaRequest);
};
/**
* @summary This function will create a request object for the function 'getItemListBySearchCriteria'.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.api.ExternalMasterdata.createGetItemByCriteriaRequest
* @param {string} sSearchQuery
* The string that is used to search external items.
* @param {number} iRecordCount
* Determines the maximum count of items that should be displayed per page.
* @param {string} oContext
* Provides the session context. For example currency, language. Data type is string but internal
* data type is Object.
* The internally used object should look like the following example:
* {
* businessUnitGroupID: "100000000000000001",
* businessUnitID: "9090", // Equivalent to store ID
* isoCurrencyCode: "USD",
* storeLanguage: "en_US",
* tenantID: "004",
* userLanguage: "zh_CN",
* workstationID: "107"
* }
* @function
* @returns (String) Returns a stringified Object for the getItemListBySearchCriteria request.
*/
comGkSoftwareGkrAppEnablementApi.ExternalMasterdata.prototype.createGetItemListBySearchCriteriaRequest = function (sSearchQuery, iRecordCount, oContext) {
return JSON.stringify({
"query": (sSearchQuery && sSearchQuery !== "") ? sSearchQuery : "",
"language": (oContext && oContext.userLanguage) ? oContext.userLanguage : null,
"isoCurrencyCode": (oContext && oContext.isoCurrencyCode) ? oContext.isoCurrencyCode : null,
"recordCount": iRecordCount
});
};
/**
* @summary This function will provide a list of external items that you searched for.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.api.ExternalMasterdata.getItemListBySearchCriteria
* @param {string} sResultFunction
* Name of the success callback function. Data type is string but internal data type is function.
* @param {string} sErrorFunction
* Name of the error callback function. Data type is string but internal data type is function.
* @param {string} oGetItemListBySearchCriteriaRequest
* Stringified Object from the createGetItemListBySearchCriteriaRequest.
* Data type is string but internal data type is Object.
* The internally used object should look like the following example:
* {
* query: "camera",
* language: "en_US",
* isoCurrencyCode: "USD",
* recordCount: 60
* }
* @function
*/
comGkSoftwareGkrAppEnablementApi.ExternalMasterdata.prototype.getItemListBySearchCriteria = function (sResultFunction, sErrorFunction, oGetItemListBySearchCriteriaRequest) {
oAppEnablementConnectorInstance.invokeMethod(this._prefix + "getItemListBySearchCriteria", sResultFunction, sErrorFunction, oGetItemListBySearchCriteriaRequest);
};
/**
* @summary This function will create a request object for the function 'getImageUrl'.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.api.ExternalMasterdata.createGetExternalImageUrlRequest
* @param {string} sItemID
* The string that is used to search external items.
* @param {string} oContext
* Provides the session context. For example currency, language. Data type is string but internal
* data type is Object.
* The internally used object should look like the following example:
* {
* businessUnitGroupID: "100000000000000001",
* businessUnitID: "9090", // Equivalent to store ID
* isoCurrencyCode: "USD",
* storeLanguage: "en_US",
* tenantID: "004",
* userLanguage: "zh_CN",
* workstationID: "107"
* }
* @function
* @returns (String) Returns a stringified Object for the getImageUrl request.
*/
comGkSoftwareGkrAppEnablementApi.ExternalMasterdata.prototype.createGetExternalImageUrlRequest = function (sItemID, oContext) {
return JSON.stringify({
"itemID": sItemID,
"type": "item",
"language": (oContext && oContext.userLanguage) ? oContext.userLanguage : null,
"isoCurrencyCode": (oContext && oContext.isoCurrencyCode) ? oContext.isoCurrencyCode : null
});
};
/**
* @summary This function will provide an image URL for external items.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.api.ExternalMasterdata.getImageUrl
* @param {string} sResultFunction
* Name of the success callback function. Data type is string but internal data type is function.
* @param {string} sErrorFunction
* Name of the error callback function. Data type is string but internal data type is function.
* @param {string} oGetExternalImageUrlRequest
* Stringified Object from the createGetExternalImageUrlRequest.
* Data type is string but internal data type is Object.
* The internally used object should look like the following example:
* {
* itemID: "030039",
* type: "item",
* language: "en_US",
* isoCurrencyCode: "USD"
* }
* @function
*/
comGkSoftwareGkrAppEnablementApi.ExternalMasterdata.prototype.getImageUrl = function (sResultFunction, sErrorFunction, oGetExternalImageUrlRequest) {
oAppEnablementConnectorInstance.invokeMethod(this._prefix + "getImageUrl", sResultFunction, sErrorFunction, oGetExternalImageUrlRequest);
};
+145
View File
@@ -0,0 +1,145 @@
/*global oAppEnablementConnectorInstance*/
// Shorthand syntax to check if the namespace already exists, if not create an empty Object.
var comGkSoftwareGkrAppEnablementApi = comGkSoftwareGkrAppEnablementApi || {};
/**
* @class
* @classdesc App Enablement class for all functionalities related to GK masterdata like getting single item
* information, get item list by id list and to grab the image url from Digital Signage Server.
* @author mluzius
* @since 2.0.0
* @public
* @name com.gk_software.gkr.app_enablement.api.Masterdata
*/
comGkSoftwareGkrAppEnablementApi.Masterdata = function () {
"use strict";
this._prefix = "comGkSoftwareGkrAppEnablementApi.Masterdata/";
};
/**
* @summary This function will create a request object for the function 'getItemDataByID'.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.api.Masterdata.createGetItemDataByIDRequest
* @param {string} sItemID
* Item ID to get the item information for GK masterdata items.
* @function
* @returns (String) Returns a stringified Object for the getItemDataByID request.
*/
comGkSoftwareGkrAppEnablementApi.Masterdata.prototype.createGetItemDataByIDRequest = function (sItemID) {
return JSON.stringify({
"itemID": sItemID
});
};
/**
* @summary This function will provide GK masterdata item information for a given item ID.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.api.Masterdata.getItemDataByID
* @param {string} sResultFunction
* Name of the success callback function. Data type is string but internal data type is function.
* @param {string} sErrorFunction
* Name of the error callback function. Data type is string but internal data type is function.
* @param {string} oGetItemDataByIDRequest
* Stringified Object from the createGetItemDataByIDRequest.
* Data type is string but internal
* data type is Object.
* The internally used object should look like the following example:
* {
* itemID: "030039"
* }
* @function
*/
comGkSoftwareGkrAppEnablementApi.Masterdata.prototype.getItemDataByID = function (sResultFunction, sErrorFunction, oGetItemDataByIDRequest) {
oAppEnablementConnectorInstance.invokeMethod(this._prefix + "getItemDataByID", sResultFunction, sErrorFunction, oGetItemDataByIDRequest);
};
/**
* @summary This function will create a request object for the function 'getItemDataListByIDList'.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.api.Masterdata.createGetItemDataListByIDListRequest
* @param {Array} aItemIDList
* Array of item IDs to get the item information for GK masterdata items.
* @function
* @returns (String) Returns a stringified Object for the getItemDataListByIDList request.
*/
comGkSoftwareGkrAppEnablementApi.Masterdata.prototype.createGetItemDataListByIDListRequest = function (aItemIDList) {
return JSON.stringify({
"itemIDList": aItemIDList
});
};
/**
* @summary This function will provide an array of GK masterdata items with their information for a given item ID list.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.api.Masterdata.getItemDataListByIDList
* @param {string} sResultFunction
* Name of the success callback function. Data type is string but internal data type is function.
* @param {string} sErrorFunction
* Name of the error callback function. Data type is string but internal data type is function.
* @param {string} oGetItemDataListByIDListRequest
* Stringified Object from the createGetItemDataListByIDListRequest.
* Data type is string but internal data type is Object.
* The internally used object should look like the following example:
* {
* itemIDList: ["03039", "65005", "65007"]
* }
* @function
*/
comGkSoftwareGkrAppEnablementApi.Masterdata.prototype.getItemDataListByIDList = function (sResultFunction, sErrorFunction, oGetItemDataListByIDListRequest) {
oAppEnablementConnectorInstance.invokeMethod(this._prefix + "getItemDataListByIDList", sResultFunction, sErrorFunction, oGetItemDataListByIDListRequest);
};
/**
* @summary This function will create a request object for the function 'getImageUrl'.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.api.Masterdata.createGetImageUrlRequest
* @param {string} sItemID
* Item ID to get the item image url for a GK masterdata item.
* @function
* @returns (String) Returns a stringified Object for the getImageUrl request.
*/
comGkSoftwareGkrAppEnablementApi.Masterdata.prototype.createGetImageUrlRequest = function (sItemID) {
return JSON.stringify({
"itemID": sItemID,
"type": "item"
});
};
/**
* @summary This function will provide an image url via an item ID and the Digital Signage Server.
*
* @author mluzius (Last modified by: mluzius)
* @since 2.0.0
* @name com.gk_software.gkr.app_enablement.api.Masterdata.getImageUrl
* @param {string} sResultFunction
* Name of the success callback function. Data type is string but internal data type is function.
* @param {string} sErrorFunction
* Name of the error callback function. Data type is string but internal data type is function.
* @param {string} oCreateGetImageUrlRequest
* Stringified Object from the createGetImageUrlRequest.
* Data type is string but internal data type is Object.
* The internally used object should look like the following example:
* {
* itemID: "03039",
* type: "item"
* }
* @function
*/
comGkSoftwareGkrAppEnablementApi.Masterdata.prototype.getImageUrl = function (sResultFunction, sErrorFunction, oCreateGetImageUrlRequest) {
oAppEnablementConnectorInstance.invokeMethod(this._prefix + "getImageUrl", sResultFunction, sErrorFunction, oCreateGetImageUrlRequest);
};
+1061
View File
File diff suppressed because it is too large Load Diff
+61
View File
@@ -0,0 +1,61 @@
// Shorthand syntax to check if the namespace already exists, if not create an empty Object.
var comGkSoftwareGkrAppEnablementApi = comGkSoftwareGkrAppEnablementApi || {};
comGkSoftwareGkrAppEnablementApi.Pos_EXT = function () {
"use strict";
this._prefix = "comGkSoftwareGkrAppEnablementApi.Pos_EXT/";
};
/**
* @summary This function sets the emailRequestedFlag, emailAddressLocalPart and emailAddressDomainPart
* of the current retailTransaction.
*
* @author jsousa
* @name com.gk_software.gkr.app_enablement.api.Pos_EXT.receiptAsEmail
* @function
*/
comGkSoftwareGkrAppEnablementApi.Pos_EXT.prototype.receiptAsEmail = function (sResultFunction, sErrorFunction, oReceiptAsEmailRequest) {
oAppEnablementConnectorInstance.invokeMethod(this._prefix + "receiptAsEmail", sResultFunction, sErrorFunction, oReceiptAsEmailRequest);
};
/**
* @summary This function will create a sub-request object for the function 'receiptAsEmail'.
*
* @author jsousa
* @name com.gk_software.gkr.app_enablement.api.Pos_EXT.createReceiptAsEmailRequest
* @param {boolean} eReceiptFlag
* @param {string} emailAddress
* @returns (String) Returns a stringified object of com.gk_software.cst.pos.ui.app_enablement.ReceiptAsEmailRequest.
*/
comGkSoftwareGkrAppEnablementApi.Pos_EXT.prototype.createReceiptAsEmailRequest = function (eReceiptFlag, emailAddress) {
return JSON.stringify({
"ereceiptFlag": eReceiptFlag,
"emailAddress": emailAddress
});
};
/**
* @summary This function will invoke function to register multiple external lineitems by one single call
*
* @author jdanisik
*
* @param {string} oRegisterExternalLineItemListRequest
*/
comGkSoftwareGkrAppEnablementApi.Pos_EXT.prototype.registerExternalLineItemList = function (sResultFunction, sErrorFunction, oRegisterExternalLineItemListRequest) {
oAppEnablementConnectorInstance.invokeMethod(this._prefix + "registerExternalLineItemList", sResultFunction, sErrorFunction, oRegisterExternalLineItemListRequest);
};
/**
* @summary This function creates a transaction discount for Tommy 4 life
*
* @author mkuda
*
* @param {string} oTradeInRequest
*/
comGkSoftwareGkrAppEnablementApi.Pos_EXT.prototype.createTradeVoucherRequest = function (sResultFunction, sErrorFunction, oTradeInRequest) {
oAppEnablementConnectorInstance.invokeMethod(this._prefix + "createTradeVoucherRequest", sResultFunction, sErrorFunction, oTradeInRequest);
};
+42
View File
@@ -1,3 +1,7 @@
var oAppEnablementCommonInstance = new comGkSoftwareGkrAppEnablementApi.Common();
var oAppEnablementPosInstance = new comGkSoftwareGkrAppEnablementApi.Pos();
var oAppEnablementPosEXTInstance = new comGkSoftwareGkrAppEnablementApi.Pos_EXT();
async function searchCompany() {
const country = document.getElementById("country").value;
const vatNumber = document.getElementById("vat_number").value.trim();
@@ -56,6 +60,14 @@ function saveData() {
};
alert(JSON.stringify(payload, null, 2));
var customer = {
"customerId":"17600703312990"
}
var oRegisterCustomerRequest = JSON.stringify(customer)
oAppEnablementPosInstance.registerCustomer('registerDataOk', 'registerDataFailed', oRegisterCustomerRequest);
}
function clearForm() {
@@ -81,5 +93,35 @@ function updateVatPlaceholder() {
}
}
function closeBrowser() {
oAppEnablementCommonInstance.closeBrowser();
}
// customer registration - uses standard Pos
function registerLoyaltyCall(customerId) {
var request = JSON.stringify({
"customerId": customerId,
"customerServiceTypeCode": null,
"preferredReceiptPrintoutTypeCode": null
});
oAppEnablementPosInstance.registerCustomer(
'onSuccess',
'onError',
request
);
}
// Callback functions
function onSuccess(result) {
document.getElementById("status").textContent = "Thank you.";
closeBrowser();
}
function onError(error) {
document.getElementById("status").textContent = "Company registration in receipt failed. Please try again.";
}
document.getElementById("country").addEventListener("change", updateVatPlaceholder);
window.addEventListener("DOMContentLoaded", updateVatPlaceholder);