2024-06-10 19:00:48 +00:00
|
|
|
import Whatsapp from "../models/Whatsapp";
|
|
|
|
import createApiClientWhatsOfficial from "./WhatsappOfficialAPI";
|
2023-09-16 14:45:44 +00:00
|
|
|
|
|
|
|
async function whatsappOfficialNumberInfo(wabaId: string) {
|
|
|
|
try {
|
2024-06-10 19:00:48 +00:00
|
|
|
const { whatsappOfficialToken }: any = await Whatsapp.findOne({
|
|
|
|
where: { wabaId }
|
|
|
|
});
|
|
|
|
|
|
|
|
const whatsappOfficialAPI = createApiClientWhatsOfficial(
|
|
|
|
whatsappOfficialToken
|
|
|
|
);
|
2023-09-16 14:45:44 +00:00
|
|
|
const { data } = await whatsappOfficialAPI.get(
|
|
|
|
`/${process.env.VERSION}/${wabaId}/phone_numbers`
|
|
|
|
);
|
|
|
|
console.log("data: ", data);
|
|
|
|
|
|
|
|
if (data && Object.keys(data).length > 0) {
|
|
|
|
return data.data[0];
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
console.log(
|
|
|
|
`There was an error into whatsappOfficialNumberInfo method : ${error}`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
export default whatsappOfficialNumberInfo;
|