Built motion from commit (unavailable).|2.4.4
[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 _0x6b9d=['jayson/promise','client','http','request','then','ZohoAccount,\x20%s,\x20%s','debug','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','request\x20sent','result','catch','GetZohoAccount','ZohoAccount','findAll','options','where','limit','map','model','attributes','include','ShowZohoAccount','find','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x14e5ac,_0x2e308d){var _0x46a9f8=function(_0x52dd2f){while(--_0x52dd2f){_0x14e5ac['push'](_0x14e5ac['shift']());}};_0x46a9f8(++_0x2e308d);}(_0x6b9d,0x1e4));var _0xd6b9=function(_0x121886,_0x8cd8e5){_0x121886=_0x121886-0x0;var _0x20ca01=_0x6b9d[_0x121886];return _0x20ca01;};'use strict';var _=require(_0xd6b9('0x0'));var util=require(_0xd6b9('0x1'));var moment=require(_0xd6b9('0x2'));var BPromise=require(_0xd6b9('0x3'));var rs=require(_0xd6b9('0x4'));var fs=require('fs');var Redis=require(_0xd6b9('0x5'));var db=require(_0xd6b9('0x6'))['db'];var utils=require(_0xd6b9('0x7'));var logger=require(_0xd6b9('0x8'))(_0xd6b9('0x9'));var config=require('../../config/environment');var jayson=require(_0xd6b9('0xa'));var client=jayson[_0xd6b9('0xb')][_0xd6b9('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x1b4f81,_0xcd8090,_0x38e9b4){return new BPromise(function(_0x11214c,_0x3eae1d){return client[_0xd6b9('0xd')](_0x1b4f81,_0x38e9b4)[_0xd6b9('0xe')](function(_0xfbf329){logger['info'](_0xd6b9('0xf'),_0xcd8090,'request\x20sent');logger[_0xd6b9('0x10')](_0xd6b9('0x11'),_0xcd8090,'request\x20sent',JSON[_0xd6b9('0x12')](_0xfbf329));if(_0xfbf329[_0xd6b9('0x13')]){if(_0xfbf329[_0xd6b9('0x13')][_0xd6b9('0x14')]===0x1f4){logger['error'](_0xd6b9('0xf'),_0xcd8090,_0xfbf329[_0xd6b9('0x13')][_0xd6b9('0x15')]);return _0x3eae1d(_0xfbf329[_0xd6b9('0x13')][_0xd6b9('0x15')]);}logger[_0xd6b9('0x13')]('ZohoAccount,\x20%s,\x20%s',_0xcd8090,_0xfbf329['error']['message']);return _0x11214c(_0xfbf329[_0xd6b9('0x13')][_0xd6b9('0x15')]);}else{logger[_0xd6b9('0x16')]('ZohoAccount,\x20%s,\x20%s',_0xcd8090,_0xd6b9('0x17'));_0x11214c(_0xfbf329[_0xd6b9('0x18')][_0xd6b9('0x15')]);}})[_0xd6b9('0x19')](function(_0x43fe92){logger['error']('ZohoAccount,\x20%s,\x20%s',_0xcd8090,_0x43fe92);_0x3eae1d(_0x43fe92);});});}exports[_0xd6b9('0x1a')]=function(_0x4f73d2){var _0x1c24d1=this;return new Promise(function(_0x412d28,_0x2299bb){return db[_0xd6b9('0x1b')][_0xd6b9('0x1c')]({'raw':_0x4f73d2['options']?_0x4f73d2[_0xd6b9('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x4f73d2[_0xd6b9('0x1d')]?_0x4f73d2[_0xd6b9('0x1d')][_0xd6b9('0x1e')]||null:null,'attributes':_0x4f73d2[_0xd6b9('0x1d')]?_0x4f73d2[_0xd6b9('0x1d')]['attributes']||null:null,'limit':_0x4f73d2[_0xd6b9('0x1d')]?_0x4f73d2['options'][_0xd6b9('0x1f')]||null:null,'include':_0x4f73d2[_0xd6b9('0x1d')]?_0x4f73d2[_0xd6b9('0x1d')]['include']?_[_0xd6b9('0x20')](_0x4f73d2[_0xd6b9('0x1d')]['include'],function(_0x21b49f){return{'model':db[_0x21b49f[_0xd6b9('0x21')]],'as':_0x21b49f['as'],'attributes':_0x21b49f[_0xd6b9('0x22')],'include':_0x21b49f[_0xd6b9('0x23')]?_[_0xd6b9('0x20')](_0x21b49f[_0xd6b9('0x23')],function(_0x178b8e){return{'model':db[_0x178b8e[_0xd6b9('0x21')]],'as':_0x178b8e['as'],'attributes':_0x178b8e[_0xd6b9('0x22')],'include':_0x178b8e[_0xd6b9('0x23')]?_['map'](_0x178b8e[_0xd6b9('0x23')],function(_0x20a650){return{'model':db[_0x20a650[_0xd6b9('0x21')]],'as':_0x20a650['as'],'attributes':_0x20a650['attributes']};}):[]};}):[]};}):[]:[]})[_0xd6b9('0xe')](function(_0x34ebf7){logger[_0xd6b9('0x16')](_0xd6b9('0x1a'),_0x4f73d2);logger[_0xd6b9('0x10')](_0xd6b9('0x1a'),_0x4f73d2,JSON['stringify'](_0x34ebf7));_0x412d28(_0x34ebf7);})[_0xd6b9('0x19')](function(_0x2ead4d){logger[_0xd6b9('0x13')](_0xd6b9('0x1a'),_0x2ead4d[_0xd6b9('0x15')],_0x4f73d2);_0x2299bb(_0x1c24d1['error'](0x1f4,_0x2ead4d[_0xd6b9('0x15')]));});});};exports[_0xd6b9('0x24')]=function(_0x2fcb15){var _0x3e363b=this;return new Promise(function(_0x1c635d,_0xa60407){return db['ZohoAccount'][_0xd6b9('0x25')]({'raw':_0x2fcb15[_0xd6b9('0x1d')]?_0x2fcb15[_0xd6b9('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x2fcb15['options']?_0x2fcb15['options'][_0xd6b9('0x1e')]||null:null,'attributes':_0x2fcb15[_0xd6b9('0x1d')]?_0x2fcb15[_0xd6b9('0x1d')][_0xd6b9('0x22')]||null:null,'include':_0x2fcb15[_0xd6b9('0x1d')]?_0x2fcb15['options']['include']?_[_0xd6b9('0x20')](_0x2fcb15['options'][_0xd6b9('0x23')],function(_0x2e97bb){return{'model':db[_0x2e97bb[_0xd6b9('0x21')]],'as':_0x2e97bb['as'],'attributes':_0x2e97bb['attributes'],'include':_0x2e97bb['include']?_[_0xd6b9('0x20')](_0x2e97bb[_0xd6b9('0x23')],function(_0x2d9dee){return{'model':db[_0x2d9dee[_0xd6b9('0x21')]],'as':_0x2d9dee['as'],'attributes':_0x2d9dee[_0xd6b9('0x22')],'include':_0x2d9dee[_0xd6b9('0x23')]?_['map'](_0x2d9dee[_0xd6b9('0x23')],function(_0x44eb2b){return{'model':db[_0x44eb2b[_0xd6b9('0x21')]],'as':_0x44eb2b['as'],'attributes':_0x44eb2b[_0xd6b9('0x22')]};}):[]};}):[]};}):[]:[]})[_0xd6b9('0xe')](function(_0x3f7f4e){logger['info'](_0xd6b9('0x24'),_0x2fcb15);logger[_0xd6b9('0x10')]('ShowZohoAccount',_0x2fcb15,JSON[_0xd6b9('0x12')](_0x3f7f4e));_0x1c635d(_0x3f7f4e);})['catch'](function(_0x205995){logger['error']('ShowZohoAccount',_0x205995['message'],_0x2fcb15);_0xa60407(_0x3e363b[_0xd6b9('0x13')](0x1f4,_0x205995[_0xd6b9('0x15')]));});});};