Built motion from commit fd055180.|2.6.30
[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 _0x29b6=['include','map','model','then','GetZohoAccount','catch','find','ShowZohoAccount','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http','request','info','ZohoAccount,\x20%s,\x20%s','request\x20sent','debug','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','ZohoAccount','options','raw','attributes','limit'];(function(_0x190681,_0x590f58){var _0x4f2ada=function(_0x4556db){while(--_0x4556db){_0x190681['push'](_0x190681['shift']());}};_0x4f2ada(++_0x590f58);}(_0x29b6,0x17e));var _0x629b=function(_0x2fdc16,_0x46b810){_0x2fdc16=_0x2fdc16-0x0;var _0x210f85=_0x29b6[_0x2fdc16];return _0x210f85;};'use strict';var _=require(_0x629b('0x0'));var util=require(_0x629b('0x1'));var moment=require(_0x629b('0x2'));var BPromise=require(_0x629b('0x3'));var rs=require(_0x629b('0x4'));var fs=require('fs');var Redis=require(_0x629b('0x5'));var db=require(_0x629b('0x6'))['db'];var utils=require(_0x629b('0x7'));var logger=require(_0x629b('0x8'))(_0x629b('0x9'));var config=require('../../config/environment');var jayson=require(_0x629b('0xa'));var client=jayson['client'][_0x629b('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x4acc5a,_0x26e439,_0x398ecb){return new BPromise(function(_0x4e90cd,_0xc44b27){return client[_0x629b('0xc')](_0x4acc5a,_0x398ecb)['then'](function(_0x28c152){logger[_0x629b('0xd')](_0x629b('0xe'),_0x26e439,_0x629b('0xf'));logger[_0x629b('0x10')](_0x629b('0x11'),_0x26e439,_0x629b('0xf'),JSON[_0x629b('0x12')](_0x28c152));if(_0x28c152[_0x629b('0x13')]){if(_0x28c152[_0x629b('0x13')]['code']===0x1f4){logger['error'](_0x629b('0xe'),_0x26e439,_0x28c152[_0x629b('0x13')][_0x629b('0x14')]);return _0xc44b27(_0x28c152['error'][_0x629b('0x14')]);}logger[_0x629b('0x13')](_0x629b('0xe'),_0x26e439,_0x28c152[_0x629b('0x13')]['message']);return _0x4e90cd(_0x28c152[_0x629b('0x13')][_0x629b('0x14')]);}else{logger[_0x629b('0xd')](_0x629b('0xe'),_0x26e439,_0x629b('0xf'));_0x4e90cd(_0x28c152['result'][_0x629b('0x14')]);}})['catch'](function(_0x151b93){logger[_0x629b('0x13')](_0x629b('0xe'),_0x26e439,_0x151b93);_0xc44b27(_0x151b93);});});}exports['GetZohoAccount']=function(_0x7f24d3){var _0x58f5a8=this;return new Promise(function(_0x1c93a1,_0x4f28dd){return db[_0x629b('0x15')]['findAll']({'raw':_0x7f24d3[_0x629b('0x16')]?_0x7f24d3[_0x629b('0x16')][_0x629b('0x17')]===undefined?!![]:![]:!![],'where':_0x7f24d3['options']?_0x7f24d3[_0x629b('0x16')]['where']||null:null,'attributes':_0x7f24d3[_0x629b('0x16')]?_0x7f24d3[_0x629b('0x16')][_0x629b('0x18')]||null:null,'limit':_0x7f24d3[_0x629b('0x16')]?_0x7f24d3['options'][_0x629b('0x19')]||null:null,'include':_0x7f24d3['options']?_0x7f24d3[_0x629b('0x16')][_0x629b('0x1a')]?_[_0x629b('0x1b')](_0x7f24d3['options'][_0x629b('0x1a')],function(_0x1e773e){return{'model':db[_0x1e773e[_0x629b('0x1c')]],'as':_0x1e773e['as'],'attributes':_0x1e773e[_0x629b('0x18')],'include':_0x1e773e[_0x629b('0x1a')]?_[_0x629b('0x1b')](_0x1e773e[_0x629b('0x1a')],function(_0x547b3c){return{'model':db[_0x547b3c['model']],'as':_0x547b3c['as'],'attributes':_0x547b3c['attributes'],'include':_0x547b3c['include']?_[_0x629b('0x1b')](_0x547b3c[_0x629b('0x1a')],function(_0xf68af8){return{'model':db[_0xf68af8[_0x629b('0x1c')]],'as':_0xf68af8['as'],'attributes':_0xf68af8[_0x629b('0x18')]};}):[]};}):[]};}):[]:[]})[_0x629b('0x1d')](function(_0x4c1f21){logger[_0x629b('0xd')](_0x629b('0x1e'),_0x7f24d3);logger[_0x629b('0x10')](_0x629b('0x1e'),_0x7f24d3,JSON[_0x629b('0x12')](_0x4c1f21));_0x1c93a1(_0x4c1f21);})[_0x629b('0x1f')](function(_0x3ef549){logger[_0x629b('0x13')]('GetZohoAccount',_0x3ef549['message'],_0x7f24d3);_0x4f28dd(_0x58f5a8[_0x629b('0x13')](0x1f4,_0x3ef549[_0x629b('0x14')]));});});};exports['ShowZohoAccount']=function(_0x1628cb){var _0x56c088=this;return new Promise(function(_0x86ee7c,_0x37b918){return db['ZohoAccount'][_0x629b('0x20')]({'raw':_0x1628cb[_0x629b('0x16')]?_0x1628cb[_0x629b('0x16')][_0x629b('0x17')]===undefined?!![]:![]:!![],'where':_0x1628cb[_0x629b('0x16')]?_0x1628cb[_0x629b('0x16')]['where']||null:null,'attributes':_0x1628cb[_0x629b('0x16')]?_0x1628cb[_0x629b('0x16')][_0x629b('0x18')]||null:null,'include':_0x1628cb[_0x629b('0x16')]?_0x1628cb[_0x629b('0x16')][_0x629b('0x1a')]?_[_0x629b('0x1b')](_0x1628cb[_0x629b('0x16')][_0x629b('0x1a')],function(_0x26a541){return{'model':db[_0x26a541[_0x629b('0x1c')]],'as':_0x26a541['as'],'attributes':_0x26a541[_0x629b('0x18')],'include':_0x26a541[_0x629b('0x1a')]?_['map'](_0x26a541['include'],function(_0x17aaef){return{'model':db[_0x17aaef[_0x629b('0x1c')]],'as':_0x17aaef['as'],'attributes':_0x17aaef[_0x629b('0x18')],'include':_0x17aaef[_0x629b('0x1a')]?_['map'](_0x17aaef[_0x629b('0x1a')],function(_0x202348){return{'model':db[_0x202348[_0x629b('0x1c')]],'as':_0x202348['as'],'attributes':_0x202348[_0x629b('0x18')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x13cac7){logger[_0x629b('0xd')](_0x629b('0x21'),_0x1628cb);logger[_0x629b('0x10')](_0x629b('0x21'),_0x1628cb,JSON['stringify'](_0x13cac7));_0x86ee7c(_0x13cac7);})[_0x629b('0x1f')](function(_0x4024c7){logger[_0x629b('0x13')](_0x629b('0x21'),_0x4024c7[_0x629b('0x14')],_0x1628cb);_0x37b918(_0x56c088[_0x629b('0x13')](0x1f4,_0x4024c7[_0x629b('0x14')]));});});};