Assist_Design/apps/bff/scripts/check-sim-status.mjs
Temuuleenn 35619f24d1 Simplify physical SIM activation and enhance order fulfillment
- Remove PA05-18 semi-black step from physical SIM flow, use PA02-01 directly
- Add WHMCS client ID fallback from Salesforce WH_Account__c field
- Return service IDs from WHMCS AcceptOrder for proper linking
- Add phone number to WHMCS domain field and WHMCS admin URL to Salesforce
- Change SIM Inventory status from "In Use" to "Assigned"
- Fix SIM services query case sensitivity ("SIM" → "Sim")
- Add bash 3.2 compatibility to dev-watch.sh
- Add "Most Popular Services" section to landing page
- Add "Trusted By" company carousel to About page

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 15:41:32 +09:00

86 lines
2.4 KiB
JavaScript

#!/usr/bin/env node
/**
* Quick script to check SIM status in Freebit
* Usage: node scripts/check-sim-status.mjs <phone_number>
*/
const account = process.argv[2] || '02000002470010';
const FREEBIT_BASE_URL = 'https://i1-q.mvno.net/emptool/api';
const FREEBIT_OEM_ID = 'PASI';
const FREEBIT_OEM_KEY = '6Au3o7wrQNR07JxFHPmf0YfFqN9a31t5';
async function getAuthKey() {
const request = {
oemId: FREEBIT_OEM_ID,
oemKey: FREEBIT_OEM_KEY,
};
const response = await fetch(`${FREEBIT_BASE_URL}/authOem/`, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: `json=${JSON.stringify(request)}`,
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
}
const data = await response.json();
if (data.resultCode !== 100 && data.resultCode !== '100') {
throw new Error(`Auth failed: ${data.status?.message || JSON.stringify(data)}`);
}
return data.authKey;
}
async function getTrafficInfo(authKey, account) {
const request = { authKey, account };
const response = await fetch(`${FREEBIT_BASE_URL}/mvno/getTrafficInfo/`, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: `json=${JSON.stringify(request)}`,
});
return response.json();
}
async function getAccountDetails(authKey, account) {
const request = {
authKey,
version: '2',
requestDatas: [{ kind: 'MVNO', account }],
};
const response = await fetch(`${FREEBIT_BASE_URL}/master/getAcnt/`, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: `json=${JSON.stringify(request)}`,
});
return response.json();
}
async function main() {
console.log(`\n🔍 Checking SIM status for: ${account}\n`);
try {
const authKey = await getAuthKey();
console.log('✓ Authenticated with Freebit\n');
// Try getTrafficInfo first (simpler)
console.log('--- Traffic Info (/mvno/getTrafficInfo/) ---');
const trafficInfo = await getTrafficInfo(authKey, account);
console.log(JSON.stringify(trafficInfo, null, 2));
// Try getAcnt for full details
console.log('\n--- Account Details (/master/getAcnt/) ---');
const details = await getAccountDetails(authKey, account);
console.log(JSON.stringify(details, null, 2));
} catch (error) {
console.error('❌ Error:', error.message);
}
}
main();