Browse Source

Updating api to send bulk numbers messages.

master
Sandeep Kumar 3 years ago
parent
commit
fafff198cd
  1. 67
      src/app/pages/home/home.component.ts

67
src/app/pages/home/home.component.ts

@ -61,26 +61,9 @@ export class HomeComponent {
this.isSalesForm = !this.isSalesForm;
}
triggerWhatsappMessages(phoneNumber: string[]) {
triggerWhatsappMessages(messages: object[]) {
const httpBody = {
messages: [
{
from: '447491163530',
// TODO: need check if we can send array here
to: phoneNumber[1],
messageId: 'a28dd97c-1ffb-4fcf-99f1-0b557ed381da',
content: {
templateName: 'infobip_kz_test_hsm_2',
templateData: {
body: {
placeholders: ['BFL Credit Card'],
},
},
language: 'en_GB',
},
callbackData: 'Callback data',
},
],
messages
};
this.homeService.sendWhatsApp(httpBody).subscribe(
@ -104,7 +87,7 @@ export class HomeComponent {
this.arrayBuffer = fileReader.result;
let data = new Uint8Array(this.arrayBuffer);
let arr = new Array();
let phoneNumber: string[] = [];
let phoneNumber: object[] = [];
for (let i = 0; i != data.length; ++i) {
arr[i] = String.fromCharCode(data[i]);
@ -119,25 +102,41 @@ export class HomeComponent {
// pull data according to upload file type
if (this.isSalesForm) {
for (let i = 0; i < this.filelist.length; i++) {
var details = {
'CUSTOMER NAME': this.filelist[i]['CUSTOMER NAME'],
'PHONE NUMBER': this.filelist[i]['PHONE NUMBER'],
'LEAD ID': this.filelist[i]['LEAD ID'],
'DATE OF ENQUIRY': this.filelist[i]['DATE OF ENQUIRY'],
let data = {
from: '447491163530',
to: this.filelist[i]['PHONE NUMBER'],
content: {
templateName: 'infobip_kz_test_hsm_2',
templateData: {
body: {
placeholders: [this.filelist[i]['CUSTOMER NAME']],
},
},
language: 'en_GB',
},
callbackData: 'Callback data',
};
this.arrayToBeSend.push(details);
phoneNumber.push(this.filelist[i]['PHONE NUMBER']);
phoneNumber.push(data);
}
} else {
for (let i = 0; i < this.filelist.length; i++) {
var details = {
'CUSTOMER NAME': this.filelist[i]['Customer'],
'PHONE NUMBER': this.filelist[i]['Mobile No'],
'LEAD ID': this.filelist[i]['__EMPTY'],
'DATE OF ENQUIRY': this.filelist[i]['Ready For Invoice Date Time'],
let data = {
from: '447491163530',
to: this.filelist[i]['Mobile No'],
content: {
templateName: 'infobip_kz_test_hsm_2',
templateData: {
body: {
placeholders: [this.filelist[i]['Customer']],
},
},
language: 'en_GB',
},
callbackData: 'Callback data',
};
this.arrayToBeSend.push(details);
phoneNumber.push(this.filelist[i]['PHONE NUMBER']);
phoneNumber.push(data);
}
}
// after reading file and storing all phonenumbers in an array

Loading…
Cancel
Save