insatller fee
This commit is contained in:
+10
-12
@@ -1,29 +1,27 @@
|
||||
const axios = require('axios')
|
||||
const { kojaBaseUrl, kojaAccount } = require('./_env')
|
||||
|
||||
export async function isDeviceRegisteredOnKoja(imei) {
|
||||
export async function findDeviceByImeiOnKoja(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
|
||||
|
||||
console.log('result.data from koja.ir******************', result.data.result)
|
||||
return result.data.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
|
||||
}
|
||||
// if (status === 404) {
|
||||
// return false
|
||||
// }
|
||||
// if (status === 403) {
|
||||
// return true
|
||||
// }
|
||||
throw error
|
||||
} else {
|
||||
throw error
|
||||
|
||||
Reference in New Issue
Block a user