7b23683a10dd803c2f80c979a731cf64334eb117
[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 _0x6b1b=['../../config/environment','jayson/promise','client','http','then','info','request\x20sent','stringify','error','ZohoAccount,\x20%s,\x20%s','message','catch','GetZohoAccount','ZohoAccount','findAll','options','raw','where','include','map','model','attributes','debug','ShowZohoAccount','find','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x58b5b0,_0x599f81){var _0x1463ab=function(_0x2f29d7){while(--_0x2f29d7){_0x58b5b0['push'](_0x58b5b0['shift']());}};_0x1463ab(++_0x599f81);}(_0x6b1b,0x1e7));var _0xb6b1=function(_0x4baae2,_0x487ab6){_0x4baae2=_0x4baae2-0x0;var _0x1a2285=_0x6b1b[_0x4baae2];return _0x1a2285;};'use strict';var _=require('lodash');var util=require(_0xb6b1('0x0'));var moment=require(_0xb6b1('0x1'));var BPromise=require(_0xb6b1('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xb6b1('0x3'));var db=require(_0xb6b1('0x4'))['db'];var utils=require(_0xb6b1('0x5'));var logger=require(_0xb6b1('0x6'))(_0xb6b1('0x7'));var config=require(_0xb6b1('0x8'));var jayson=require(_0xb6b1('0x9'));var client=jayson[_0xb6b1('0xa')][_0xb6b1('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x13334e,_0x1a4cd0,_0x5b440a){return new BPromise(function(_0x2734cc,_0x52aa76){return client['request'](_0x13334e,_0x5b440a)[_0xb6b1('0xc')](function(_0x58027c){logger[_0xb6b1('0xd')]('ZohoAccount,\x20%s,\x20%s',_0x1a4cd0,'request\x20sent');logger['debug']('ZohoAccount,\x20%s,\x20%s,\x20%s',_0x1a4cd0,_0xb6b1('0xe'),JSON[_0xb6b1('0xf')](_0x58027c));if(_0x58027c['error']){if(_0x58027c[_0xb6b1('0x10')]['code']===0x1f4){logger['error'](_0xb6b1('0x11'),_0x1a4cd0,_0x58027c[_0xb6b1('0x10')][_0xb6b1('0x12')]);return _0x52aa76(_0x58027c[_0xb6b1('0x10')][_0xb6b1('0x12')]);}logger[_0xb6b1('0x10')](_0xb6b1('0x11'),_0x1a4cd0,_0x58027c[_0xb6b1('0x10')][_0xb6b1('0x12')]);return _0x2734cc(_0x58027c[_0xb6b1('0x10')][_0xb6b1('0x12')]);}else{logger[_0xb6b1('0xd')]('ZohoAccount,\x20%s,\x20%s',_0x1a4cd0,'request\x20sent');_0x2734cc(_0x58027c['result']['message']);}})[_0xb6b1('0x13')](function(_0x12c595){logger[_0xb6b1('0x10')](_0xb6b1('0x11'),_0x1a4cd0,_0x12c595);_0x52aa76(_0x12c595);});});}exports[_0xb6b1('0x14')]=function(_0x51fb33){var _0x47a204=this;return new Promise(function(_0x581e28,_0x1bdf63){return db[_0xb6b1('0x15')][_0xb6b1('0x16')]({'raw':_0x51fb33[_0xb6b1('0x17')]?_0x51fb33[_0xb6b1('0x17')][_0xb6b1('0x18')]===undefined?!![]:![]:!![],'where':_0x51fb33['options']?_0x51fb33['options'][_0xb6b1('0x19')]||null:null,'attributes':_0x51fb33[_0xb6b1('0x17')]?_0x51fb33['options']['attributes']||null:null,'limit':_0x51fb33[_0xb6b1('0x17')]?_0x51fb33['options']['limit']||null:null,'include':_0x51fb33[_0xb6b1('0x17')]?_0x51fb33[_0xb6b1('0x17')][_0xb6b1('0x1a')]?_[_0xb6b1('0x1b')](_0x51fb33[_0xb6b1('0x17')][_0xb6b1('0x1a')],function(_0x1eb1b2){return{'model':db[_0x1eb1b2[_0xb6b1('0x1c')]],'as':_0x1eb1b2['as'],'attributes':_0x1eb1b2[_0xb6b1('0x1d')],'include':_0x1eb1b2[_0xb6b1('0x1a')]?_['map'](_0x1eb1b2[_0xb6b1('0x1a')],function(_0x4f1e2e){return{'model':db[_0x4f1e2e[_0xb6b1('0x1c')]],'as':_0x4f1e2e['as'],'attributes':_0x4f1e2e['attributes'],'include':_0x4f1e2e[_0xb6b1('0x1a')]?_['map'](_0x4f1e2e[_0xb6b1('0x1a')],function(_0x387603){return{'model':db[_0x387603[_0xb6b1('0x1c')]],'as':_0x387603['as'],'attributes':_0x387603[_0xb6b1('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xb6b1('0xc')](function(_0x188627){logger[_0xb6b1('0xd')](_0xb6b1('0x14'),_0x51fb33);logger[_0xb6b1('0x1e')]('GetZohoAccount',_0x51fb33,JSON[_0xb6b1('0xf')](_0x188627));_0x581e28(_0x188627);})['catch'](function(_0x427efb){logger[_0xb6b1('0x10')](_0xb6b1('0x14'),_0x427efb[_0xb6b1('0x12')],_0x51fb33);_0x1bdf63(_0x47a204[_0xb6b1('0x10')](0x1f4,_0x427efb[_0xb6b1('0x12')]));});});};exports[_0xb6b1('0x1f')]=function(_0x59094f){var _0x427797=this;return new Promise(function(_0x2ccd37,_0x1791a2){return db['ZohoAccount'][_0xb6b1('0x20')]({'raw':_0x59094f[_0xb6b1('0x17')]?_0x59094f['options'][_0xb6b1('0x18')]===undefined?!![]:![]:!![],'where':_0x59094f[_0xb6b1('0x17')]?_0x59094f[_0xb6b1('0x17')][_0xb6b1('0x19')]||null:null,'attributes':_0x59094f[_0xb6b1('0x17')]?_0x59094f[_0xb6b1('0x17')]['attributes']||null:null,'include':_0x59094f[_0xb6b1('0x17')]?_0x59094f[_0xb6b1('0x17')]['include']?_[_0xb6b1('0x1b')](_0x59094f['options'][_0xb6b1('0x1a')],function(_0x242ec3){return{'model':db[_0x242ec3[_0xb6b1('0x1c')]],'as':_0x242ec3['as'],'attributes':_0x242ec3[_0xb6b1('0x1d')],'include':_0x242ec3[_0xb6b1('0x1a')]?_[_0xb6b1('0x1b')](_0x242ec3['include'],function(_0x203d8e){return{'model':db[_0x203d8e[_0xb6b1('0x1c')]],'as':_0x203d8e['as'],'attributes':_0x203d8e[_0xb6b1('0x1d')],'include':_0x203d8e[_0xb6b1('0x1a')]?_['map'](_0x203d8e['include'],function(_0x4b9125){return{'model':db[_0x4b9125[_0xb6b1('0x1c')]],'as':_0x4b9125['as'],'attributes':_0x4b9125[_0xb6b1('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xb6b1('0xc')](function(_0xe9cc){logger[_0xb6b1('0xd')](_0xb6b1('0x1f'),_0x59094f);logger[_0xb6b1('0x1e')](_0xb6b1('0x1f'),_0x59094f,JSON[_0xb6b1('0xf')](_0xe9cc));_0x2ccd37(_0xe9cc);})[_0xb6b1('0x13')](function(_0x9abbe1){logger[_0xb6b1('0x10')]('ShowZohoAccount',_0x9abbe1[_0xb6b1('0x12')],_0x59094f);_0x1791a2(_0x427797[_0xb6b1('0x10')](0x1f4,_0x9abbe1[_0xb6b1('0x12')]));});});};