1 line
3.1 KiB
JavaScript
1 line
3.1 KiB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.websdk=t():e.websdk=t()}(this,(function(){return(this.webpackChunkwebsdk=this.webpackChunkwebsdk||[]).push([[33],{70:function(e,t,r){r.r(t),r.d(t,{getSupportedLanguages:function(){return c},translateMessage:function(){return u}}),r(1539),r(8674),r(2222),r(9753);var a=r(3246),s=r(5531),n=r(7252),o=r(7360),i=r(4370);function c(){if(!a.XZ.call(this)){var e=n.Z.create({type:s.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(e)}var t=this.context,r=t.orgName,c=t.appName,u=t.accessToken,l={url:"".concat(this.apiUrl,"/").concat(r,"/").concat(c,"/users/").concat(this.user,"/translate/support/language"),dataType:"json",type:"GET",headers:{Authorization:"Bearer "+u}};return o.kg.debug("Call getSupportedLanguages"),i.hj.call(this,l)}function u(e){if("string"!=typeof e.text||""===e.text)throw Error('Invalid parameter: "text"');if(!Array.isArray(e.languages))throw Error('Invalid parameter: "language"');if(!a.XZ.call(this)){var t=n.Z.create({type:s.E.REST_PARAMS_STATUS,message:"appkey or token error"});return Promise.reject(t)}var r=this.context,c=r.orgName,u=r.appName,l=r.accessToken,p="".concat(this.apiUrl,"/").concat(c,"/").concat(u,"/users/").concat(this.user,"/translate"),d={text:e.text,to:e.languages},h={url:p,dataType:"json",type:"POST",data:JSON.stringify(d),headers:{Authorization:"Bearer "+l}};return o.kg.debug("Call translateMessage"),i.hj.call(this,h)}},3246:function(e,t,r){r.d(t,{H7:function(){return u},XZ:function(){return i},_W:function(){return c}}),r(7941),r(9554),r(1539),r(4747),r(6699),r(2023);var a=r(5531),s=r(7252);function n(){var e=this.context.appName,t=this.context.orgName;return!(!e||!t)||(this.onError&&this.onError({type:a.E.WEBIM_CONNCTION_AUTH_ERROR,message:"appName or orgName is illegal"}),!1)}function o(){var e;if(!this.context.accessToken){var t=s.Z.create({type:a.E.WEBIM_CONNCTION_TOKEN_NOT_ASSIGN_ERROR,message:"token not assign error"});return this.onError&&this.onError(t),null===(e=this.eventHandler)||void 0===e||e.dispatch("onError",t),!1}return!0}function i(){return o.call(this)&&n.call(this)}function c(e){var t=e.data,r=e.type;return{data:{status:Object.keys(t.errorKeys).length>0?"fail":"success",errorKeys:t.errorKeys,successKeys:t.successKeys},type:r}}function u(e){var t=e.data,r=void 0;return Object.keys(t.errorKeys).length>0&&Object.keys(t.errorKeys).forEach((function(e){var n=t.errorKeys[e];r=n.includes("is not part of you")?s.Z.create({type:a.E.NO_PERMISSION,message:n}):n.includes("size of metadata for this single chatroom exceeds the user defined limit")||n.includes("total size of chatroom metadata for this app exceeds the user defined limit")||n.includes("is exceeding maximum limit")?s.Z.create({type:a.E.MAX_LIMIT,message:n}):n.includes("is not Legal")?s.Z.create({type:a.E.REQUEST_PARAMETER_ERROR,message:n}):n.includes("Failed to update userMetadata. Concurrent updates not allowed")?s.Z.create({type:a.E.OPERATION_NOT_ALLOWED,message:n}):s.Z.create({type:a.E.WEBIM_CONNCTION_AJAX_ERROR,message:n})})),r}}},function(e){return 70,e(e.s=70)}])})); |