Built motion from commit d5e4af8c.|2.6.23
[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 _0xd8d7=['ZohoAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','GetZohoAccount','findAll','options','raw','where','attributes','limit','include','model','map','ZohoAccount','catch','ShowZohoAccount','lodash','util','moment','bluebird','randomstring','rpc','jayson/promise','client','http','request','then','info'];(function(_0x465028,_0x4570ac){var _0xb783d4=function(_0x5458c5){while(--_0x5458c5){_0x465028['push'](_0x465028['shift']());}};_0xb783d4(++_0x4570ac);}(_0xd8d7,0x1d4));var _0x7d8d=function(_0x513aa5,_0x1fba79){_0x513aa5=_0x513aa5-0x0;var _0x1a1a7c=_0xd8d7[_0x513aa5];return _0x1a1a7c;};'use strict';var _=require(_0x7d8d('0x0'));var util=require(_0x7d8d('0x1'));var moment=require(_0x7d8d('0x2'));var BPromise=require(_0x7d8d('0x3'));var rs=require(_0x7d8d('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x7d8d('0x5'));var config=require('../../config/environment');var jayson=require(_0x7d8d('0x6'));var client=jayson[_0x7d8d('0x7')][_0x7d8d('0x8')]({'port':0x232a});function respondWithRpcPromise(_0xc39292,_0x2294c2,_0x3036a9){return new BPromise(function(_0x1bac2e,_0x506fcd){return client[_0x7d8d('0x9')](_0xc39292,_0x3036a9)[_0x7d8d('0xa')](function(_0x3e2f6e){logger[_0x7d8d('0xb')](_0x7d8d('0xc'),_0x2294c2,_0x7d8d('0xd'));logger[_0x7d8d('0xe')]('ZohoAccount,\x20%s,\x20%s,\x20%s',_0x2294c2,_0x7d8d('0xd'),JSON[_0x7d8d('0xf')](_0x3e2f6e));if(_0x3e2f6e[_0x7d8d('0x10')]){if(_0x3e2f6e[_0x7d8d('0x10')][_0x7d8d('0x11')]===0x1f4){logger['error'](_0x7d8d('0xc'),_0x2294c2,_0x3e2f6e[_0x7d8d('0x10')][_0x7d8d('0x12')]);return _0x506fcd(_0x3e2f6e[_0x7d8d('0x10')][_0x7d8d('0x12')]);}logger[_0x7d8d('0x10')]('ZohoAccount,\x20%s,\x20%s',_0x2294c2,_0x3e2f6e[_0x7d8d('0x10')][_0x7d8d('0x12')]);return _0x1bac2e(_0x3e2f6e[_0x7d8d('0x10')][_0x7d8d('0x12')]);}else{logger[_0x7d8d('0xb')]('ZohoAccount,\x20%s,\x20%s',_0x2294c2,_0x7d8d('0xd'));_0x1bac2e(_0x3e2f6e['result'][_0x7d8d('0x12')]);}})['catch'](function(_0x12588c){logger[_0x7d8d('0x10')](_0x7d8d('0xc'),_0x2294c2,_0x12588c);_0x506fcd(_0x12588c);});});}exports[_0x7d8d('0x13')]=function(_0x1c00a3){var _0x31be40=this;return new Promise(function(_0x36dfbe,_0x37fe93){return db['ZohoAccount'][_0x7d8d('0x14')]({'raw':_0x1c00a3[_0x7d8d('0x15')]?_0x1c00a3[_0x7d8d('0x15')][_0x7d8d('0x16')]===undefined?!![]:![]:!![],'where':_0x1c00a3[_0x7d8d('0x15')]?_0x1c00a3[_0x7d8d('0x15')][_0x7d8d('0x17')]||null:null,'attributes':_0x1c00a3[_0x7d8d('0x15')]?_0x1c00a3[_0x7d8d('0x15')][_0x7d8d('0x18')]||null:null,'limit':_0x1c00a3[_0x7d8d('0x15')]?_0x1c00a3[_0x7d8d('0x15')][_0x7d8d('0x19')]||null:null,'include':_0x1c00a3[_0x7d8d('0x15')]?_0x1c00a3['options']['include']?_['map'](_0x1c00a3[_0x7d8d('0x15')][_0x7d8d('0x1a')],function(_0x2ab3b8){return{'model':db[_0x2ab3b8[_0x7d8d('0x1b')]],'as':_0x2ab3b8['as'],'attributes':_0x2ab3b8[_0x7d8d('0x18')],'include':_0x2ab3b8['include']?_[_0x7d8d('0x1c')](_0x2ab3b8[_0x7d8d('0x1a')],function(_0x459e88){return{'model':db[_0x459e88[_0x7d8d('0x1b')]],'as':_0x459e88['as'],'attributes':_0x459e88[_0x7d8d('0x18')],'include':_0x459e88[_0x7d8d('0x1a')]?_[_0x7d8d('0x1c')](_0x459e88['include'],function(_0x414da4){return{'model':db[_0x414da4[_0x7d8d('0x1b')]],'as':_0x414da4['as'],'attributes':_0x414da4[_0x7d8d('0x18')]};}):[]};}):[]};}):[]:[]})[_0x7d8d('0xa')](function(_0xedad25){logger['info']('GetZohoAccount',_0x1c00a3);logger[_0x7d8d('0xe')](_0x7d8d('0x13'),_0x1c00a3,JSON[_0x7d8d('0xf')](_0xedad25));_0x36dfbe(_0xedad25);})['catch'](function(_0x18605b){logger[_0x7d8d('0x10')](_0x7d8d('0x13'),_0x18605b['message'],_0x1c00a3);_0x37fe93(_0x31be40[_0x7d8d('0x10')](0x1f4,_0x18605b[_0x7d8d('0x12')]));});});};exports['ShowZohoAccount']=function(_0x1a918c){var _0x46319a=this;return new Promise(function(_0x3c1fb2,_0x308383){return db[_0x7d8d('0x1d')]['find']({'raw':_0x1a918c['options']?_0x1a918c[_0x7d8d('0x15')][_0x7d8d('0x16')]===undefined?!![]:![]:!![],'where':_0x1a918c['options']?_0x1a918c[_0x7d8d('0x15')]['where']||null:null,'attributes':_0x1a918c[_0x7d8d('0x15')]?_0x1a918c[_0x7d8d('0x15')]['attributes']||null:null,'include':_0x1a918c[_0x7d8d('0x15')]?_0x1a918c[_0x7d8d('0x15')][_0x7d8d('0x1a')]?_[_0x7d8d('0x1c')](_0x1a918c['options'][_0x7d8d('0x1a')],function(_0x55262f){return{'model':db[_0x55262f[_0x7d8d('0x1b')]],'as':_0x55262f['as'],'attributes':_0x55262f[_0x7d8d('0x18')],'include':_0x55262f[_0x7d8d('0x1a')]?_[_0x7d8d('0x1c')](_0x55262f['include'],function(_0x35e469){return{'model':db[_0x35e469[_0x7d8d('0x1b')]],'as':_0x35e469['as'],'attributes':_0x35e469[_0x7d8d('0x18')],'include':_0x35e469[_0x7d8d('0x1a')]?_[_0x7d8d('0x1c')](_0x35e469[_0x7d8d('0x1a')],function(_0x3a90df){return{'model':db[_0x3a90df[_0x7d8d('0x1b')]],'as':_0x3a90df['as'],'attributes':_0x3a90df['attributes']};}):[]};}):[]};}):[]:[]})[_0x7d8d('0xa')](function(_0x3f87da){logger[_0x7d8d('0xb')]('ShowZohoAccount',_0x1a918c);logger['debug']('ShowZohoAccount',_0x1a918c,JSON[_0x7d8d('0xf')](_0x3f87da));_0x3c1fb2(_0x3f87da);})[_0x7d8d('0x1e')](function(_0x41432a){logger[_0x7d8d('0x10')](_0x7d8d('0x1f'),_0x41432a['message'],_0x1a918c);_0x308383(_0x46319a[_0x7d8d('0x10')](0x1f4,_0x41432a[_0x7d8d('0x12')]));});});};