lookup fix

This commit is contained in:
huzaif-plivo 2021-10-11 15:22:29 +05:30 committed by narayana
parent a3748ab6b3
commit a040ece470
7 changed files with 27 additions and 44 deletions

View file

@ -1523,7 +1523,7 @@ export function Request(config) {
}
// ============= Lookup ===================
else if (action == 'Lookup/Number/+14154305555' && method == 'GET') {
else if (action == 'Number//' && method == 'GET') {
resolve({
response: {},
body: {

View file

@ -38,17 +38,15 @@ export function AccessToken(authId, authToken, username, validityOptions = {}, u
this.uid = uid || this.username + "-" + (new Date()).getTime();
}
AccessToken.prototype.addVoiceGrants= function(incoming = false, outgoing = false) {
AccessToken.prototype = {
addVoiceGrants: function(incoming = false, outgoing = false) {
this.grants = {
voice: {
incoming_allow: incoming,
outgoing_allow: outgoing
}
};
}
AccessToken.prototype = {
},
toJwt: function() {
let payload = {
jti: this.uid,

View file

@ -15,16 +15,13 @@ describe('Account', function () {
});
it('should update Account via interface', function () {
return client.accounts.get()
.then(function(account){
return account.update({
return client.accounts.update({
name: 'name',
city: 'city',
address: 'address'
})
.then(function(account) {
assert.equal(account.name, 'name')
})
})
.then(function(account) {
assert.equal(account.message, 'changed')
})
});
@ -35,7 +32,7 @@ describe('Account', function () {
address: 'address'
})
.then(function(account) {
assert.equal(account.name, 'name')
assert.equal(account.message, 'changed')
})
});
@ -80,17 +77,7 @@ describe('Account', function () {
it('should update subAccount via interface', function () {
return client.subAccounts.update(1, 'name', true)
.then(function(account) {
assert.equal(account.name, 'name')
})
});
it('should update subAccount', function () {
return client.subAccounts.get(1)
.then(function(subaccount){
return subaccount.update('name', true)
})
.then(function(account) {
assert.equal(account.name, 'name')
assert.equal(account.message, 'changed')
})
});
@ -101,15 +88,6 @@ describe('Account', function () {
})
});
it('delete subAccounts', function () {
return client.subAccounts.get(1)
.then(function(subaccount){
return subaccount.delete()
})
.then(function(account) {
assert.equal(account, true)
})
});
it('delete subAccounts via interface', function () {
return client.subAccounts.delete(1)
.then(function(accounts) {

View file

@ -13,7 +13,8 @@ describe('LookupInterface', function() {
it('should lookup number', function() {
return client.lookup.get('+14154305555')
.then(function(number) {
assert.equal(number.numberFormat.e164, '+14154305555')
console.log(number)
assert.equal(number.format.e164, '+14154305555')
assert.equal(number.phoneNumber, '+14154305555')
assert.equal(number.resourceUri, '/v1/Number/+14154305555?type=carrier')
})

View file

@ -19,7 +19,7 @@ describe('MediaInterface', function () {
});
it('should get media', function () {
return client.media.get('0178eb8a-461a-4fd1-bc37-13eebfdc0676')
.then(function (media) {
.then(function (res) {
assert.equal(res.mediaId, '0178eb8a-461a-4fd1-bc37-13eebfdc0676')
})
});

View file

@ -25,7 +25,7 @@ describe('message', function () {
});
it('should create message via interface', function () {
return client.messages.create('src', 'dst', 'text')
return client.messages.create({src:'src', dst:'dst', text:'text',powerpackUUID: null})
.then(function (message) {
assert.equal(message.message, 'message(s) queued')
})
@ -38,6 +38,13 @@ describe('message', function () {
})
});
it('should send message via interface', function () {
return client.messages.create({src:'src', dst:'dst', text:'text'})
.then(function(message){
assert.equal(message.message, 'message(s) queued')
})
});
it('should throw error - id is required via interface', function () {
return client.messages.get()
@ -47,14 +54,14 @@ describe('message', function () {
});
it('should throw error - src and powerpack both not present', function () {
return client.messages.send(null, 'dst', 'text', {}, null)
return client.messages.send({src:null,dst:'dst',text:'text',powerpackUUID:null})
.catch(function (err) {
assert.equal(err.message, 'Neither of src or powerpack uuid present, either one is required')
})
});
it('should throw error - src and powerpack both are present', function () {
return client.messages.send('91235456917375', 'dst', 'text', {}, '916386027476')
return client.messages.send({src:'91235456917375', dst:'dst', text:'text', powerpackUUID:'916386027476'})
.catch(function (err) {
assert.equal(err.message, 'Either of src or powerpack uuid, both of them are present')
})

View file

@ -29,7 +29,7 @@ describe('PowerpackInterface', function () {
return powerpack.delete()
})
.then(function (result) {
assert.equal(res.response, "success")
assert.equal(result.response, "success")
})
});
it('list powerpacks numbers via interface', function () {
@ -63,10 +63,9 @@ describe('PowerpackInterface', function () {
client.powerpacks.get("5ec4c8c9-cd74-42b5-9e41-0d7670d6bb46").then(
function (powerpack) {
return powerpack.find_shortcode('4444444')
})
.then(function (result) {
assert.equal(result.shortcode, "4444444")
})
}).then(function (ppk) {
assert.equal(ppk.shortcode, "4444444")
});
});
it('list shortcode via interface', function () {
client.powerpacks.get("5ec4c8c9-cd74-42b5-9e41-0d7670d6bb46").then(