Built motion from commit (unavailable).|2.5.31
[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 _0x4136=['debug','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','ZohoAccount','findAll','options','where','limit','include','map','attributes','model','then','GetZohoAccount','ShowZohoAccount','find','raw','util','moment','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','request','info','ZohoAccount,\x20%s,\x20%s','request\x20sent'];(function(_0x282a1e,_0x4dd4db){var _0x460b6c=function(_0xe99af3){while(--_0xe99af3){_0x282a1e['push'](_0x282a1e['shift']());}};_0x460b6c(++_0x4dd4db);}(_0x4136,0x151));var _0x6413=function(_0x12a89f,_0xea0e56){_0x12a89f=_0x12a89f-0x0;var _0x4cb82a=_0x4136[_0x12a89f];return _0x4cb82a;};'use strict';var _=require('lodash');var util=require(_0x6413('0x0'));var moment=require(_0x6413('0x1'));var BPromise=require('bluebird');var rs=require(_0x6413('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x6413('0x3'))['db'];var utils=require(_0x6413('0x4'));var logger=require('../../config/logger')(_0x6413('0x5'));var config=require(_0x6413('0x6'));var jayson=require(_0x6413('0x7'));var client=jayson[_0x6413('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x25555e,_0x387e9e,_0x4c853e){return new BPromise(function(_0x2867da,_0x56170d){return client[_0x6413('0x9')](_0x25555e,_0x4c853e)['then'](function(_0x243bac){logger[_0x6413('0xa')](_0x6413('0xb'),_0x387e9e,_0x6413('0xc'));logger[_0x6413('0xd')](_0x6413('0xe'),_0x387e9e,_0x6413('0xc'),JSON[_0x6413('0xf')](_0x243bac));if(_0x243bac[_0x6413('0x10')]){if(_0x243bac['error'][_0x6413('0x11')]===0x1f4){logger[_0x6413('0x10')](_0x6413('0xb'),_0x387e9e,_0x243bac[_0x6413('0x10')][_0x6413('0x12')]);return _0x56170d(_0x243bac['error'][_0x6413('0x12')]);}logger[_0x6413('0x10')]('ZohoAccount,\x20%s,\x20%s',_0x387e9e,_0x243bac[_0x6413('0x10')][_0x6413('0x12')]);return _0x2867da(_0x243bac[_0x6413('0x10')][_0x6413('0x12')]);}else{logger[_0x6413('0xa')](_0x6413('0xb'),_0x387e9e,_0x6413('0xc'));_0x2867da(_0x243bac[_0x6413('0x13')][_0x6413('0x12')]);}})[_0x6413('0x14')](function(_0x157661){logger[_0x6413('0x10')]('ZohoAccount,\x20%s,\x20%s',_0x387e9e,_0x157661);_0x56170d(_0x157661);});});}exports['GetZohoAccount']=function(_0x4201c4){var _0x5647e1=this;return new Promise(function(_0x2fb5a8,_0xf6e228){return db[_0x6413('0x15')][_0x6413('0x16')]({'raw':_0x4201c4[_0x6413('0x17')]?_0x4201c4[_0x6413('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x4201c4[_0x6413('0x17')]?_0x4201c4[_0x6413('0x17')][_0x6413('0x18')]||null:null,'attributes':_0x4201c4[_0x6413('0x17')]?_0x4201c4[_0x6413('0x17')]['attributes']||null:null,'limit':_0x4201c4[_0x6413('0x17')]?_0x4201c4['options'][_0x6413('0x19')]||null:null,'include':_0x4201c4[_0x6413('0x17')]?_0x4201c4[_0x6413('0x17')][_0x6413('0x1a')]?_[_0x6413('0x1b')](_0x4201c4[_0x6413('0x17')][_0x6413('0x1a')],function(_0xd21a16){return{'model':db[_0xd21a16['model']],'as':_0xd21a16['as'],'attributes':_0xd21a16[_0x6413('0x1c')],'include':_0xd21a16['include']?_['map'](_0xd21a16['include'],function(_0x48c22e){return{'model':db[_0x48c22e[_0x6413('0x1d')]],'as':_0x48c22e['as'],'attributes':_0x48c22e[_0x6413('0x1c')],'include':_0x48c22e['include']?_['map'](_0x48c22e['include'],function(_0xf98efe){return{'model':db[_0xf98efe[_0x6413('0x1d')]],'as':_0xf98efe['as'],'attributes':_0xf98efe[_0x6413('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x6413('0x1e')](function(_0x415445){logger[_0x6413('0xa')](_0x6413('0x1f'),_0x4201c4);logger[_0x6413('0xd')](_0x6413('0x1f'),_0x4201c4,JSON[_0x6413('0xf')](_0x415445));_0x2fb5a8(_0x415445);})['catch'](function(_0xc9942e){logger[_0x6413('0x10')](_0x6413('0x1f'),_0xc9942e['message'],_0x4201c4);_0xf6e228(_0x5647e1[_0x6413('0x10')](0x1f4,_0xc9942e[_0x6413('0x12')]));});});};exports[_0x6413('0x20')]=function(_0x5793e3){var _0x17df43=this;return new Promise(function(_0x5f4b91,_0xfe73c3){return db['ZohoAccount'][_0x6413('0x21')]({'raw':_0x5793e3[_0x6413('0x17')]?_0x5793e3['options'][_0x6413('0x22')]===undefined?!![]:![]:!![],'where':_0x5793e3[_0x6413('0x17')]?_0x5793e3[_0x6413('0x17')]['where']||null:null,'attributes':_0x5793e3['options']?_0x5793e3[_0x6413('0x17')][_0x6413('0x1c')]||null:null,'include':_0x5793e3[_0x6413('0x17')]?_0x5793e3['options']['include']?_[_0x6413('0x1b')](_0x5793e3[_0x6413('0x17')][_0x6413('0x1a')],function(_0x442807){return{'model':db[_0x442807[_0x6413('0x1d')]],'as':_0x442807['as'],'attributes':_0x442807[_0x6413('0x1c')],'include':_0x442807['include']?_[_0x6413('0x1b')](_0x442807[_0x6413('0x1a')],function(_0x27590c){return{'model':db[_0x27590c['model']],'as':_0x27590c['as'],'attributes':_0x27590c[_0x6413('0x1c')],'include':_0x27590c[_0x6413('0x1a')]?_[_0x6413('0x1b')](_0x27590c[_0x6413('0x1a')],function(_0x342a9d){return{'model':db[_0x342a9d['model']],'as':_0x342a9d['as'],'attributes':_0x342a9d[_0x6413('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x6413('0x1e')](function(_0x2ded43){logger[_0x6413('0xa')](_0x6413('0x20'),_0x5793e3);logger[_0x6413('0xd')](_0x6413('0x20'),_0x5793e3,JSON[_0x6413('0xf')](_0x2ded43));_0x5f4b91(_0x2ded43);})[_0x6413('0x14')](function(_0x4c5a3e){logger['error'](_0x6413('0x20'),_0x4c5a3e[_0x6413('0x12')],_0x5793e3);_0xfe73c3(_0x17df43['error'](0x1f4,_0x4c5a3e[_0x6413('0x12')]));});});};