add money to wallet if correct
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user