sendpulse.init receives correct API_USER_ID and API_SECRET every time but returns wrong data
exports.smsBalance = functions.https.onCall(async (data, context) => {
const { companyId } = data
const { API_USER_ID, API_SECRET } = await admin.database().ref('SendPulse/' + companyId)
.once('value')
.then(s => s.val())
const TOKEN_STORAGE = tempy.directory()
const sendpulse = require("sendpulse-api")
console.log(companyId, API_USER_ID, TOKEN_STORAGE)
return new Promise(resolve =>
sendpulse.init(API_USER_ID,API_SECRET,TOKEN_STORAGE, () =>
sendpulse.getBalance(
(data) => {
resolve(data.balance_currency)
},
'UAH'
)
)
)
})
.then(() => {
rimraf(TOKEN_STORAGE, () => console.log('cleaned up'))
})
I have no idea how to fix this. help appreciated.
Use case:
I've tried everything:
sendpulse.init receives correct API_USER_ID and API_SECRET every time but returns wrong data
I have no idea how to fix this. help appreciated.