7530618fc7a59a31d37f60e96b7e18b9244c6d24
[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 _0x363c=['attributes','limit','include','map','model','ShowZohoAccount','find','where','lodash','util','moment','bluebird','randomstring','../../mysqldb','rpc','../../config/environment','jayson/promise','client','http','request','then','info','ZohoAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','GetZohoAccount','ZohoAccount','findAll','options','raw'];(function(_0x555ebb,_0x4b1b68){var _0x3c0a4a=function(_0x312e2f){while(--_0x312e2f){_0x555ebb['push'](_0x555ebb['shift']());}};_0x3c0a4a(++_0x4b1b68);}(_0x363c,0xbc));var _0xc363=function(_0x4fff8c,_0x26caad){_0x4fff8c=_0x4fff8c-0x0;var _0x340434=_0x363c[_0x4fff8c];return _0x340434;};'use strict';var _=require(_0xc363('0x0'));var util=require(_0xc363('0x1'));var moment=require(_0xc363('0x2'));var BPromise=require(_0xc363('0x3'));var rs=require(_0xc363('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xc363('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xc363('0x6'));var config=require(_0xc363('0x7'));var jayson=require(_0xc363('0x8'));var client=jayson[_0xc363('0x9')][_0xc363('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x4f1486,_0x448021,_0x128637){return new BPromise(function(_0x47689d,_0x39d968){return client[_0xc363('0xb')](_0x4f1486,_0x128637)[_0xc363('0xc')](function(_0x6bc684){logger[_0xc363('0xd')](_0xc363('0xe'),_0x448021,_0xc363('0xf'));logger[_0xc363('0x10')]('ZohoAccount,\x20%s,\x20%s,\x20%s',_0x448021,_0xc363('0xf'),JSON[_0xc363('0x11')](_0x6bc684));if(_0x6bc684[_0xc363('0x12')]){if(_0x6bc684['error'][_0xc363('0x13')]===0x1f4){logger[_0xc363('0x12')]('ZohoAccount,\x20%s,\x20%s',_0x448021,_0x6bc684['error']['message']);return _0x39d968(_0x6bc684[_0xc363('0x12')][_0xc363('0x14')]);}logger[_0xc363('0x12')](_0xc363('0xe'),_0x448021,_0x6bc684[_0xc363('0x12')][_0xc363('0x14')]);return _0x47689d(_0x6bc684[_0xc363('0x12')][_0xc363('0x14')]);}else{logger[_0xc363('0xd')](_0xc363('0xe'),_0x448021,_0xc363('0xf'));_0x47689d(_0x6bc684[_0xc363('0x15')]['message']);}})[_0xc363('0x16')](function(_0x2a1738){logger[_0xc363('0x12')]('ZohoAccount,\x20%s,\x20%s',_0x448021,_0x2a1738);_0x39d968(_0x2a1738);});});}exports[_0xc363('0x17')]=function(_0x8a1b21){var _0x34afa1=this;return new Promise(function(_0x39f6a3,_0x5dc368){return db[_0xc363('0x18')][_0xc363('0x19')]({'raw':_0x8a1b21[_0xc363('0x1a')]?_0x8a1b21[_0xc363('0x1a')][_0xc363('0x1b')]===undefined?!![]:![]:!![],'where':_0x8a1b21[_0xc363('0x1a')]?_0x8a1b21[_0xc363('0x1a')]['where']||null:null,'attributes':_0x8a1b21['options']?_0x8a1b21[_0xc363('0x1a')][_0xc363('0x1c')]||null:null,'limit':_0x8a1b21[_0xc363('0x1a')]?_0x8a1b21[_0xc363('0x1a')][_0xc363('0x1d')]||null:null,'include':_0x8a1b21[_0xc363('0x1a')]?_0x8a1b21[_0xc363('0x1a')][_0xc363('0x1e')]?_[_0xc363('0x1f')](_0x8a1b21[_0xc363('0x1a')]['include'],function(_0x2f4db3){return{'model':db[_0x2f4db3[_0xc363('0x20')]],'as':_0x2f4db3['as'],'attributes':_0x2f4db3[_0xc363('0x1c')],'include':_0x2f4db3['include']?_['map'](_0x2f4db3[_0xc363('0x1e')],function(_0x4a44fb){return{'model':db[_0x4a44fb[_0xc363('0x20')]],'as':_0x4a44fb['as'],'attributes':_0x4a44fb[_0xc363('0x1c')],'include':_0x4a44fb[_0xc363('0x1e')]?_[_0xc363('0x1f')](_0x4a44fb['include'],function(_0x2ad053){return{'model':db[_0x2ad053[_0xc363('0x20')]],'as':_0x2ad053['as'],'attributes':_0x2ad053['attributes']};}):[]};}):[]};}):[]:[]})[_0xc363('0xc')](function(_0x1e0fc6){logger[_0xc363('0xd')](_0xc363('0x17'),_0x8a1b21);logger[_0xc363('0x10')]('GetZohoAccount',_0x8a1b21,JSON[_0xc363('0x11')](_0x1e0fc6));_0x39f6a3(_0x1e0fc6);})[_0xc363('0x16')](function(_0x119fdc){logger[_0xc363('0x12')]('GetZohoAccount',_0x119fdc[_0xc363('0x14')],_0x8a1b21);_0x5dc368(_0x34afa1['error'](0x1f4,_0x119fdc[_0xc363('0x14')]));});});};exports[_0xc363('0x21')]=function(_0x47ed05){var _0x1777f6=this;return new Promise(function(_0x2cb40c,_0x5a3bca){return db[_0xc363('0x18')][_0xc363('0x22')]({'raw':_0x47ed05[_0xc363('0x1a')]?_0x47ed05[_0xc363('0x1a')][_0xc363('0x1b')]===undefined?!![]:![]:!![],'where':_0x47ed05['options']?_0x47ed05[_0xc363('0x1a')][_0xc363('0x23')]||null:null,'attributes':_0x47ed05[_0xc363('0x1a')]?_0x47ed05[_0xc363('0x1a')]['attributes']||null:null,'include':_0x47ed05[_0xc363('0x1a')]?_0x47ed05[_0xc363('0x1a')]['include']?_[_0xc363('0x1f')](_0x47ed05[_0xc363('0x1a')]['include'],function(_0x74ed7){return{'model':db[_0x74ed7[_0xc363('0x20')]],'as':_0x74ed7['as'],'attributes':_0x74ed7['attributes'],'include':_0x74ed7[_0xc363('0x1e')]?_[_0xc363('0x1f')](_0x74ed7[_0xc363('0x1e')],function(_0x433213){return{'model':db[_0x433213['model']],'as':_0x433213['as'],'attributes':_0x433213[_0xc363('0x1c')],'include':_0x433213[_0xc363('0x1e')]?_[_0xc363('0x1f')](_0x433213['include'],function(_0x5c5f02){return{'model':db[_0x5c5f02[_0xc363('0x20')]],'as':_0x5c5f02['as'],'attributes':_0x5c5f02[_0xc363('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0xe69e32){logger['info'](_0xc363('0x21'),_0x47ed05);logger[_0xc363('0x10')](_0xc363('0x21'),_0x47ed05,JSON[_0xc363('0x11')](_0xe69e32));_0x2cb40c(_0xe69e32);})[_0xc363('0x16')](function(_0x2573f8){logger[_0xc363('0x12')](_0xc363('0x21'),_0x2573f8[_0xc363('0x14')],_0x47ed05);_0x5a3bca(_0x1777f6[_0xc363('0x12')](0x1f4,_0x2573f8[_0xc363('0x14')]));});});};