UNPKG

@nethesis/phone-island

Version:
3 lines (2 loc) 1.54 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../node_modules/tslib/tslib.es6.js"),t=require("../store/index.js");exports.getVoicemailBase64=function(r){return e.__awaiter(this,void 0,void 0,(function(){var s,a,o,i,n;return e.__generator(this,(function(c){switch(c.label){case 0:if(!r)throw new Error("Voicemail ID is required");s=t.store.getState().fetchDefaults,a=s.baseURL,o=s.headers,c.label=1;case 1:return c.trys.push([1,4,,5]),[4,fetch("".concat(a,"/voicemail/listen/").concat(r),{headers:e.__assign({},o)})];case 2:if(!(i=c.sent()).ok)throw new Error("Failed to get voicemail audio: ".concat(i.status," ").concat(i.statusText));return[4,i.json()];case 3:return[2,c.sent()];case 4:throw n=c.sent(),console.error("Error fetching voicemail audio:",n),n;case 5:return[2]}}))}))},exports.getVoicemailFileName=function(r){return e.__awaiter(this,void 0,void 0,(function(){var s,a,o,i,n;return e.__generator(this,(function(c){switch(c.label){case 0:if(!r)throw new Error("Voicemail ID is required");s=t.store.getState().fetchDefaults,a=s.baseURL,o=s.headers,c.label=1;case 1:return c.trys.push([1,4,,5]),[4,fetch("".concat(a,"/voicemail/download/").concat(r),{headers:e.__assign({},o)})];case 2:if(!(i=c.sent()).ok)throw new Error("Failed to get voicemail filename: ".concat(i.status," ").concat(i.statusText));return[4,i.json()];case 3:return[2,c.sent()];case 4:throw n=c.sent(),console.error("Error fetching voicemail filename:",n),n;case 5:return[2]}}))}))}; //# sourceMappingURL=voicemail.js.map