Skip to content

Commit 0015b58

Browse files
committed
update twilio function
1 parent edcd965 commit 0015b58

File tree

1 file changed

+12
-3
lines changed
  • src/extensions/service-vendors/twilio

1 file changed

+12
-3
lines changed

src/extensions/service-vendors/twilio/index.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -825,12 +825,21 @@ export async function getTollFreeNumbers(
825825
opts = {},
826826
) {
827827

828-
// var for count of short codes
828+
const messageServiceSid = await getMessageServiceSid(organization);
829+
830+
// var for count of toll free numbers
829831
let tollfreeNumberCount = 0;
830832

833+
// defensively delete toll free numbers
834+
await r.knex("owned_phone_number").where('area_code', 'Tollfree').del()
835+
836+
console.log("Trying to get toll free numbers");
837+
831838
// getting the shortcode list from twilio
832839
const twilioInstance = await exports.getTwilio(organization);
833-
const response = await twilioInstance.shortCodes.list();
840+
const response = await twilioInstance.messaging.v1.services(messageServiceSid).phoneNumbers.list({limit: 20});
841+
842+
console.log(response);
834843

835844
// throw error if we get a bad response
836845
if (response.error) {
@@ -852,7 +861,7 @@ export async function getTollFreeNumbers(
852861
}
853862

854863
// for each response, add it to the table
855-
const tollfreeResponse = response.map(tollfree => {
864+
const tollfreeResponse = response.map(response => {
856865
addTollFreeNumberToPhoneNumberTable(tollfree);
857866
tollfreeNumberCount++;
858867
});

0 commit comments

Comments
 (0)