Skip to content

Commit

Permalink
update twilio function
Browse files Browse the repository at this point in the history
  • Loading branch information
mabrownnyu committed Sep 10, 2024
1 parent edcd965 commit 0015b58
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/extensions/service-vendors/twilio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -825,12 +825,21 @@ export async function getTollFreeNumbers(
opts = {},
) {

// var for count of short codes
const messageServiceSid = await getMessageServiceSid(organization);

// var for count of toll free numbers
let tollfreeNumberCount = 0;

// defensively delete toll free numbers
await r.knex("owned_phone_number").where('area_code', 'Tollfree').del()

console.log("Trying to get toll free numbers");

// getting the shortcode list from twilio
const twilioInstance = await exports.getTwilio(organization);
const response = await twilioInstance.shortCodes.list();
const response = await twilioInstance.messaging.v1.services(messageServiceSid).phoneNumbers.list({limit: 20});

console.log(response);

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

// for each response, add it to the table
const tollfreeResponse = response.map(tollfree => {
const tollfreeResponse = response.map(response => {
addTollFreeNumberToPhoneNumberTable(tollfree);
tollfreeNumberCount++;
});
Expand Down

0 comments on commit 0015b58

Please sign in to comment.