parent
7953c7dbbd
commit
46caaba6bd
|
@ -12,6 +12,7 @@ import {
|
||||||
} from './whatsapp.constant';
|
} from './whatsapp.constant';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { Logger } from '@nestjs/common';
|
import { Logger } from '@nestjs/common';
|
||||||
|
import { apm } from 'src/core/apm';
|
||||||
|
|
||||||
export class WhatsappService {
|
export class WhatsappService {
|
||||||
async sendMessage(data) {
|
async sendMessage(data) {
|
||||||
|
@ -25,8 +26,14 @@ export class WhatsappService {
|
||||||
data: data,
|
data: data,
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await axios(config);
|
try {
|
||||||
return response.data;
|
const response = await axios(config);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
Logger.error(error);
|
||||||
|
apm?.captureError(error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async queueRegister(data: WhatsappQueue) {
|
async queueRegister(data: WhatsappQueue) {
|
||||||
|
@ -91,8 +98,11 @@ export class WhatsappService {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
await this.sendMessage(payload);
|
const response = await this.sendMessage(payload);
|
||||||
Logger.log(`Notification register for ${data.code} send to ${data.phone}`);
|
if (response)
|
||||||
|
Logger.log(
|
||||||
|
`Notification register for ${data.code} send to ${data.phone}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async queueProcess(data: WhatsappQueue) {
|
async queueProcess(data: WhatsappQueue) {
|
||||||
|
@ -152,7 +162,8 @@ export class WhatsappService {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
await this.sendMessage(payload);
|
const response = await this.sendMessage(payload);
|
||||||
Logger.log(`Notification process for ${data.code} send to ${data.phone}`);
|
if (response)
|
||||||
|
Logger.log(`Notification process for ${data.code} send to ${data.phone}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue