Built motion from commit 06eb8eb0.|2.6.31
[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 _0x4253=['client','http','request','then','info','ZohoAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','ZohoAccount,\x20%s,\x20%s','result','GetZohoAccount','findAll','options','raw','where','limit','include','map','model','attributes','catch','ShowZohoAccount','ZohoAccount','find','debug','lodash','util','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise'];(function(_0x46b392,_0x4f1ad0){var _0x41aca2=function(_0x1d8ca0){while(--_0x1d8ca0){_0x46b392['push'](_0x46b392['shift']());}};_0x41aca2(++_0x4f1ad0);}(_0x4253,0x14c));var _0x3425=function(_0x54e547,_0x4bbf7c){_0x54e547=_0x54e547-0x0;var _0x209dd5=_0x4253[_0x54e547];return _0x209dd5;};'use strict';var _=require(_0x3425('0x0'));var util=require(_0x3425('0x1'));var moment=require('moment');var BPromise=require(_0x3425('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x3425('0x3'));var db=require(_0x3425('0x4'))['db'];var utils=require(_0x3425('0x5'));var logger=require(_0x3425('0x6'))(_0x3425('0x7'));var config=require(_0x3425('0x8'));var jayson=require(_0x3425('0x9'));var client=jayson[_0x3425('0xa')][_0x3425('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x53cc1f,_0x1bb3ca,_0x1994b1){return new BPromise(function(_0x33cbc7,_0x4ce62b){return client[_0x3425('0xc')](_0x53cc1f,_0x1994b1)[_0x3425('0xd')](function(_0x5a2bc6){logger[_0x3425('0xe')]('ZohoAccount,\x20%s,\x20%s',_0x1bb3ca,'request\x20sent');logger['debug'](_0x3425('0xf'),_0x1bb3ca,_0x3425('0x10'),JSON[_0x3425('0x11')](_0x5a2bc6));if(_0x5a2bc6['error']){if(_0x5a2bc6[_0x3425('0x12')][_0x3425('0x13')]===0x1f4){logger[_0x3425('0x12')]('ZohoAccount,\x20%s,\x20%s',_0x1bb3ca,_0x5a2bc6[_0x3425('0x12')][_0x3425('0x14')]);return _0x4ce62b(_0x5a2bc6[_0x3425('0x12')][_0x3425('0x14')]);}logger[_0x3425('0x12')](_0x3425('0x15'),_0x1bb3ca,_0x5a2bc6[_0x3425('0x12')]['message']);return _0x33cbc7(_0x5a2bc6[_0x3425('0x12')]['message']);}else{logger[_0x3425('0xe')](_0x3425('0x15'),_0x1bb3ca,'request\x20sent');_0x33cbc7(_0x5a2bc6[_0x3425('0x16')][_0x3425('0x14')]);}})['catch'](function(_0x13aabd){logger['error'](_0x3425('0x15'),_0x1bb3ca,_0x13aabd);_0x4ce62b(_0x13aabd);});});}exports[_0x3425('0x17')]=function(_0x1565c8){var _0x2156c4=this;return new Promise(function(_0x4d5933,_0xb9b412){return db['ZohoAccount'][_0x3425('0x18')]({'raw':_0x1565c8[_0x3425('0x19')]?_0x1565c8[_0x3425('0x19')][_0x3425('0x1a')]===undefined?!![]:![]:!![],'where':_0x1565c8[_0x3425('0x19')]?_0x1565c8[_0x3425('0x19')][_0x3425('0x1b')]||null:null,'attributes':_0x1565c8[_0x3425('0x19')]?_0x1565c8['options']['attributes']||null:null,'limit':_0x1565c8[_0x3425('0x19')]?_0x1565c8['options'][_0x3425('0x1c')]||null:null,'include':_0x1565c8[_0x3425('0x19')]?_0x1565c8[_0x3425('0x19')][_0x3425('0x1d')]?_[_0x3425('0x1e')](_0x1565c8[_0x3425('0x19')]['include'],function(_0x38b577){return{'model':db[_0x38b577[_0x3425('0x1f')]],'as':_0x38b577['as'],'attributes':_0x38b577[_0x3425('0x20')],'include':_0x38b577[_0x3425('0x1d')]?_['map'](_0x38b577[_0x3425('0x1d')],function(_0x31d4d5){return{'model':db[_0x31d4d5[_0x3425('0x1f')]],'as':_0x31d4d5['as'],'attributes':_0x31d4d5[_0x3425('0x20')],'include':_0x31d4d5[_0x3425('0x1d')]?_[_0x3425('0x1e')](_0x31d4d5[_0x3425('0x1d')],function(_0x2638b5){return{'model':db[_0x2638b5[_0x3425('0x1f')]],'as':_0x2638b5['as'],'attributes':_0x2638b5[_0x3425('0x20')]};}):[]};}):[]};}):[]:[]})[_0x3425('0xd')](function(_0x16c50a){logger[_0x3425('0xe')](_0x3425('0x17'),_0x1565c8);logger['debug'](_0x3425('0x17'),_0x1565c8,JSON[_0x3425('0x11')](_0x16c50a));_0x4d5933(_0x16c50a);})[_0x3425('0x21')](function(_0x27f416){logger[_0x3425('0x12')](_0x3425('0x17'),_0x27f416[_0x3425('0x14')],_0x1565c8);_0xb9b412(_0x2156c4[_0x3425('0x12')](0x1f4,_0x27f416[_0x3425('0x14')]));});});};exports[_0x3425('0x22')]=function(_0x24b353){var _0xf4111=this;return new Promise(function(_0x256a64,_0x425753){return db[_0x3425('0x23')][_0x3425('0x24')]({'raw':_0x24b353[_0x3425('0x19')]?_0x24b353[_0x3425('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x24b353[_0x3425('0x19')]?_0x24b353[_0x3425('0x19')][_0x3425('0x1b')]||null:null,'attributes':_0x24b353['options']?_0x24b353[_0x3425('0x19')][_0x3425('0x20')]||null:null,'include':_0x24b353[_0x3425('0x19')]?_0x24b353[_0x3425('0x19')][_0x3425('0x1d')]?_[_0x3425('0x1e')](_0x24b353[_0x3425('0x19')][_0x3425('0x1d')],function(_0x7b658c){return{'model':db[_0x7b658c[_0x3425('0x1f')]],'as':_0x7b658c['as'],'attributes':_0x7b658c[_0x3425('0x20')],'include':_0x7b658c[_0x3425('0x1d')]?_['map'](_0x7b658c[_0x3425('0x1d')],function(_0x3efee9){return{'model':db[_0x3efee9[_0x3425('0x1f')]],'as':_0x3efee9['as'],'attributes':_0x3efee9[_0x3425('0x20')],'include':_0x3efee9[_0x3425('0x1d')]?_[_0x3425('0x1e')](_0x3efee9[_0x3425('0x1d')],function(_0x22ef8e){return{'model':db[_0x22ef8e[_0x3425('0x1f')]],'as':_0x22ef8e['as'],'attributes':_0x22ef8e[_0x3425('0x20')]};}):[]};}):[]};}):[]:[]})[_0x3425('0xd')](function(_0xda59ce){logger['info'](_0x3425('0x22'),_0x24b353);logger[_0x3425('0x25')](_0x3425('0x22'),_0x24b353,JSON[_0x3425('0x11')](_0xda59ce));_0x256a64(_0xda59ce);})[_0x3425('0x21')](function(_0x21e67e){logger[_0x3425('0x12')](_0x3425('0x22'),_0x21e67e[_0x3425('0x14')],_0x24b353);_0x425753(_0xf4111[_0x3425('0x12')](0x1f4,_0x21e67e[_0x3425('0x14')]));});});};