5471532911b842e5cc8a28b372a2b06fe4499cf5
[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 _0x0954=['ZohoAccount','options','raw','attributes','limit','include','map','model','then','find','ShowZohoAccount','stringify','lodash','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','request','info','ZohoAccount,\x20%s,\x20%s','debug','ZohoAccount,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','result','catch','GetZohoAccount'];(function(_0x1d8fa1,_0x18d00f){var _0x528467=function(_0x259e18){while(--_0x259e18){_0x1d8fa1['push'](_0x1d8fa1['shift']());}};_0x528467(++_0x18d00f);}(_0x0954,0x135));var _0x4095=function(_0x454165,_0x1f3e74){_0x454165=_0x454165-0x0;var _0x56db53=_0x0954[_0x454165];return _0x56db53;};'use strict';var _=require(_0x4095('0x0'));var util=require('util');var moment=require(_0x4095('0x1'));var BPromise=require(_0x4095('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x4095('0x3'));var db=require(_0x4095('0x4'))['db'];var utils=require(_0x4095('0x5'));var logger=require(_0x4095('0x6'))(_0x4095('0x7'));var config=require(_0x4095('0x8'));var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x14b440,_0x352c8f,_0x1cf027){return new BPromise(function(_0x1440af,_0x24adfd){return client[_0x4095('0x9')](_0x14b440,_0x1cf027)['then'](function(_0x158dc7){logger[_0x4095('0xa')](_0x4095('0xb'),_0x352c8f,'request\x20sent');logger[_0x4095('0xc')](_0x4095('0xd'),_0x352c8f,_0x4095('0xe'),JSON['stringify'](_0x158dc7));if(_0x158dc7[_0x4095('0xf')]){if(_0x158dc7['error'][_0x4095('0x10')]===0x1f4){logger['error'](_0x4095('0xb'),_0x352c8f,_0x158dc7[_0x4095('0xf')][_0x4095('0x11')]);return _0x24adfd(_0x158dc7['error']['message']);}logger[_0x4095('0xf')](_0x4095('0xb'),_0x352c8f,_0x158dc7[_0x4095('0xf')][_0x4095('0x11')]);return _0x1440af(_0x158dc7['error']['message']);}else{logger[_0x4095('0xa')](_0x4095('0xb'),_0x352c8f,_0x4095('0xe'));_0x1440af(_0x158dc7[_0x4095('0x12')][_0x4095('0x11')]);}})[_0x4095('0x13')](function(_0x50c8c0){logger['error'](_0x4095('0xb'),_0x352c8f,_0x50c8c0);_0x24adfd(_0x50c8c0);});});}exports[_0x4095('0x14')]=function(_0x47ebf5){var _0x52d4d1=this;return new Promise(function(_0x5c3503,_0x59e95b){return db[_0x4095('0x15')]['findAll']({'raw':_0x47ebf5[_0x4095('0x16')]?_0x47ebf5[_0x4095('0x16')][_0x4095('0x17')]===undefined?!![]:![]:!![],'where':_0x47ebf5[_0x4095('0x16')]?_0x47ebf5['options']['where']||null:null,'attributes':_0x47ebf5[_0x4095('0x16')]?_0x47ebf5[_0x4095('0x16')][_0x4095('0x18')]||null:null,'limit':_0x47ebf5[_0x4095('0x16')]?_0x47ebf5[_0x4095('0x16')][_0x4095('0x19')]||null:null,'include':_0x47ebf5[_0x4095('0x16')]?_0x47ebf5[_0x4095('0x16')][_0x4095('0x1a')]?_[_0x4095('0x1b')](_0x47ebf5[_0x4095('0x16')][_0x4095('0x1a')],function(_0x440631){return{'model':db[_0x440631[_0x4095('0x1c')]],'as':_0x440631['as'],'attributes':_0x440631['attributes'],'include':_0x440631['include']?_[_0x4095('0x1b')](_0x440631[_0x4095('0x1a')],function(_0x26604f){return{'model':db[_0x26604f['model']],'as':_0x26604f['as'],'attributes':_0x26604f['attributes'],'include':_0x26604f[_0x4095('0x1a')]?_[_0x4095('0x1b')](_0x26604f[_0x4095('0x1a')],function(_0xbe5842){return{'model':db[_0xbe5842[_0x4095('0x1c')]],'as':_0xbe5842['as'],'attributes':_0xbe5842['attributes']};}):[]};}):[]};}):[]:[]})[_0x4095('0x1d')](function(_0xf87fd4){logger[_0x4095('0xa')](_0x4095('0x14'),_0x47ebf5);logger['debug'](_0x4095('0x14'),_0x47ebf5,JSON['stringify'](_0xf87fd4));_0x5c3503(_0xf87fd4);})['catch'](function(_0x199b7d){logger[_0x4095('0xf')](_0x4095('0x14'),_0x199b7d[_0x4095('0x11')],_0x47ebf5);_0x59e95b(_0x52d4d1['error'](0x1f4,_0x199b7d[_0x4095('0x11')]));});});};exports['ShowZohoAccount']=function(_0x347df8){var _0x3f2516=this;return new Promise(function(_0x4eb0ab,_0x3c49c0){return db[_0x4095('0x15')][_0x4095('0x1e')]({'raw':_0x347df8[_0x4095('0x16')]?_0x347df8[_0x4095('0x16')][_0x4095('0x17')]===undefined?!![]:![]:!![],'where':_0x347df8[_0x4095('0x16')]?_0x347df8[_0x4095('0x16')]['where']||null:null,'attributes':_0x347df8[_0x4095('0x16')]?_0x347df8['options'][_0x4095('0x18')]||null:null,'include':_0x347df8[_0x4095('0x16')]?_0x347df8['options'][_0x4095('0x1a')]?_[_0x4095('0x1b')](_0x347df8[_0x4095('0x16')][_0x4095('0x1a')],function(_0x31834d){return{'model':db[_0x31834d[_0x4095('0x1c')]],'as':_0x31834d['as'],'attributes':_0x31834d[_0x4095('0x18')],'include':_0x31834d[_0x4095('0x1a')]?_[_0x4095('0x1b')](_0x31834d['include'],function(_0x336e22){return{'model':db[_0x336e22[_0x4095('0x1c')]],'as':_0x336e22['as'],'attributes':_0x336e22['attributes'],'include':_0x336e22[_0x4095('0x1a')]?_['map'](_0x336e22['include'],function(_0x27dceb){return{'model':db[_0x27dceb[_0x4095('0x1c')]],'as':_0x27dceb['as'],'attributes':_0x27dceb[_0x4095('0x18')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x53b9e8){logger[_0x4095('0xa')](_0x4095('0x1f'),_0x347df8);logger[_0x4095('0xc')]('ShowZohoAccount',_0x347df8,JSON[_0x4095('0x20')](_0x53b9e8));_0x4eb0ab(_0x53b9e8);})[_0x4095('0x13')](function(_0x1375e7){logger[_0x4095('0xf')](_0x4095('0x1f'),_0x1375e7[_0x4095('0x11')],_0x347df8);_0x3c49c0(_0x3f2516[_0x4095('0xf')](0x1f4,_0x1375e7[_0x4095('0x11')]));});});};