feat/982: fixed issue where vendor's API is not called if vendor is defined at service provider level, and also made format of name consistent (#365)

This commit is contained in:
rammohan-y
2024-12-12 17:06:45 -05:00
committed by GitHub
parent 843980c7f6
commit 75c27e3f80
3 changed files with 33 additions and 23 deletions
+5 -2
View File
@@ -22,14 +22,17 @@ class SpeechCredential extends Model {
static async getSpeechCredentialsByVendorAndLabel(service_provider_sid, account_sid, vendor, label) {
let sql;
let rows = [];
if (account_sid) {
sql = `SELECT * FROM speech_credentials WHERE account_sid = ? AND vendor = ?
AND label ${label ? '= ?' : 'is NULL'}`;
} else {
[rows] = await promisePool.query(sql, [account_sid, vendor, label]);
}
if (rows.length === 0) {
sql = `SELECT * FROM speech_credentials WHERE service_provider_sid = ? AND vendor = ?
AND label ${label ? '= ?' : 'is NULL'}`;
[rows] = await promisePool.query(sql, [service_provider_sid, vendor, label]);
}
const [rows] = await promisePool.query(sql, [account_sid ? account_sid : service_provider_sid, vendor, label]);
return rows;
}