Built motion from commit 9d0783e6.|2.6.13
[motion2.git] / server / api / intZohoAccount / intZohoAccount.rpc.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xc1d3=['ShowZohoAccount','find','raw','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise','http','request','then','info','ZohoAccount,\x20%s,\x20%s','request\x20sent','debug','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','ZohoAccount','findAll','options','where','limit','include','map','model','attributes','GetZohoAccount'];(function(_0x47aa64,_0xfb8a07){var _0x549c7a=function(_0x266165){while(--_0x266165){_0x47aa64['push'](_0x47aa64['shift']());}};_0x549c7a(++_0xfb8a07);}(_0xc1d3,0x147));var _0x3c1d=function(_0xbed52b,_0x36d658){_0xbed52b=_0xbed52b-0x0;var _0x391159=_0xc1d3[_0xbed52b];return _0x391159;};'use strict';var _=require(_0x3c1d('0x0'));var util=require(_0x3c1d('0x1'));var moment=require(_0x3c1d('0x2'));var BPromise=require(_0x3c1d('0x3'));var rs=require(_0x3c1d('0x4'));var fs=require('fs');var Redis=require(_0x3c1d('0x5'));var db=require(_0x3c1d('0x6'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x3c1d('0x7'));var config=require(_0x3c1d('0x8'));var jayson=require(_0x3c1d('0x9'));var client=jayson['client'][_0x3c1d('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x36863b,_0x3bef1a,_0x28793c){return new BPromise(function(_0x1796a0,_0x58e08c){return client[_0x3c1d('0xb')](_0x36863b,_0x28793c)[_0x3c1d('0xc')](function(_0x33cb1b){logger[_0x3c1d('0xd')](_0x3c1d('0xe'),_0x3bef1a,_0x3c1d('0xf'));logger[_0x3c1d('0x10')](_0x3c1d('0x11'),_0x3bef1a,'request\x20sent',JSON[_0x3c1d('0x12')](_0x33cb1b));if(_0x33cb1b[_0x3c1d('0x13')]){if(_0x33cb1b[_0x3c1d('0x13')][_0x3c1d('0x14')]===0x1f4){logger[_0x3c1d('0x13')]('ZohoAccount,\x20%s,\x20%s',_0x3bef1a,_0x33cb1b[_0x3c1d('0x13')][_0x3c1d('0x15')]);return _0x58e08c(_0x33cb1b['error'][_0x3c1d('0x15')]);}logger['error']('ZohoAccount,\x20%s,\x20%s',_0x3bef1a,_0x33cb1b['error'][_0x3c1d('0x15')]);return _0x1796a0(_0x33cb1b[_0x3c1d('0x13')][_0x3c1d('0x15')]);}else{logger[_0x3c1d('0xd')](_0x3c1d('0xe'),_0x3bef1a,_0x3c1d('0xf'));_0x1796a0(_0x33cb1b['result']['message']);}})[_0x3c1d('0x16')](function(_0x5ab3b0){logger[_0x3c1d('0x13')](_0x3c1d('0xe'),_0x3bef1a,_0x5ab3b0);_0x58e08c(_0x5ab3b0);});});}exports['GetZohoAccount']=function(_0x4a7e42){var _0x49a81d=this;return new Promise(function(_0x33637d,_0x4620fb){return db[_0x3c1d('0x17')][_0x3c1d('0x18')]({'raw':_0x4a7e42[_0x3c1d('0x19')]?_0x4a7e42['options']['raw']===undefined?!![]:![]:!![],'where':_0x4a7e42[_0x3c1d('0x19')]?_0x4a7e42[_0x3c1d('0x19')][_0x3c1d('0x1a')]||null:null,'attributes':_0x4a7e42[_0x3c1d('0x19')]?_0x4a7e42[_0x3c1d('0x19')]['attributes']||null:null,'limit':_0x4a7e42[_0x3c1d('0x19')]?_0x4a7e42[_0x3c1d('0x19')][_0x3c1d('0x1b')]||null:null,'include':_0x4a7e42['options']?_0x4a7e42[_0x3c1d('0x19')][_0x3c1d('0x1c')]?_[_0x3c1d('0x1d')](_0x4a7e42[_0x3c1d('0x19')][_0x3c1d('0x1c')],function(_0x1a853d){return{'model':db[_0x1a853d[_0x3c1d('0x1e')]],'as':_0x1a853d['as'],'attributes':_0x1a853d[_0x3c1d('0x1f')],'include':_0x1a853d[_0x3c1d('0x1c')]?_['map'](_0x1a853d[_0x3c1d('0x1c')],function(_0x2a8854){return{'model':db[_0x2a8854[_0x3c1d('0x1e')]],'as':_0x2a8854['as'],'attributes':_0x2a8854['attributes'],'include':_0x2a8854[_0x3c1d('0x1c')]?_[_0x3c1d('0x1d')](_0x2a8854['include'],function(_0x392bb1){return{'model':db[_0x392bb1[_0x3c1d('0x1e')]],'as':_0x392bb1['as'],'attributes':_0x392bb1[_0x3c1d('0x1f')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x23e5a0){logger['info'](_0x3c1d('0x20'),_0x4a7e42);logger[_0x3c1d('0x10')]('GetZohoAccount',_0x4a7e42,JSON['stringify'](_0x23e5a0));_0x33637d(_0x23e5a0);})[_0x3c1d('0x16')](function(_0x2f7af9){logger[_0x3c1d('0x13')]('GetZohoAccount',_0x2f7af9[_0x3c1d('0x15')],_0x4a7e42);_0x4620fb(_0x49a81d['error'](0x1f4,_0x2f7af9[_0x3c1d('0x15')]));});});};exports[_0x3c1d('0x21')]=function(_0x1296ed){var _0x4f0d9e=this;return new Promise(function(_0x147523,_0x3fa262){return db[_0x3c1d('0x17')][_0x3c1d('0x22')]({'raw':_0x1296ed[_0x3c1d('0x19')]?_0x1296ed[_0x3c1d('0x19')][_0x3c1d('0x23')]===undefined?!![]:![]:!![],'where':_0x1296ed[_0x3c1d('0x19')]?_0x1296ed[_0x3c1d('0x19')]['where']||null:null,'attributes':_0x1296ed['options']?_0x1296ed[_0x3c1d('0x19')]['attributes']||null:null,'include':_0x1296ed[_0x3c1d('0x19')]?_0x1296ed[_0x3c1d('0x19')][_0x3c1d('0x1c')]?_[_0x3c1d('0x1d')](_0x1296ed[_0x3c1d('0x19')]['include'],function(_0x1bc180){return{'model':db[_0x1bc180[_0x3c1d('0x1e')]],'as':_0x1bc180['as'],'attributes':_0x1bc180['attributes'],'include':_0x1bc180['include']?_[_0x3c1d('0x1d')](_0x1bc180[_0x3c1d('0x1c')],function(_0x38673f){return{'model':db[_0x38673f[_0x3c1d('0x1e')]],'as':_0x38673f['as'],'attributes':_0x38673f[_0x3c1d('0x1f')],'include':_0x38673f['include']?_[_0x3c1d('0x1d')](_0x38673f[_0x3c1d('0x1c')],function(_0x4bda17){return{'model':db[_0x4bda17['model']],'as':_0x4bda17['as'],'attributes':_0x4bda17['attributes']};}):[]};}):[]};}):[]:[]})[_0x3c1d('0xc')](function(_0xe04d95){logger[_0x3c1d('0xd')](_0x3c1d('0x21'),_0x1296ed);logger['debug'](_0x3c1d('0x21'),_0x1296ed,JSON['stringify'](_0xe04d95));_0x147523(_0xe04d95);})[_0x3c1d('0x16')](function(_0x3c9d5d){logger[_0x3c1d('0x13')](_0x3c1d('0x21'),_0x3c9d5d[_0x3c1d('0x15')],_0x1296ed);_0x3fa262(_0x4f0d9e['error'](0x1f4,_0x3c9d5d[_0x3c1d('0x15')]));});});};