Built motion from commit (unavailable).|2.5.5
[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 _0xc3c2=['ShowZohoAccount','util','moment','bluebird','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','then','info','ZohoAccount,\x20%s,\x20%s','debug','ZohoAccount,\x20%s,\x20%s,\x20%s','request\x20sent','error','message','result','catch','GetZohoAccount','findAll','options','raw','where','attributes','limit','map','include','model','stringify'];(function(_0x4c8758,_0x5f2274){var _0x36bdc3=function(_0x51b490){while(--_0x51b490){_0x4c8758['push'](_0x4c8758['shift']());}};_0x36bdc3(++_0x5f2274);}(_0xc3c2,0x64));var _0x2c3c=function(_0x13ddbc,_0xefd5dc){_0x13ddbc=_0x13ddbc-0x0;var _0xc331ec=_0xc3c2[_0x13ddbc];return _0xc331ec;};'use strict';var _=require('lodash');var util=require(_0x2c3c('0x0'));var moment=require(_0x2c3c('0x1'));var BPromise=require(_0x2c3c('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x2c3c('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x2c3c('0x4'));var logger=require(_0x2c3c('0x5'))(_0x2c3c('0x6'));var config=require(_0x2c3c('0x7'));var jayson=require(_0x2c3c('0x8'));var client=jayson[_0x2c3c('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x385e51,_0x282a26,_0x171ccd){return new BPromise(function(_0xe751ea,_0x32b3a0){return client[_0x2c3c('0xa')](_0x385e51,_0x171ccd)[_0x2c3c('0xb')](function(_0xee27c2){logger[_0x2c3c('0xc')](_0x2c3c('0xd'),_0x282a26,'request\x20sent');logger[_0x2c3c('0xe')](_0x2c3c('0xf'),_0x282a26,_0x2c3c('0x10'),JSON['stringify'](_0xee27c2));if(_0xee27c2[_0x2c3c('0x11')]){if(_0xee27c2[_0x2c3c('0x11')]['code']===0x1f4){logger[_0x2c3c('0x11')](_0x2c3c('0xd'),_0x282a26,_0xee27c2[_0x2c3c('0x11')][_0x2c3c('0x12')]);return _0x32b3a0(_0xee27c2[_0x2c3c('0x11')][_0x2c3c('0x12')]);}logger[_0x2c3c('0x11')](_0x2c3c('0xd'),_0x282a26,_0xee27c2['error'][_0x2c3c('0x12')]);return _0xe751ea(_0xee27c2[_0x2c3c('0x11')][_0x2c3c('0x12')]);}else{logger[_0x2c3c('0xc')](_0x2c3c('0xd'),_0x282a26,_0x2c3c('0x10'));_0xe751ea(_0xee27c2[_0x2c3c('0x13')][_0x2c3c('0x12')]);}})[_0x2c3c('0x14')](function(_0x5e834f){logger[_0x2c3c('0x11')](_0x2c3c('0xd'),_0x282a26,_0x5e834f);_0x32b3a0(_0x5e834f);});});}exports[_0x2c3c('0x15')]=function(_0x20c033){var _0x33921e=this;return new Promise(function(_0x4e2142,_0x1db631){return db['ZohoAccount'][_0x2c3c('0x16')]({'raw':_0x20c033[_0x2c3c('0x17')]?_0x20c033[_0x2c3c('0x17')][_0x2c3c('0x18')]===undefined?!![]:![]:!![],'where':_0x20c033[_0x2c3c('0x17')]?_0x20c033[_0x2c3c('0x17')][_0x2c3c('0x19')]||null:null,'attributes':_0x20c033[_0x2c3c('0x17')]?_0x20c033[_0x2c3c('0x17')][_0x2c3c('0x1a')]||null:null,'limit':_0x20c033[_0x2c3c('0x17')]?_0x20c033['options'][_0x2c3c('0x1b')]||null:null,'include':_0x20c033[_0x2c3c('0x17')]?_0x20c033[_0x2c3c('0x17')]['include']?_[_0x2c3c('0x1c')](_0x20c033['options'][_0x2c3c('0x1d')],function(_0x478b76){return{'model':db[_0x478b76[_0x2c3c('0x1e')]],'as':_0x478b76['as'],'attributes':_0x478b76[_0x2c3c('0x1a')],'include':_0x478b76[_0x2c3c('0x1d')]?_['map'](_0x478b76[_0x2c3c('0x1d')],function(_0x578e96){return{'model':db[_0x578e96['model']],'as':_0x578e96['as'],'attributes':_0x578e96[_0x2c3c('0x1a')],'include':_0x578e96[_0x2c3c('0x1d')]?_['map'](_0x578e96['include'],function(_0x48a563){return{'model':db[_0x48a563[_0x2c3c('0x1e')]],'as':_0x48a563['as'],'attributes':_0x48a563[_0x2c3c('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x2c3c('0xb')](function(_0x2c4ce4){logger[_0x2c3c('0xc')](_0x2c3c('0x15'),_0x20c033);logger[_0x2c3c('0xe')](_0x2c3c('0x15'),_0x20c033,JSON[_0x2c3c('0x1f')](_0x2c4ce4));_0x4e2142(_0x2c4ce4);})['catch'](function(_0xf47d6e){logger['error'](_0x2c3c('0x15'),_0xf47d6e[_0x2c3c('0x12')],_0x20c033);_0x1db631(_0x33921e['error'](0x1f4,_0xf47d6e[_0x2c3c('0x12')]));});});};exports[_0x2c3c('0x20')]=function(_0x72a2e8){var _0x35d38d=this;return new Promise(function(_0x152b4c,_0x44364e){return db['ZohoAccount']['find']({'raw':_0x72a2e8[_0x2c3c('0x17')]?_0x72a2e8[_0x2c3c('0x17')][_0x2c3c('0x18')]===undefined?!![]:![]:!![],'where':_0x72a2e8[_0x2c3c('0x17')]?_0x72a2e8[_0x2c3c('0x17')][_0x2c3c('0x19')]||null:null,'attributes':_0x72a2e8['options']?_0x72a2e8[_0x2c3c('0x17')][_0x2c3c('0x1a')]||null:null,'include':_0x72a2e8['options']?_0x72a2e8[_0x2c3c('0x17')][_0x2c3c('0x1d')]?_[_0x2c3c('0x1c')](_0x72a2e8[_0x2c3c('0x17')][_0x2c3c('0x1d')],function(_0x211a2a){return{'model':db[_0x211a2a[_0x2c3c('0x1e')]],'as':_0x211a2a['as'],'attributes':_0x211a2a['attributes'],'include':_0x211a2a[_0x2c3c('0x1d')]?_['map'](_0x211a2a[_0x2c3c('0x1d')],function(_0xb0a4f2){return{'model':db[_0xb0a4f2[_0x2c3c('0x1e')]],'as':_0xb0a4f2['as'],'attributes':_0xb0a4f2[_0x2c3c('0x1a')],'include':_0xb0a4f2[_0x2c3c('0x1d')]?_[_0x2c3c('0x1c')](_0xb0a4f2[_0x2c3c('0x1d')],function(_0x5c2cdf){return{'model':db[_0x5c2cdf[_0x2c3c('0x1e')]],'as':_0x5c2cdf['as'],'attributes':_0x5c2cdf[_0x2c3c('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x2c3c('0xb')](function(_0x311734){logger[_0x2c3c('0xc')](_0x2c3c('0x20'),_0x72a2e8);logger[_0x2c3c('0xe')](_0x2c3c('0x20'),_0x72a2e8,JSON[_0x2c3c('0x1f')](_0x311734));_0x152b4c(_0x311734);})['catch'](function(_0x3bdeee){logger[_0x2c3c('0x11')](_0x2c3c('0x20'),_0x3bdeee[_0x2c3c('0x12')],_0x72a2e8);_0x44364e(_0x35d38d[_0x2c3c('0x11')](0x1f4,_0x3bdeee[_0x2c3c('0x12')]));});});};