add money to wallet if correct

This commit is contained in:
morteza-mortezai
2025-11-16 09:05:23 +03:30
parent b80a5d5e53
commit 1a98067f1a
3 changed files with 97 additions and 21 deletions
+32
View File
@@ -0,0 +1,32 @@
const axios = require('axios')
const { kojaBaseUrl, kojaAccount } = require('./_env')
export async function isDeviceRegisteredOnKoja(imei) {
try {
const result = await axios.get(`/devices/imei/${imei}`, {
baseURL: kojaBaseUrl,
auth: kojaAccount
})
console.log('device registration check result from koja.ir', result)
if (result.status === 200) {
return true
}
return result
} catch (error) {
if (error.response) {
const { status } = error.response
if (status === 401) {
throw new Error('خطا در اتصال به سامانه ردیاب')
}
if (status === 404) {
return false
}
if (status === 403) {
return true
}
throw error
} else {
throw error
}
}
}