Built motion from commit (unavailable).|2.3.98
[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 _0x9cbe=['model','GetZohoAccount','ShowZohoAccount','find','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','then','info','ZohoAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','ZohoAccount','findAll','options','raw','where','attributes','limit','map','include'];(function(_0x4b2436,_0x452299){var _0x4f5ab2=function(_0x5c6679){while(--_0x5c6679){_0x4b2436['push'](_0x4b2436['shift']());}};_0x4f5ab2(++_0x452299);}(_0x9cbe,0x114));var _0xe9cb=function(_0x17406a,_0x1e2320){_0x17406a=_0x17406a-0x0;var _0x1501ff=_0x9cbe[_0x17406a];return _0x1501ff;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require(_0xe9cb('0x0'));var rs=require(_0xe9cb('0x1'));var fs=require('fs');var Redis=require(_0xe9cb('0x2'));var db=require(_0xe9cb('0x3'))['db'];var utils=require(_0xe9cb('0x4'));var logger=require(_0xe9cb('0x5'))('rpc');var config=require(_0xe9cb('0x6'));var jayson=require(_0xe9cb('0x7'));var client=jayson[_0xe9cb('0x8')][_0xe9cb('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x404615,_0x7894ea,_0x32d7a9){return new BPromise(function(_0x2493b5,_0x3fcde0){return client['request'](_0x404615,_0x32d7a9)[_0xe9cb('0xa')](function(_0x34c371){logger[_0xe9cb('0xb')](_0xe9cb('0xc'),_0x7894ea,_0xe9cb('0xd'));logger[_0xe9cb('0xe')]('ZohoAccount,\x20%s,\x20%s,\x20%s',_0x7894ea,_0xe9cb('0xd'),JSON[_0xe9cb('0xf')](_0x34c371));if(_0x34c371[_0xe9cb('0x10')]){if(_0x34c371[_0xe9cb('0x10')][_0xe9cb('0x11')]===0x1f4){logger['error'](_0xe9cb('0xc'),_0x7894ea,_0x34c371[_0xe9cb('0x10')][_0xe9cb('0x12')]);return _0x3fcde0(_0x34c371[_0xe9cb('0x10')][_0xe9cb('0x12')]);}logger[_0xe9cb('0x10')](_0xe9cb('0xc'),_0x7894ea,_0x34c371[_0xe9cb('0x10')][_0xe9cb('0x12')]);return _0x2493b5(_0x34c371['error'][_0xe9cb('0x12')]);}else{logger[_0xe9cb('0xb')]('ZohoAccount,\x20%s,\x20%s',_0x7894ea,_0xe9cb('0xd'));_0x2493b5(_0x34c371[_0xe9cb('0x13')][_0xe9cb('0x12')]);}})[_0xe9cb('0x14')](function(_0x488175){logger[_0xe9cb('0x10')]('ZohoAccount,\x20%s,\x20%s',_0x7894ea,_0x488175);_0x3fcde0(_0x488175);});});}exports['GetZohoAccount']=function(_0x3500c1){var _0x5abd27=this;return new Promise(function(_0x2f7b89,_0x2c0dbd){return db[_0xe9cb('0x15')][_0xe9cb('0x16')]({'raw':_0x3500c1[_0xe9cb('0x17')]?_0x3500c1[_0xe9cb('0x17')][_0xe9cb('0x18')]===undefined?!![]:![]:!![],'where':_0x3500c1[_0xe9cb('0x17')]?_0x3500c1[_0xe9cb('0x17')][_0xe9cb('0x19')]||null:null,'attributes':_0x3500c1[_0xe9cb('0x17')]?_0x3500c1[_0xe9cb('0x17')][_0xe9cb('0x1a')]||null:null,'limit':_0x3500c1['options']?_0x3500c1['options'][_0xe9cb('0x1b')]||null:null,'include':_0x3500c1[_0xe9cb('0x17')]?_0x3500c1[_0xe9cb('0x17')]['include']?_[_0xe9cb('0x1c')](_0x3500c1[_0xe9cb('0x17')][_0xe9cb('0x1d')],function(_0x433696){return{'model':db[_0x433696[_0xe9cb('0x1e')]],'as':_0x433696['as'],'attributes':_0x433696[_0xe9cb('0x1a')],'include':_0x433696[_0xe9cb('0x1d')]?_[_0xe9cb('0x1c')](_0x433696['include'],function(_0x140c56){return{'model':db[_0x140c56[_0xe9cb('0x1e')]],'as':_0x140c56['as'],'attributes':_0x140c56[_0xe9cb('0x1a')],'include':_0x140c56[_0xe9cb('0x1d')]?_['map'](_0x140c56[_0xe9cb('0x1d')],function(_0x3a20f4){return{'model':db[_0x3a20f4[_0xe9cb('0x1e')]],'as':_0x3a20f4['as'],'attributes':_0x3a20f4['attributes']};}):[]};}):[]};}):[]:[]})[_0xe9cb('0xa')](function(_0x193a14){logger[_0xe9cb('0xb')](_0xe9cb('0x1f'),_0x3500c1);logger[_0xe9cb('0xe')](_0xe9cb('0x1f'),_0x3500c1,JSON[_0xe9cb('0xf')](_0x193a14));_0x2f7b89(_0x193a14);})[_0xe9cb('0x14')](function(_0x29b0e3){logger[_0xe9cb('0x10')]('GetZohoAccount',_0x29b0e3[_0xe9cb('0x12')],_0x3500c1);_0x2c0dbd(_0x5abd27[_0xe9cb('0x10')](0x1f4,_0x29b0e3['message']));});});};exports[_0xe9cb('0x20')]=function(_0x2594c6){var _0x11cb2d=this;return new Promise(function(_0x52a7dc,_0x4c81e1){return db[_0xe9cb('0x15')][_0xe9cb('0x21')]({'raw':_0x2594c6[_0xe9cb('0x17')]?_0x2594c6['options'][_0xe9cb('0x18')]===undefined?!![]:![]:!![],'where':_0x2594c6[_0xe9cb('0x17')]?_0x2594c6[_0xe9cb('0x17')]['where']||null:null,'attributes':_0x2594c6['options']?_0x2594c6['options'][_0xe9cb('0x1a')]||null:null,'include':_0x2594c6[_0xe9cb('0x17')]?_0x2594c6[_0xe9cb('0x17')]['include']?_[_0xe9cb('0x1c')](_0x2594c6[_0xe9cb('0x17')]['include'],function(_0x3fa4e0){return{'model':db[_0x3fa4e0[_0xe9cb('0x1e')]],'as':_0x3fa4e0['as'],'attributes':_0x3fa4e0[_0xe9cb('0x1a')],'include':_0x3fa4e0[_0xe9cb('0x1d')]?_['map'](_0x3fa4e0[_0xe9cb('0x1d')],function(_0x105b24){return{'model':db[_0x105b24[_0xe9cb('0x1e')]],'as':_0x105b24['as'],'attributes':_0x105b24[_0xe9cb('0x1a')],'include':_0x105b24[_0xe9cb('0x1d')]?_['map'](_0x105b24[_0xe9cb('0x1d')],function(_0x34c295){return{'model':db[_0x34c295[_0xe9cb('0x1e')]],'as':_0x34c295['as'],'attributes':_0x34c295[_0xe9cb('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xe9cb('0xa')](function(_0x1f4357){logger[_0xe9cb('0xb')](_0xe9cb('0x20'),_0x2594c6);logger[_0xe9cb('0xe')](_0xe9cb('0x20'),_0x2594c6,JSON[_0xe9cb('0xf')](_0x1f4357));_0x52a7dc(_0x1f4357);})[_0xe9cb('0x14')](function(_0xe1c717){logger[_0xe9cb('0x10')](_0xe9cb('0x20'),_0xe1c717[_0xe9cb('0x12')],_0x2594c6);_0x4c81e1(_0x11cb2d['error'](0x1f4,_0xe1c717[_0xe9cb('0x12')]));});});};