Member cards (Secutix contacts)
Use the Secutix connector to create and update Secutix contacts, then deliver a member card pass to Apple Wallet and Google Wallet.
Last updated
/**
* Applies enhanced mapping from neostore account data to a Secutix contact request.
* The standard mapping is already applied on the request object before this function is called.
*
* @param {Object} account - Data coming from neostore.
* @param {Object} request - Request sent to Secutix with default mapping already populated.
*/
function mapToSecutix(account, request){
request.ExternalContactCriterionData = [{ CriterionIdCode : 'OPT_CO', Values : [account["consents_email"] ? 'true' : 'false'] }];
}
/**
* Applies enhanced mapping from a Secutix contact response back to a neostore account.
* The standard mapping is already applied on the account object before this function is called.
*
* @param {Object} response - Response received from Secutix.
* @param {Object} account - Data sent to neostore with default mapping already populated.
*/
function mapToNeostore(response, account){
response.ContactCriteria = response.ContactCriteria || [];
account["consents_email"] = !!response.ContactCriteria.find(c => c.CriterionIdCode === 'OPT_CO' && c.Values != null && c.Values[0] === 'true');
}
export default function(context) {
context.register('extensions.secutix.contact.mapper', {
MapToSecutix : mapToSecutix,
MapToNeostore: mapToNeostore
});
}/**
* Triggered when a member card installation status changes.
*
* @param {Object} request - Secutix SaveIndividualContactRequest.
* @param {boolean} isInstalled - `true` if the card is installed, otherwise `false`.
* @param {number} device - Device on which the installation status changed (0 = Apple, 2 = Google).
* @returns {Promise<void>} No return value; modifies the request in place.
*/
async function onPassInstallationStatusChanged(request, isInstalled, device){
request.ExternalContactCriterionData = [
{
CriterionIdCode : 'W_' + (device == 0 ? "APPLE" : "GOOGLE"),
Values : [isInstalled ? 'Installé' : 'Désinstallé']
}
];
}
export default function(context) {
context.register('extensions.secutix.contact.passUpdater', {
OnPassInstallationStatusChanged: onPassInstallationStatusChanged
});
}