Built motion from commit f8768ebe.|2.6.15
[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 _0xfa25=['moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','client','request','info','ZohoAccount,\x20%s,\x20%s','debug','stringify','error','code','message','request\x20sent','result','GetZohoAccount','findAll','options','raw','where','attributes','limit','include','map','model','then','catch','ShowZohoAccount','ZohoAccount','find','util'];(function(_0x21a9d9,_0x4d5ac8){var _0x46adce=function(_0xfdd336){while(--_0xfdd336){_0x21a9d9['push'](_0x21a9d9['shift']());}};_0x46adce(++_0x4d5ac8);}(_0xfa25,0xd1));var _0x5fa2=function(_0x3bb27d,_0x1c25a4){_0x3bb27d=_0x3bb27d-0x0;var _0x384140=_0xfa25[_0x3bb27d];return _0x384140;};'use strict';var _=require('lodash');var util=require(_0x5fa2('0x0'));var moment=require(_0x5fa2('0x1'));var BPromise=require(_0x5fa2('0x2'));var rs=require(_0x5fa2('0x3'));var fs=require('fs');var Redis=require(_0x5fa2('0x4'));var db=require(_0x5fa2('0x5'))['db'];var utils=require(_0x5fa2('0x6'));var logger=require(_0x5fa2('0x7'))('rpc');var config=require('../../config/environment');var jayson=require(_0x5fa2('0x8'));var client=jayson[_0x5fa2('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x53a560,_0x2a9a69,_0x4b04ea){return new BPromise(function(_0x35c145,_0x9c9f1c){return client[_0x5fa2('0xa')](_0x53a560,_0x4b04ea)['then'](function(_0x36778e){logger[_0x5fa2('0xb')](_0x5fa2('0xc'),_0x2a9a69,'request\x20sent');logger[_0x5fa2('0xd')]('ZohoAccount,\x20%s,\x20%s,\x20%s',_0x2a9a69,'request\x20sent',JSON[_0x5fa2('0xe')](_0x36778e));if(_0x36778e[_0x5fa2('0xf')]){if(_0x36778e['error'][_0x5fa2('0x10')]===0x1f4){logger[_0x5fa2('0xf')](_0x5fa2('0xc'),_0x2a9a69,_0x36778e[_0x5fa2('0xf')][_0x5fa2('0x11')]);return _0x9c9f1c(_0x36778e[_0x5fa2('0xf')][_0x5fa2('0x11')]);}logger[_0x5fa2('0xf')](_0x5fa2('0xc'),_0x2a9a69,_0x36778e[_0x5fa2('0xf')][_0x5fa2('0x11')]);return _0x35c145(_0x36778e[_0x5fa2('0xf')][_0x5fa2('0x11')]);}else{logger[_0x5fa2('0xb')]('ZohoAccount,\x20%s,\x20%s',_0x2a9a69,_0x5fa2('0x12'));_0x35c145(_0x36778e[_0x5fa2('0x13')][_0x5fa2('0x11')]);}})['catch'](function(_0x4e20d1){logger[_0x5fa2('0xf')](_0x5fa2('0xc'),_0x2a9a69,_0x4e20d1);_0x9c9f1c(_0x4e20d1);});});}exports[_0x5fa2('0x14')]=function(_0x522f1c){var _0x427205=this;return new Promise(function(_0x593815,_0x41be51){return db['ZohoAccount'][_0x5fa2('0x15')]({'raw':_0x522f1c[_0x5fa2('0x16')]?_0x522f1c['options'][_0x5fa2('0x17')]===undefined?!![]:![]:!![],'where':_0x522f1c[_0x5fa2('0x16')]?_0x522f1c[_0x5fa2('0x16')][_0x5fa2('0x18')]||null:null,'attributes':_0x522f1c['options']?_0x522f1c[_0x5fa2('0x16')][_0x5fa2('0x19')]||null:null,'limit':_0x522f1c[_0x5fa2('0x16')]?_0x522f1c[_0x5fa2('0x16')][_0x5fa2('0x1a')]||null:null,'include':_0x522f1c[_0x5fa2('0x16')]?_0x522f1c[_0x5fa2('0x16')][_0x5fa2('0x1b')]?_[_0x5fa2('0x1c')](_0x522f1c[_0x5fa2('0x16')][_0x5fa2('0x1b')],function(_0x2cac01){return{'model':db[_0x2cac01[_0x5fa2('0x1d')]],'as':_0x2cac01['as'],'attributes':_0x2cac01['attributes'],'include':_0x2cac01[_0x5fa2('0x1b')]?_[_0x5fa2('0x1c')](_0x2cac01[_0x5fa2('0x1b')],function(_0x45af15){return{'model':db[_0x45af15['model']],'as':_0x45af15['as'],'attributes':_0x45af15['attributes'],'include':_0x45af15[_0x5fa2('0x1b')]?_[_0x5fa2('0x1c')](_0x45af15['include'],function(_0x12b99b){return{'model':db[_0x12b99b[_0x5fa2('0x1d')]],'as':_0x12b99b['as'],'attributes':_0x12b99b[_0x5fa2('0x19')]};}):[]};}):[]};}):[]:[]})[_0x5fa2('0x1e')](function(_0x18cbd7){logger[_0x5fa2('0xb')]('GetZohoAccount',_0x522f1c);logger[_0x5fa2('0xd')](_0x5fa2('0x14'),_0x522f1c,JSON[_0x5fa2('0xe')](_0x18cbd7));_0x593815(_0x18cbd7);})[_0x5fa2('0x1f')](function(_0x4fd561){logger[_0x5fa2('0xf')](_0x5fa2('0x14'),_0x4fd561['message'],_0x522f1c);_0x41be51(_0x427205['error'](0x1f4,_0x4fd561['message']));});});};exports[_0x5fa2('0x20')]=function(_0xc5a40c){var _0x5a0d50=this;return new Promise(function(_0x22f054,_0x3d1d41){return db[_0x5fa2('0x21')][_0x5fa2('0x22')]({'raw':_0xc5a40c[_0x5fa2('0x16')]?_0xc5a40c['options'][_0x5fa2('0x17')]===undefined?!![]:![]:!![],'where':_0xc5a40c[_0x5fa2('0x16')]?_0xc5a40c[_0x5fa2('0x16')][_0x5fa2('0x18')]||null:null,'attributes':_0xc5a40c[_0x5fa2('0x16')]?_0xc5a40c['options'][_0x5fa2('0x19')]||null:null,'include':_0xc5a40c[_0x5fa2('0x16')]?_0xc5a40c['options']['include']?_['map'](_0xc5a40c[_0x5fa2('0x16')][_0x5fa2('0x1b')],function(_0x293948){return{'model':db[_0x293948['model']],'as':_0x293948['as'],'attributes':_0x293948[_0x5fa2('0x19')],'include':_0x293948[_0x5fa2('0x1b')]?_['map'](_0x293948['include'],function(_0x3ba30e){return{'model':db[_0x3ba30e['model']],'as':_0x3ba30e['as'],'attributes':_0x3ba30e[_0x5fa2('0x19')],'include':_0x3ba30e[_0x5fa2('0x1b')]?_['map'](_0x3ba30e[_0x5fa2('0x1b')],function(_0x5e7419){return{'model':db[_0x5e7419[_0x5fa2('0x1d')]],'as':_0x5e7419['as'],'attributes':_0x5e7419['attributes']};}):[]};}):[]};}):[]:[]})[_0x5fa2('0x1e')](function(_0x2e9614){logger['info'](_0x5fa2('0x20'),_0xc5a40c);logger[_0x5fa2('0xd')](_0x5fa2('0x20'),_0xc5a40c,JSON[_0x5fa2('0xe')](_0x2e9614));_0x22f054(_0x2e9614);})[_0x5fa2('0x1f')](function(_0x2e0a26){logger[_0x5fa2('0xf')](_0x5fa2('0x20'),_0x2e0a26[_0x5fa2('0x11')],_0xc5a40c);_0x3d1d41(_0x5a0d50[_0x5fa2('0xf')](0x1f4,_0x2e0a26[_0x5fa2('0x11')]));});});};