Built motion from commit (unavailable).|2.5.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 _0x693a=['request','then','info','ZohoAccount,\x20%s,\x20%s','request\x20sent','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','ZohoAccount','findAll','options','raw','where','limit','include','map','model','attributes','GetZohoAccount','debug','catch','ShowZohoAccount','find','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','jayson/promise','http'];(function(_0x4cb74e,_0x3da374){var _0x4a7534=function(_0x4d31a3){while(--_0x4d31a3){_0x4cb74e['push'](_0x4cb74e['shift']());}};_0x4a7534(++_0x3da374);}(_0x693a,0x1ee));var _0xa693=function(_0x17823f,_0xffd807){_0x17823f=_0x17823f-0x0;var _0x51fc21=_0x693a[_0x17823f];return _0x51fc21;};'use strict';var _=require(_0xa693('0x0'));var util=require(_0xa693('0x1'));var moment=require('moment');var BPromise=require(_0xa693('0x2'));var rs=require(_0xa693('0x3'));var fs=require('fs');var Redis=require(_0xa693('0x4'));var db=require(_0xa693('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xa693('0x6'))(_0xa693('0x7'));var config=require('../../config/environment');var jayson=require(_0xa693('0x8'));var client=jayson['client'][_0xa693('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3abc7d,_0x1fa171,_0x1b9a50){return new BPromise(function(_0x23889a,_0x81d415){return client[_0xa693('0xa')](_0x3abc7d,_0x1b9a50)[_0xa693('0xb')](function(_0x2a9942){logger[_0xa693('0xc')](_0xa693('0xd'),_0x1fa171,_0xa693('0xe'));logger['debug'](_0xa693('0xf'),_0x1fa171,_0xa693('0xe'),JSON[_0xa693('0x10')](_0x2a9942));if(_0x2a9942[_0xa693('0x11')]){if(_0x2a9942[_0xa693('0x11')][_0xa693('0x12')]===0x1f4){logger[_0xa693('0x11')](_0xa693('0xd'),_0x1fa171,_0x2a9942[_0xa693('0x11')]['message']);return _0x81d415(_0x2a9942[_0xa693('0x11')][_0xa693('0x13')]);}logger[_0xa693('0x11')](_0xa693('0xd'),_0x1fa171,_0x2a9942['error'][_0xa693('0x13')]);return _0x23889a(_0x2a9942[_0xa693('0x11')][_0xa693('0x13')]);}else{logger[_0xa693('0xc')](_0xa693('0xd'),_0x1fa171,'request\x20sent');_0x23889a(_0x2a9942[_0xa693('0x14')][_0xa693('0x13')]);}})['catch'](function(_0xbffb8d){logger[_0xa693('0x11')](_0xa693('0xd'),_0x1fa171,_0xbffb8d);_0x81d415(_0xbffb8d);});});}exports['GetZohoAccount']=function(_0x2c1da1){var _0x2ce706=this;return new Promise(function(_0xb501d0,_0x12c63f){return db[_0xa693('0x15')][_0xa693('0x16')]({'raw':_0x2c1da1[_0xa693('0x17')]?_0x2c1da1[_0xa693('0x17')][_0xa693('0x18')]===undefined?!![]:![]:!![],'where':_0x2c1da1['options']?_0x2c1da1[_0xa693('0x17')][_0xa693('0x19')]||null:null,'attributes':_0x2c1da1[_0xa693('0x17')]?_0x2c1da1[_0xa693('0x17')]['attributes']||null:null,'limit':_0x2c1da1['options']?_0x2c1da1['options'][_0xa693('0x1a')]||null:null,'include':_0x2c1da1[_0xa693('0x17')]?_0x2c1da1['options'][_0xa693('0x1b')]?_[_0xa693('0x1c')](_0x2c1da1[_0xa693('0x17')][_0xa693('0x1b')],function(_0x21e186){return{'model':db[_0x21e186[_0xa693('0x1d')]],'as':_0x21e186['as'],'attributes':_0x21e186[_0xa693('0x1e')],'include':_0x21e186[_0xa693('0x1b')]?_[_0xa693('0x1c')](_0x21e186[_0xa693('0x1b')],function(_0x5d5e35){return{'model':db[_0x5d5e35[_0xa693('0x1d')]],'as':_0x5d5e35['as'],'attributes':_0x5d5e35['attributes'],'include':_0x5d5e35[_0xa693('0x1b')]?_[_0xa693('0x1c')](_0x5d5e35[_0xa693('0x1b')],function(_0x2a9ef4){return{'model':db[_0x2a9ef4['model']],'as':_0x2a9ef4['as'],'attributes':_0x2a9ef4[_0xa693('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xa693('0xb')](function(_0xe30d72){logger[_0xa693('0xc')](_0xa693('0x1f'),_0x2c1da1);logger[_0xa693('0x20')](_0xa693('0x1f'),_0x2c1da1,JSON[_0xa693('0x10')](_0xe30d72));_0xb501d0(_0xe30d72);})[_0xa693('0x21')](function(_0x2d86e6){logger['error'](_0xa693('0x1f'),_0x2d86e6[_0xa693('0x13')],_0x2c1da1);_0x12c63f(_0x2ce706['error'](0x1f4,_0x2d86e6[_0xa693('0x13')]));});});};exports[_0xa693('0x22')]=function(_0x4238b8){var _0x1a67f4=this;return new Promise(function(_0x397db3,_0x14a582){return db[_0xa693('0x15')][_0xa693('0x23')]({'raw':_0x4238b8[_0xa693('0x17')]?_0x4238b8[_0xa693('0x17')][_0xa693('0x18')]===undefined?!![]:![]:!![],'where':_0x4238b8['options']?_0x4238b8[_0xa693('0x17')][_0xa693('0x19')]||null:null,'attributes':_0x4238b8['options']?_0x4238b8['options']['attributes']||null:null,'include':_0x4238b8['options']?_0x4238b8['options'][_0xa693('0x1b')]?_[_0xa693('0x1c')](_0x4238b8[_0xa693('0x17')][_0xa693('0x1b')],function(_0x3b03e6){return{'model':db[_0x3b03e6[_0xa693('0x1d')]],'as':_0x3b03e6['as'],'attributes':_0x3b03e6[_0xa693('0x1e')],'include':_0x3b03e6[_0xa693('0x1b')]?_['map'](_0x3b03e6[_0xa693('0x1b')],function(_0x463f75){return{'model':db[_0x463f75[_0xa693('0x1d')]],'as':_0x463f75['as'],'attributes':_0x463f75[_0xa693('0x1e')],'include':_0x463f75[_0xa693('0x1b')]?_['map'](_0x463f75[_0xa693('0x1b')],function(_0x54b7ef){return{'model':db[_0x54b7ef[_0xa693('0x1d')]],'as':_0x54b7ef['as'],'attributes':_0x54b7ef[_0xa693('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xa693('0xb')](function(_0x54bb47){logger[_0xa693('0xc')](_0xa693('0x22'),_0x4238b8);logger[_0xa693('0x20')](_0xa693('0x22'),_0x4238b8,JSON[_0xa693('0x10')](_0x54bb47));_0x397db3(_0x54bb47);})[_0xa693('0x21')](function(_0x4d7ba6){logger[_0xa693('0x11')](_0xa693('0x22'),_0x4d7ba6[_0xa693('0x13')],_0x4238b8);_0x14a582(_0x1a67f4[_0xa693('0x11')](0x1f4,_0x4d7ba6[_0xa693('0x13')]));});});};