67 lines
2.0 KiB
JavaScript
67 lines
2.0 KiB
JavaScript
|
|
"use strict";
|
||
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
|
exports.isSimSubscription = isSimSubscription;
|
||
|
|
exports.extractSimAccountFromSubscription = extractSimAccountFromSubscription;
|
||
|
|
exports.cleanSimAccount = cleanSimAccount;
|
||
|
|
function isSimSubscription(subscription) {
|
||
|
|
const productName = subscription.productName?.toLowerCase() || "";
|
||
|
|
const groupName = subscription.groupName?.toLowerCase() || "";
|
||
|
|
return productName.includes("sim") || groupName.includes("sim");
|
||
|
|
}
|
||
|
|
function extractSimAccountFromSubscription(subscription) {
|
||
|
|
if (subscription.domain && subscription.domain.trim()) {
|
||
|
|
return subscription.domain.trim();
|
||
|
|
}
|
||
|
|
if (subscription.customFields) {
|
||
|
|
const account = extractFromCustomFields(subscription.customFields);
|
||
|
|
if (account)
|
||
|
|
return account;
|
||
|
|
}
|
||
|
|
if (subscription.orderNumber) {
|
||
|
|
const orderNum = subscription.orderNumber.toString();
|
||
|
|
if (/^\d{10,11}$/.test(orderNum)) {
|
||
|
|
return orderNum;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
function extractFromCustomFields(customFields) {
|
||
|
|
const phoneFields = [
|
||
|
|
"phone",
|
||
|
|
"msisdn",
|
||
|
|
"phonenumber",
|
||
|
|
"phone_number",
|
||
|
|
"mobile",
|
||
|
|
"sim_phone",
|
||
|
|
"Phone Number",
|
||
|
|
"MSISDN",
|
||
|
|
"Phone",
|
||
|
|
"Mobile",
|
||
|
|
"SIM Phone",
|
||
|
|
"PhoneNumber",
|
||
|
|
"mobile_number",
|
||
|
|
"sim_number",
|
||
|
|
"account_number",
|
||
|
|
"Account Number",
|
||
|
|
"SIM Account",
|
||
|
|
"Phone Number (SIM)",
|
||
|
|
"Mobile Number",
|
||
|
|
"SIM Number",
|
||
|
|
"SIM_Number",
|
||
|
|
"SIM_Phone_Number",
|
||
|
|
"Phone_Number_SIM",
|
||
|
|
"Mobile_SIM_Number",
|
||
|
|
"SIM_Account_Number",
|
||
|
|
];
|
||
|
|
for (const fieldName of phoneFields) {
|
||
|
|
const value = customFields[fieldName];
|
||
|
|
if (value !== undefined && value !== null && value !== "") {
|
||
|
|
return String(value);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
function cleanSimAccount(account) {
|
||
|
|
return account.replace(/[-\s()]/g, "");
|
||
|
|
}
|
||
|
|
//# sourceMappingURL=validation.js.map
|