UNPKG

@nethesis/phone-island

Version:
3 lines (2 loc) 11.3 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../node_modules/tslib/tslib.es6.js"),t=require("../store/index.js");exports.answerPhysical=function(){return e.__awaiter(this,void 0,void 0,(function(){var r,s,n,a,o,i,c;return e.__generator(this,(function(u){switch(u.label){case 0:if(r=t.store.getState().currentUser.default_device,void 0===((null==r?void 0:r.id)||(null==r?void 0:r.exten)))return[3,4];s={endpointId:(null==r?void 0:r.exten)||(null==r?void 0:r.id),endpointType:"extension"},u.label=1;case 1:return u.trys.push([1,3,,4]),n=t.store.getState().fetchDefaults,a=n.baseURL,o=n.headers,[4,fetch("".concat(a,"/astproxy/answer"),{method:"POST",headers:e.__assign({},o),body:JSON.stringify(s)})];case 2:if(!(i=u.sent()).ok)throw new Error(i.statusText);return[2,!0];case 3:throw c=u.sent(),new Error(c);case 4:return[2]}}))}))},exports.attendedTransfer=function(r){return e.__awaiter(this,void 0,void 0,(function(){var s,n,a,o,i;return e.__generator(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),s=t.store.getState().fetchDefaults,n=s.baseURL,a=s.headers,[4,fetch("".concat(n,"/astproxy/atxfer"),{method:"POST",headers:e.__assign({},a),body:JSON.stringify(r)})];case 1:if(!(o=c.sent()).ok)throw new Error(o.statusText);return[2,!0];case 2:throw i=c.sent(),new Error(i);case 3:return[2]}}))}))},exports.blindTransfer=function(r){return e.__awaiter(this,void 0,void 0,(function(){var s,n,a,o,i;return e.__generator(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),s=t.store.getState().fetchDefaults,n=s.baseURL,a=s.headers,[4,fetch("".concat(n,"/astproxy/blindtransfer"),{method:"POST",headers:e.__assign({},a),body:JSON.stringify(r)})];case 1:if(!(o=c.sent()).ok)throw new Error(o.statusText);return[2,!0];case 2:throw i=c.sent(),new Error(i);case 3:return[2]}}))}))},exports.callPhysical=function(r){return e.__awaiter(this,void 0,void 0,(function(){var s,n,a,o,i,c,u;return e.__generator(this,(function(h){switch(h.label){case 0:s=t.store.getState().currentCall.ownerExtension,n={endpointId:s,endpointTpe:"extension",number:r},h.label=1;case 1:return h.trys.push([1,3,,4]),a=t.store.getState().fetchDefaults,o=a.baseURL,i=a.headers,[4,fetch("".concat(o,"/astproxy/call"),{method:"POST",headers:e.__assign({},i),body:JSON.stringify(n)})];case 2:if(!(c=h.sent()).ok)throw new Error(c.statusText);return[2,!0];case 3:throw u=h.sent(),new Error(u);case 4:return[2]}}))}))},exports.endConf=function(r){return e.__awaiter(this,void 0,void 0,(function(){var s,n,a,o;return e.__generator(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),s=t.store.getState().fetchDefaults,n=s.baseURL,a=s.headers,[4,fetch("".concat(n,"/astproxy/end_conf"),{method:"POST",headers:e.__assign({},a),body:JSON.stringify(r)})];case 1:if(!(o=i.sent()).ok)throw new Error(o.statusText);return[2,!0];case 2:throw i.sent();case 3:return[2]}}))}))},exports.forceHangup=function(r){return e.__awaiter(this,void 0,void 0,(function(){var s,n,a,o,i;return e.__generator(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),s=t.store.getState().fetchDefaults,n=s.baseURL,a=s.headers,[4,fetch("".concat(n,"/astproxy/force_hangup"),{method:"POST",headers:e.__assign({},a),body:JSON.stringify(r)})];case 1:if(!(o=c.sent()).ok)throw new Error(o.statusText);return[2,!0];case 2:throw i=c.sent(),new Error(i);case 3:return[2]}}))}))},exports.getAllExtensions=function(){return e.__awaiter(this,void 0,void 0,(function(){var r,s,n,a,o;return e.__generator(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),r=t.store.getState().fetchDefaults,s=r.baseURL,n=r.headers,[4,fetch("".concat(s,"/astproxy/extensions"),{headers:e.__assign({},n)})];case 1:if(!(a=i.sent()).ok)throw new Error(a.statusText);return[4,a.json()];case 2:return[2,i.sent()];case 3:throw o=i.sent(),new Error(o);case 4:return[2]}}))}))},exports.hangupConversation=function(r){return e.__awaiter(this,void 0,void 0,(function(){var s,n,a,o,i;return e.__generator(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),s=t.store.getState().fetchDefaults,n=s.baseURL,a=s.headers,[4,fetch("".concat(n,"/astproxy/hangup"),{method:"POST",headers:e.__assign({},a),body:JSON.stringify(r)})];case 1:if(!(o=c.sent()).ok)throw new Error(o.statusText);return[2,!0];case 2:throw i=c.sent(),new Error(i);case 3:return[2]}}))}))},exports.hangupPhysical=function(){var r;return e.__awaiter(this,void 0,void 0,(function(){var s,n,a,o,i,c,u,h,d,f,l,_;return e.__generator(this,(function(w){switch(w.label){case 0:s=t.store.getState().currentCall,n=s.ownerExtension,a=s.conversationId,o=t.store.getState().currentUser,c="/astproxy/",u="",""!==(null==(i={convid:a,endpointId:n,endpointType:"extension"})?void 0:i.convid)&&void 0!==(null==i?void 0:i.convid)?u="hangup":(u="cancel",i.endpointId=null===(r=null==o?void 0:o.default_device)||void 0===r?void 0:r.id),w.label=1;case 1:return w.trys.push([1,3,,4]),h=t.store.getState().fetchDefaults,d=h.baseURL,f=h.headers,[4,fetch("".concat(d)+"".concat(c)+"".concat(u),{method:"POST",headers:e.__assign({},f),body:JSON.stringify(i)})];case 2:if(!(l=w.sent()).ok)throw new Error(l.statusText);return[2,!0];case 3:throw _=w.sent(),new Error(_);case 4:return[2]}}))}))},exports.hangupPhysicalRecordingCall=function(){return e.__awaiter(this,void 0,void 0,(function(){var r,s,n,a,o,i,c,u,h;return e.__generator(this,(function(d){switch(d.label){case 0:r=t.store.getState().physicalRecorder,s=r.ownerExtension,n=r.conversationId,a={convid:n,endpointId:s,endpointType:"extension"},d.label=1;case 1:return d.trys.push([1,3,,4]),o=t.store.getState().fetchDefaults,i=o.baseURL,c=o.headers,[4,fetch("".concat(i,"/astproxy/hangup"),{method:"POST",headers:e.__assign({},c),body:JSON.stringify(a)})];case 2:if(!(u=d.sent()).ok)throw new Error(u.statusText);return[2,!0];case 3:throw h=d.sent(),new Error(h);case 4:return[2]}}))}))},exports.hangupUserConf=function(r){return e.__awaiter(this,void 0,void 0,(function(){var s,n,a,o;return e.__generator(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),s=t.store.getState().fetchDefaults,n=s.baseURL,a=s.headers,[4,fetch("".concat(n,"/astproxy/hangup_userconf"),{method:"POST",headers:e.__assign({},a),body:JSON.stringify(r)})];case 1:if(!(o=i.sent()).ok)throw new Error(o.statusText);return[2,!0];case 2:throw i.sent();case 3:return[2]}}))}))},exports.joinMyConf=function(r){return e.__awaiter(this,void 0,void 0,(function(){var s,n,a,o;return e.__generator(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),s=t.store.getState().fetchDefaults,n=s.baseURL,a=s.headers,[4,fetch("".concat(n,"/astproxy/join_myconf"),{method:"POST",headers:e.__assign({},a),body:JSON.stringify(r)})];case 1:if(!(o=i.sent()).ok)throw new Error(o.statusText);return[2,!0];case 2:throw i.sent();case 3:return[2]}}))}))},exports.mutePhysical=function(r){return e.__awaiter(this,void 0,void 0,(function(){var s,n,a,o,i,c,u,h,d;return e.__generator(this,(function(f){switch(f.label){case 0:s=t.store.getState().currentCall,n=s.ownerExtension,a=s.conversationId,o={convid:a,endpointId:n},f.label=1;case 1:return f.trys.push([1,3,,4]),i=t.store.getState().fetchDefaults,c=i.baseURL,u=i.headers,[4,fetch("".concat(c,"/astproxy/toggle_mute"),{method:"POST",headers:e.__assign({},u),body:JSON.stringify(o)})];case 2:if(!(h=f.sent()).ok)throw new Error(h.statusText);return t.store.dispatch.currentCall.updateCurrentCall({muted:r}),[2,!0];case 3:throw d=f.sent(),new Error(d);case 4:return[2]}}))}))},exports.muteUserConf=function(r){return e.__awaiter(this,void 0,void 0,(function(){var s,n,a,o;return e.__generator(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),s=t.store.getState().fetchDefaults,n=s.baseURL,a=s.headers,[4,fetch("".concat(n,"/astproxy/mute_userconf"),{method:"POST",headers:e.__assign({},a),body:JSON.stringify(r)})];case 1:if(!(o=i.sent()).ok)throw new Error(o.statusText);return[2,!0];case 2:throw i.sent();case 3:return[2]}}))}))},exports.parkConversation=function(r){return e.__awaiter(this,void 0,void 0,(function(){var s,n,a,o,i;return e.__generator(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),s=t.store.getState().fetchDefaults,n=s.baseURL,a=s.headers,[4,fetch("".concat(n,"/astproxy/park"),{method:"POST",headers:e.__assign({},a),body:JSON.stringify(r)})];case 1:if(!(o=c.sent()).ok)throw new Error(o.statusText);return[2,!0];case 2:throw i=c.sent(),new Error(i);case 3:return[2]}}))}))},exports.pausePhysical=function(r){return e.__awaiter(this,void 0,void 0,(function(){var s,n,a,o,i,c,u,h,d;return e.__generator(this,(function(f){switch(f.label){case 0:s=t.store.getState().currentCall,n=s.ownerExtension,a=s.conversationId,o={convid:a,endpointId:n},f.label=1;case 1:return f.trys.push([1,3,,4]),i=t.store.getState().fetchDefaults,c=i.baseURL,u=i.headers,[4,fetch("".concat(c,"/astproxy/toggle_hold"),{method:"POST",headers:e.__assign({},u),body:JSON.stringify(o)})];case 2:if(!(h=f.sent()).ok)throw new Error(h.statusText);return t.store.dispatch.currentCall.updateCurrentCall({paused:r}),[2,!0];case 3:throw d=f.sent(),new Error(d);case 4:return[2]}}))}))},exports.sendPhysicalDTMF=function(r){return e.__awaiter(this,void 0,void 0,(function(){var s,n,a,o,i,c,u,h,d;return e.__generator(this,(function(f){switch(f.label){case 0:s=t.store.getState().currentCall,n=s.ownerExtension,a=s.conversationId,o={convid:a,endpointId:n,tone:r.toString()},f.label=1;case 1:return f.trys.push([1,3,,4]),i=t.store.getState().fetchDefaults,c=i.baseURL,u=i.headers,[4,fetch("".concat(c,"/astproxy/dtmf"),{method:"POST",headers:e.__assign({},u),body:JSON.stringify(o)})];case 2:if(!(h=f.sent()).ok)throw new Error(h.statusText);return[2,!0];case 3:throw d=f.sent(),new Error(d);case 4:return[2]}}))}))},exports.startConf=function(r){return e.__awaiter(this,void 0,void 0,(function(){var s,n,a,o;return e.__generator(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),s=t.store.getState().fetchDefaults,n=s.baseURL,a=s.headers,[4,fetch("".concat(n,"/astproxy/start_conf"),{method:"POST",headers:e.__assign({},a),body:JSON.stringify(r)})];case 1:if(!(o=i.sent()).ok)throw new Error(o.statusText);return[2,!0];case 2:throw i.sent();case 3:return[2]}}))}))},exports.toggleRecord=function(r,s){return e.__awaiter(this,void 0,void 0,(function(){var n,a,o,i;return e.__generator(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),n=t.store.getState().fetchDefaults,a=n.baseURL,o=n.headers,[4,fetch("".concat(a,"/astproxy/").concat(r),{method:"POST",headers:e.__assign({},o),body:JSON.stringify(s)})];case 1:if(!(i=c.sent()).ok)throw new Error(i.statusText);return[2,!0];case 2:throw c.sent();case 3:return[2]}}))}))},exports.unmuteUserConf=function(r){return e.__awaiter(this,void 0,void 0,(function(){var s,n,a,o;return e.__generator(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),s=t.store.getState().fetchDefaults,n=s.baseURL,a=s.headers,[4,fetch("".concat(n,"/astproxy/unmute_userconf"),{method:"POST",headers:e.__assign({},a),body:JSON.stringify(r)})];case 1:if(!(o=i.sent()).ok)throw new Error(o.statusText);return[2,!0];case 2:throw i.sent();case 3:return[2]}}))}))}; //# sourceMappingURL=astproxy.js.map