8fe90dd7f2d77d670dc59b5aca4d337bb1767b4b
[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 _0xb4ac=['raw','options','attributes','include','model','map','GetZohoAccount','ShowZohoAccount','find','lodash','util','moment','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','http','request','then','ZohoAccount,\x20%s,\x20%s','request\x20sent','debug','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','findAll'];(function(_0x691d1e,_0x8e0815){var _0x53a0ed=function(_0x512efb){while(--_0x512efb){_0x691d1e['push'](_0x691d1e['shift']());}};_0x53a0ed(++_0x8e0815);}(_0xb4ac,0x109));var _0xcb4a=function(_0x1a22db,_0x2a2d07){_0x1a22db=_0x1a22db-0x0;var _0x5b0f2d=_0xb4ac[_0x1a22db];return _0x5b0f2d;};'use strict';var _=require(_0xcb4a('0x0'));var util=require(_0xcb4a('0x1'));var moment=require(_0xcb4a('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xcb4a('0x3'));var db=require(_0xcb4a('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xcb4a('0x5'))(_0xcb4a('0x6'));var config=require(_0xcb4a('0x7'));var jayson=require('jayson/promise');var client=jayson['client'][_0xcb4a('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x5c1feb,_0x3ae17f,_0x655380){return new BPromise(function(_0x5827e3,_0xdd4f5d){return client[_0xcb4a('0x9')](_0x5c1feb,_0x655380)[_0xcb4a('0xa')](function(_0x236390){logger['info'](_0xcb4a('0xb'),_0x3ae17f,_0xcb4a('0xc'));logger[_0xcb4a('0xd')](_0xcb4a('0xe'),_0x3ae17f,'request\x20sent',JSON[_0xcb4a('0xf')](_0x236390));if(_0x236390[_0xcb4a('0x10')]){if(_0x236390[_0xcb4a('0x10')][_0xcb4a('0x11')]===0x1f4){logger[_0xcb4a('0x10')](_0xcb4a('0xb'),_0x3ae17f,_0x236390[_0xcb4a('0x10')][_0xcb4a('0x12')]);return _0xdd4f5d(_0x236390[_0xcb4a('0x10')]['message']);}logger[_0xcb4a('0x10')](_0xcb4a('0xb'),_0x3ae17f,_0x236390['error'][_0xcb4a('0x12')]);return _0x5827e3(_0x236390[_0xcb4a('0x10')][_0xcb4a('0x12')]);}else{logger[_0xcb4a('0x13')]('ZohoAccount,\x20%s,\x20%s',_0x3ae17f,_0xcb4a('0xc'));_0x5827e3(_0x236390[_0xcb4a('0x14')][_0xcb4a('0x12')]);}})[_0xcb4a('0x15')](function(_0x1fdaa1){logger[_0xcb4a('0x10')](_0xcb4a('0xb'),_0x3ae17f,_0x1fdaa1);_0xdd4f5d(_0x1fdaa1);});});}exports['GetZohoAccount']=function(_0x55c70b){var _0x9f86a7=this;return new Promise(function(_0x3db74a,_0x43bb1e){return db['ZohoAccount'][_0xcb4a('0x16')]({'raw':_0x55c70b['options']?_0x55c70b['options'][_0xcb4a('0x17')]===undefined?!![]:![]:!![],'where':_0x55c70b[_0xcb4a('0x18')]?_0x55c70b[_0xcb4a('0x18')]['where']||null:null,'attributes':_0x55c70b[_0xcb4a('0x18')]?_0x55c70b['options'][_0xcb4a('0x19')]||null:null,'limit':_0x55c70b['options']?_0x55c70b[_0xcb4a('0x18')]['limit']||null:null,'include':_0x55c70b[_0xcb4a('0x18')]?_0x55c70b['options']['include']?_['map'](_0x55c70b['options'][_0xcb4a('0x1a')],function(_0x346879){return{'model':db[_0x346879[_0xcb4a('0x1b')]],'as':_0x346879['as'],'attributes':_0x346879[_0xcb4a('0x19')],'include':_0x346879[_0xcb4a('0x1a')]?_[_0xcb4a('0x1c')](_0x346879[_0xcb4a('0x1a')],function(_0x3b5183){return{'model':db[_0x3b5183[_0xcb4a('0x1b')]],'as':_0x3b5183['as'],'attributes':_0x3b5183['attributes'],'include':_0x3b5183[_0xcb4a('0x1a')]?_[_0xcb4a('0x1c')](_0x3b5183[_0xcb4a('0x1a')],function(_0x3b6289){return{'model':db[_0x3b6289[_0xcb4a('0x1b')]],'as':_0x3b6289['as'],'attributes':_0x3b6289[_0xcb4a('0x19')]};}):[]};}):[]};}):[]:[]})[_0xcb4a('0xa')](function(_0x1add9e){logger[_0xcb4a('0x13')](_0xcb4a('0x1d'),_0x55c70b);logger['debug'](_0xcb4a('0x1d'),_0x55c70b,JSON[_0xcb4a('0xf')](_0x1add9e));_0x3db74a(_0x1add9e);})['catch'](function(_0x21f277){logger[_0xcb4a('0x10')](_0xcb4a('0x1d'),_0x21f277[_0xcb4a('0x12')],_0x55c70b);_0x43bb1e(_0x9f86a7['error'](0x1f4,_0x21f277[_0xcb4a('0x12')]));});});};exports[_0xcb4a('0x1e')]=function(_0x5bfd70){var _0x3f3a09=this;return new Promise(function(_0x57570e,_0x103a3c){return db['ZohoAccount'][_0xcb4a('0x1f')]({'raw':_0x5bfd70[_0xcb4a('0x18')]?_0x5bfd70[_0xcb4a('0x18')][_0xcb4a('0x17')]===undefined?!![]:![]:!![],'where':_0x5bfd70[_0xcb4a('0x18')]?_0x5bfd70[_0xcb4a('0x18')]['where']||null:null,'attributes':_0x5bfd70[_0xcb4a('0x18')]?_0x5bfd70[_0xcb4a('0x18')][_0xcb4a('0x19')]||null:null,'include':_0x5bfd70[_0xcb4a('0x18')]?_0x5bfd70[_0xcb4a('0x18')]['include']?_['map'](_0x5bfd70[_0xcb4a('0x18')]['include'],function(_0xd3a293){return{'model':db[_0xd3a293[_0xcb4a('0x1b')]],'as':_0xd3a293['as'],'attributes':_0xd3a293[_0xcb4a('0x19')],'include':_0xd3a293[_0xcb4a('0x1a')]?_['map'](_0xd3a293['include'],function(_0x2f4585){return{'model':db[_0x2f4585[_0xcb4a('0x1b')]],'as':_0x2f4585['as'],'attributes':_0x2f4585[_0xcb4a('0x19')],'include':_0x2f4585[_0xcb4a('0x1a')]?_[_0xcb4a('0x1c')](_0x2f4585[_0xcb4a('0x1a')],function(_0xc39f3){return{'model':db[_0xc39f3[_0xcb4a('0x1b')]],'as':_0xc39f3['as'],'attributes':_0xc39f3[_0xcb4a('0x19')]};}):[]};}):[]};}):[]:[]})[_0xcb4a('0xa')](function(_0x20dcb6){logger['info']('ShowZohoAccount',_0x5bfd70);logger[_0xcb4a('0xd')]('ShowZohoAccount',_0x5bfd70,JSON[_0xcb4a('0xf')](_0x20dcb6));_0x57570e(_0x20dcb6);})[_0xcb4a('0x15')](function(_0x3d6253){logger['error'](_0xcb4a('0x1e'),_0x3d6253[_0xcb4a('0x12')],_0x5bfd70);_0x103a3c(_0x3f3a09[_0xcb4a('0x10')](0x1f4,_0x3d6253[_0xcb4a('0x12')]));});});};