test powerpack

This commit is contained in:
huzaif-plivo 2021-08-11 17:00:29 +05:30
parent e60d5d927a
commit 470433a784

View file

@ -1,6 +1,7 @@
import * as _ from 'lodash';
import {
PlivoGenericResponse,
PlivoResource,
PlivoResourceInterface
} from '../base';
@ -695,8 +696,30 @@ export class PowerpackInterface extends PlivoResourceInterface {
* @promise {object} return {@link Powerpack} object
* @fail {Error} return Error
*/
get(uuid) {
return super.get(uuid);
get(uuid) {
let errors = validate([{
field: 'uuid',
value: uuid,
validators: ['isRequired']
}]);
if (errors) {
return errors;
}
let client = this[clientKey];
return new Promise((resolve, reject) => {
if (action !== '' && !uuid) {
reject(new Error(this[idKey] + ' must be set'));
}
client('GET', action + (uuid ? uuid + '/' : ''))
.then(response => {
resolve(new PlivoGenericResponse(response.body, client));
})
.catch(error => {
reject(error);
});
});
}
/**
* create Powerpack