Built motion from commit (unavailable).|2.5.6
[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 _0x5fd9=['attributes','limit','include','model','map','GetZohoAccount','ShowZohoAccount','find','where','debug','catch','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','jayson/promise','request','then','ZohoAccount,\x20%s,\x20%s','ZohoAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','ZohoAccount','options','raw'];(function(_0x5db5f5,_0x195ef9){var _0x51d907=function(_0x203a3f){while(--_0x203a3f){_0x5db5f5['push'](_0x5db5f5['shift']());}};_0x51d907(++_0x195ef9);}(_0x5fd9,0x1d9));var _0x95fd=function(_0x120bc0,_0x40e780){_0x120bc0=_0x120bc0-0x0;var _0x49d52a=_0x5fd9[_0x120bc0];return _0x49d52a;};'use strict';var _=require('lodash');var util=require(_0x95fd('0x0'));var moment=require(_0x95fd('0x1'));var BPromise=require(_0x95fd('0x2'));var rs=require(_0x95fd('0x3'));var fs=require('fs');var Redis=require(_0x95fd('0x4'));var db=require(_0x95fd('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x95fd('0x6'))('rpc');var config=require('../../config/environment');var jayson=require(_0x95fd('0x7'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0xebaf10,_0x46799e,_0x54e5e7){return new BPromise(function(_0x31e2d8,_0x5bcafb){return client[_0x95fd('0x8')](_0xebaf10,_0x54e5e7)[_0x95fd('0x9')](function(_0x4521cd){logger['info'](_0x95fd('0xa'),_0x46799e,'request\x20sent');logger['debug'](_0x95fd('0xb'),_0x46799e,_0x95fd('0xc'),JSON[_0x95fd('0xd')](_0x4521cd));if(_0x4521cd[_0x95fd('0xe')]){if(_0x4521cd[_0x95fd('0xe')][_0x95fd('0xf')]===0x1f4){logger[_0x95fd('0xe')]('ZohoAccount,\x20%s,\x20%s',_0x46799e,_0x4521cd[_0x95fd('0xe')][_0x95fd('0x10')]);return _0x5bcafb(_0x4521cd[_0x95fd('0xe')]['message']);}logger[_0x95fd('0xe')](_0x95fd('0xa'),_0x46799e,_0x4521cd[_0x95fd('0xe')][_0x95fd('0x10')]);return _0x31e2d8(_0x4521cd[_0x95fd('0xe')][_0x95fd('0x10')]);}else{logger[_0x95fd('0x11')](_0x95fd('0xa'),_0x46799e,_0x95fd('0xc'));_0x31e2d8(_0x4521cd[_0x95fd('0x12')][_0x95fd('0x10')]);}})['catch'](function(_0x4e7410){logger['error']('ZohoAccount,\x20%s,\x20%s',_0x46799e,_0x4e7410);_0x5bcafb(_0x4e7410);});});}exports['GetZohoAccount']=function(_0x16f167){var _0x175d87=this;return new Promise(function(_0xcdb98c,_0x19e3a9){return db[_0x95fd('0x13')]['findAll']({'raw':_0x16f167['options']?_0x16f167[_0x95fd('0x14')][_0x95fd('0x15')]===undefined?!![]:![]:!![],'where':_0x16f167[_0x95fd('0x14')]?_0x16f167['options']['where']||null:null,'attributes':_0x16f167['options']?_0x16f167[_0x95fd('0x14')][_0x95fd('0x16')]||null:null,'limit':_0x16f167['options']?_0x16f167[_0x95fd('0x14')][_0x95fd('0x17')]||null:null,'include':_0x16f167['options']?_0x16f167[_0x95fd('0x14')]['include']?_['map'](_0x16f167[_0x95fd('0x14')][_0x95fd('0x18')],function(_0x1822c8){return{'model':db[_0x1822c8[_0x95fd('0x19')]],'as':_0x1822c8['as'],'attributes':_0x1822c8[_0x95fd('0x16')],'include':_0x1822c8[_0x95fd('0x18')]?_[_0x95fd('0x1a')](_0x1822c8[_0x95fd('0x18')],function(_0x2b597a){return{'model':db[_0x2b597a[_0x95fd('0x19')]],'as':_0x2b597a['as'],'attributes':_0x2b597a[_0x95fd('0x16')],'include':_0x2b597a['include']?_['map'](_0x2b597a[_0x95fd('0x18')],function(_0x2a7285){return{'model':db[_0x2a7285['model']],'as':_0x2a7285['as'],'attributes':_0x2a7285[_0x95fd('0x16')]};}):[]};}):[]};}):[]:[]})[_0x95fd('0x9')](function(_0xc4bbbd){logger[_0x95fd('0x11')](_0x95fd('0x1b'),_0x16f167);logger['debug'](_0x95fd('0x1b'),_0x16f167,JSON[_0x95fd('0xd')](_0xc4bbbd));_0xcdb98c(_0xc4bbbd);})['catch'](function(_0x418ff1){logger[_0x95fd('0xe')]('GetZohoAccount',_0x418ff1[_0x95fd('0x10')],_0x16f167);_0x19e3a9(_0x175d87[_0x95fd('0xe')](0x1f4,_0x418ff1[_0x95fd('0x10')]));});});};exports[_0x95fd('0x1c')]=function(_0x279637){var _0x236695=this;return new Promise(function(_0x1ac0ab,_0x379ce5){return db[_0x95fd('0x13')][_0x95fd('0x1d')]({'raw':_0x279637[_0x95fd('0x14')]?_0x279637[_0x95fd('0x14')][_0x95fd('0x15')]===undefined?!![]:![]:!![],'where':_0x279637[_0x95fd('0x14')]?_0x279637['options'][_0x95fd('0x1e')]||null:null,'attributes':_0x279637[_0x95fd('0x14')]?_0x279637[_0x95fd('0x14')][_0x95fd('0x16')]||null:null,'include':_0x279637[_0x95fd('0x14')]?_0x279637[_0x95fd('0x14')][_0x95fd('0x18')]?_[_0x95fd('0x1a')](_0x279637[_0x95fd('0x14')]['include'],function(_0x16539){return{'model':db[_0x16539[_0x95fd('0x19')]],'as':_0x16539['as'],'attributes':_0x16539[_0x95fd('0x16')],'include':_0x16539[_0x95fd('0x18')]?_[_0x95fd('0x1a')](_0x16539[_0x95fd('0x18')],function(_0x3a0e70){return{'model':db[_0x3a0e70['model']],'as':_0x3a0e70['as'],'attributes':_0x3a0e70[_0x95fd('0x16')],'include':_0x3a0e70[_0x95fd('0x18')]?_[_0x95fd('0x1a')](_0x3a0e70['include'],function(_0x411291){return{'model':db[_0x411291[_0x95fd('0x19')]],'as':_0x411291['as'],'attributes':_0x411291[_0x95fd('0x16')]};}):[]};}):[]};}):[]:[]})[_0x95fd('0x9')](function(_0x5f1ee8){logger[_0x95fd('0x11')](_0x95fd('0x1c'),_0x279637);logger[_0x95fd('0x1f')](_0x95fd('0x1c'),_0x279637,JSON[_0x95fd('0xd')](_0x5f1ee8));_0x1ac0ab(_0x5f1ee8);})[_0x95fd('0x20')](function(_0x118833){logger[_0x95fd('0xe')](_0x95fd('0x1c'),_0x118833['message'],_0x279637);_0x379ce5(_0x236695['error'](0x1f4,_0x118833['message']));});});};