Built motion from commit b0a9a629.|2.6.33
[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 _0xa5c1=['util','moment','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','then','info','ZohoAccount,\x20%s,\x20%s','debug','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','ZohoAccount','options','raw','attributes','include','map','model','GetZohoAccount','ShowZohoAccount','find','where','lodash'];(function(_0x122ef9,_0x451d2a){var _0x42fba0=function(_0x17c9d3){while(--_0x17c9d3){_0x122ef9['push'](_0x122ef9['shift']());}};_0x42fba0(++_0x451d2a);}(_0xa5c1,0x19f));var _0x1a5c=function(_0x270b83,_0x481742){_0x270b83=_0x270b83-0x0;var _0x51da81=_0xa5c1[_0x270b83];return _0x51da81;};'use strict';var _=require(_0x1a5c('0x0'));var util=require(_0x1a5c('0x1'));var moment=require(_0x1a5c('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x1a5c('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x1a5c('0x4'));var logger=require(_0x1a5c('0x5'))(_0x1a5c('0x6'));var config=require(_0x1a5c('0x7'));var jayson=require(_0x1a5c('0x8'));var client=jayson[_0x1a5c('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x9853,_0x580a2e,_0x438f8f){return new BPromise(function(_0x43a2ed,_0x1702ce){return client['request'](_0x9853,_0x438f8f)[_0x1a5c('0xa')](function(_0x4c0bd2){logger[_0x1a5c('0xb')](_0x1a5c('0xc'),_0x580a2e,'request\x20sent');logger[_0x1a5c('0xd')](_0x1a5c('0xe'),_0x580a2e,'request\x20sent',JSON[_0x1a5c('0xf')](_0x4c0bd2));if(_0x4c0bd2[_0x1a5c('0x10')]){if(_0x4c0bd2[_0x1a5c('0x10')][_0x1a5c('0x11')]===0x1f4){logger[_0x1a5c('0x10')](_0x1a5c('0xc'),_0x580a2e,_0x4c0bd2[_0x1a5c('0x10')]['message']);return _0x1702ce(_0x4c0bd2[_0x1a5c('0x10')][_0x1a5c('0x12')]);}logger['error'](_0x1a5c('0xc'),_0x580a2e,_0x4c0bd2[_0x1a5c('0x10')]['message']);return _0x43a2ed(_0x4c0bd2[_0x1a5c('0x10')][_0x1a5c('0x12')]);}else{logger[_0x1a5c('0xb')](_0x1a5c('0xc'),_0x580a2e,'request\x20sent');_0x43a2ed(_0x4c0bd2[_0x1a5c('0x13')]['message']);}})[_0x1a5c('0x14')](function(_0x44648a){logger[_0x1a5c('0x10')]('ZohoAccount,\x20%s,\x20%s',_0x580a2e,_0x44648a);_0x1702ce(_0x44648a);});});}exports['GetZohoAccount']=function(_0x32e177){var _0x2e6a6f=this;return new Promise(function(_0x18551c,_0xe376f4){return db[_0x1a5c('0x15')]['findAll']({'raw':_0x32e177[_0x1a5c('0x16')]?_0x32e177['options'][_0x1a5c('0x17')]===undefined?!![]:![]:!![],'where':_0x32e177[_0x1a5c('0x16')]?_0x32e177[_0x1a5c('0x16')]['where']||null:null,'attributes':_0x32e177[_0x1a5c('0x16')]?_0x32e177[_0x1a5c('0x16')][_0x1a5c('0x18')]||null:null,'limit':_0x32e177[_0x1a5c('0x16')]?_0x32e177[_0x1a5c('0x16')]['limit']||null:null,'include':_0x32e177[_0x1a5c('0x16')]?_0x32e177[_0x1a5c('0x16')][_0x1a5c('0x19')]?_[_0x1a5c('0x1a')](_0x32e177[_0x1a5c('0x16')][_0x1a5c('0x19')],function(_0x1991f6){return{'model':db[_0x1991f6[_0x1a5c('0x1b')]],'as':_0x1991f6['as'],'attributes':_0x1991f6[_0x1a5c('0x18')],'include':_0x1991f6[_0x1a5c('0x19')]?_[_0x1a5c('0x1a')](_0x1991f6[_0x1a5c('0x19')],function(_0x4c6520){return{'model':db[_0x4c6520[_0x1a5c('0x1b')]],'as':_0x4c6520['as'],'attributes':_0x4c6520['attributes'],'include':_0x4c6520[_0x1a5c('0x19')]?_['map'](_0x4c6520[_0x1a5c('0x19')],function(_0x4323f8){return{'model':db[_0x4323f8[_0x1a5c('0x1b')]],'as':_0x4323f8['as'],'attributes':_0x4323f8[_0x1a5c('0x18')]};}):[]};}):[]};}):[]:[]})[_0x1a5c('0xa')](function(_0x1e5e87){logger[_0x1a5c('0xb')](_0x1a5c('0x1c'),_0x32e177);logger[_0x1a5c('0xd')](_0x1a5c('0x1c'),_0x32e177,JSON[_0x1a5c('0xf')](_0x1e5e87));_0x18551c(_0x1e5e87);})['catch'](function(_0x25950b){logger[_0x1a5c('0x10')](_0x1a5c('0x1c'),_0x25950b[_0x1a5c('0x12')],_0x32e177);_0xe376f4(_0x2e6a6f[_0x1a5c('0x10')](0x1f4,_0x25950b[_0x1a5c('0x12')]));});});};exports[_0x1a5c('0x1d')]=function(_0x1a2bec){var _0xb97acb=this;return new Promise(function(_0x523dfb,_0x243c0c){return db[_0x1a5c('0x15')][_0x1a5c('0x1e')]({'raw':_0x1a2bec[_0x1a5c('0x16')]?_0x1a2bec['options'][_0x1a5c('0x17')]===undefined?!![]:![]:!![],'where':_0x1a2bec[_0x1a5c('0x16')]?_0x1a2bec[_0x1a5c('0x16')][_0x1a5c('0x1f')]||null:null,'attributes':_0x1a2bec[_0x1a5c('0x16')]?_0x1a2bec[_0x1a5c('0x16')][_0x1a5c('0x18')]||null:null,'include':_0x1a2bec['options']?_0x1a2bec[_0x1a5c('0x16')][_0x1a5c('0x19')]?_['map'](_0x1a2bec[_0x1a5c('0x16')][_0x1a5c('0x19')],function(_0xdd89f2){return{'model':db[_0xdd89f2[_0x1a5c('0x1b')]],'as':_0xdd89f2['as'],'attributes':_0xdd89f2['attributes'],'include':_0xdd89f2[_0x1a5c('0x19')]?_[_0x1a5c('0x1a')](_0xdd89f2['include'],function(_0x1f957a){return{'model':db[_0x1f957a[_0x1a5c('0x1b')]],'as':_0x1f957a['as'],'attributes':_0x1f957a[_0x1a5c('0x18')],'include':_0x1f957a[_0x1a5c('0x19')]?_[_0x1a5c('0x1a')](_0x1f957a[_0x1a5c('0x19')],function(_0x38e8cb){return{'model':db[_0x38e8cb[_0x1a5c('0x1b')]],'as':_0x38e8cb['as'],'attributes':_0x38e8cb[_0x1a5c('0x18')]};}):[]};}):[]};}):[]:[]})[_0x1a5c('0xa')](function(_0x515780){logger[_0x1a5c('0xb')](_0x1a5c('0x1d'),_0x1a2bec);logger['debug'](_0x1a5c('0x1d'),_0x1a2bec,JSON[_0x1a5c('0xf')](_0x515780));_0x523dfb(_0x515780);})['catch'](function(_0x4abca8){logger[_0x1a5c('0x10')](_0x1a5c('0x1d'),_0x4abca8[_0x1a5c('0x12')],_0x1a2bec);_0x243c0c(_0xb97acb[_0x1a5c('0x10')](0x1f4,_0x4abca8['message']));});});};