4587168a7f732421ffeaa17e71877459a28c6041
[motion2.git] / server / api / intVtigerAccount / intVtigerAccount.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 _0x6238=['../../config/logger','rpc','../../config/environment','client','request','then','info','VtigerAccount,\x20%s,\x20%s','request\x20sent','debug','VtigerAccount,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','GetVtigerAccount','VtigerAccount','findAll','options','raw','where','include','map','model','attributes','ShowVtigerAccount','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils'];(function(_0x43b1fb,_0x22e01e){var _0x2eb5bc=function(_0x1622a4){while(--_0x1622a4){_0x43b1fb['push'](_0x43b1fb['shift']());}};_0x2eb5bc(++_0x22e01e);}(_0x6238,0x118));var _0x8623=function(_0x501510,_0x61caa9){_0x501510=_0x501510-0x0;var _0x1e6ee5=_0x6238[_0x501510];return _0x1e6ee5;};'use strict';var _=require(_0x8623('0x0'));var util=require(_0x8623('0x1'));var moment=require(_0x8623('0x2'));var BPromise=require(_0x8623('0x3'));var rs=require(_0x8623('0x4'));var fs=require('fs');var Redis=require(_0x8623('0x5'));var db=require(_0x8623('0x6'))['db'];var utils=require(_0x8623('0x7'));var logger=require(_0x8623('0x8'))(_0x8623('0x9'));var config=require(_0x8623('0xa'));var jayson=require('jayson/promise');var client=jayson[_0x8623('0xb')]['http']({'port':0x232a});function respondWithRpcPromise(_0x57ab28,_0x408855,_0x2b1484){return new BPromise(function(_0x2ab910,_0x1b12bd){return client[_0x8623('0xc')](_0x57ab28,_0x2b1484)[_0x8623('0xd')](function(_0x4d3a2c){logger[_0x8623('0xe')](_0x8623('0xf'),_0x408855,_0x8623('0x10'));logger[_0x8623('0x11')](_0x8623('0x12'),_0x408855,'request\x20sent',JSON['stringify'](_0x4d3a2c));if(_0x4d3a2c[_0x8623('0x13')]){if(_0x4d3a2c['error'][_0x8623('0x14')]===0x1f4){logger[_0x8623('0x13')](_0x8623('0xf'),_0x408855,_0x4d3a2c[_0x8623('0x13')][_0x8623('0x15')]);return _0x1b12bd(_0x4d3a2c[_0x8623('0x13')][_0x8623('0x15')]);}logger[_0x8623('0x13')](_0x8623('0xf'),_0x408855,_0x4d3a2c[_0x8623('0x13')]['message']);return _0x2ab910(_0x4d3a2c[_0x8623('0x13')][_0x8623('0x15')]);}else{logger[_0x8623('0xe')](_0x8623('0xf'),_0x408855,_0x8623('0x10'));_0x2ab910(_0x4d3a2c[_0x8623('0x16')][_0x8623('0x15')]);}})[_0x8623('0x17')](function(_0x2a4ec5){logger['error']('VtigerAccount,\x20%s,\x20%s',_0x408855,_0x2a4ec5);_0x1b12bd(_0x2a4ec5);});});}exports[_0x8623('0x18')]=function(_0x323156){var _0x4b7fe2=this;return new Promise(function(_0x12f723,_0x2a71c7){return db[_0x8623('0x19')][_0x8623('0x1a')]({'raw':_0x323156[_0x8623('0x1b')]?_0x323156[_0x8623('0x1b')][_0x8623('0x1c')]===undefined?!![]:![]:!![],'where':_0x323156[_0x8623('0x1b')]?_0x323156['options'][_0x8623('0x1d')]||null:null,'attributes':_0x323156[_0x8623('0x1b')]?_0x323156[_0x8623('0x1b')]['attributes']||null:null,'limit':_0x323156[_0x8623('0x1b')]?_0x323156[_0x8623('0x1b')]['limit']||null:null,'include':_0x323156[_0x8623('0x1b')]?_0x323156['options'][_0x8623('0x1e')]?_[_0x8623('0x1f')](_0x323156['options'][_0x8623('0x1e')],function(_0x4600c9){return{'model':db[_0x4600c9[_0x8623('0x20')]],'as':_0x4600c9['as'],'attributes':_0x4600c9[_0x8623('0x21')],'include':_0x4600c9[_0x8623('0x1e')]?_[_0x8623('0x1f')](_0x4600c9['include'],function(_0x23f32f){return{'model':db[_0x23f32f['model']],'as':_0x23f32f['as'],'attributes':_0x23f32f[_0x8623('0x21')],'include':_0x23f32f[_0x8623('0x1e')]?_[_0x8623('0x1f')](_0x23f32f[_0x8623('0x1e')],function(_0x34fffb){return{'model':db[_0x34fffb[_0x8623('0x20')]],'as':_0x34fffb['as'],'attributes':_0x34fffb[_0x8623('0x21')]};}):[]};}):[]};}):[]:[]})[_0x8623('0xd')](function(_0x13ddce){logger[_0x8623('0xe')](_0x8623('0x18'),_0x323156);logger[_0x8623('0x11')](_0x8623('0x18'),_0x323156,JSON['stringify'](_0x13ddce));_0x12f723(_0x13ddce);})['catch'](function(_0x714668){logger[_0x8623('0x13')]('GetVtigerAccount',_0x714668['message'],_0x323156);_0x2a71c7(_0x4b7fe2[_0x8623('0x13')](0x1f4,_0x714668[_0x8623('0x15')]));});});};exports['ShowVtigerAccount']=function(_0x543f29){var _0x595295=this;return new Promise(function(_0x17e1e3,_0x5728e1){return db[_0x8623('0x19')]['find']({'raw':_0x543f29[_0x8623('0x1b')]?_0x543f29[_0x8623('0x1b')][_0x8623('0x1c')]===undefined?!![]:![]:!![],'where':_0x543f29[_0x8623('0x1b')]?_0x543f29[_0x8623('0x1b')][_0x8623('0x1d')]||null:null,'attributes':_0x543f29[_0x8623('0x1b')]?_0x543f29[_0x8623('0x1b')]['attributes']||null:null,'include':_0x543f29['options']?_0x543f29[_0x8623('0x1b')]['include']?_[_0x8623('0x1f')](_0x543f29[_0x8623('0x1b')][_0x8623('0x1e')],function(_0x3dacc2){return{'model':db[_0x3dacc2[_0x8623('0x20')]],'as':_0x3dacc2['as'],'attributes':_0x3dacc2[_0x8623('0x21')],'include':_0x3dacc2[_0x8623('0x1e')]?_[_0x8623('0x1f')](_0x3dacc2[_0x8623('0x1e')],function(_0x2036ae){return{'model':db[_0x2036ae[_0x8623('0x20')]],'as':_0x2036ae['as'],'attributes':_0x2036ae[_0x8623('0x21')],'include':_0x2036ae['include']?_[_0x8623('0x1f')](_0x2036ae[_0x8623('0x1e')],function(_0x319257){return{'model':db[_0x319257['model']],'as':_0x319257['as'],'attributes':_0x319257['attributes']};}):[]};}):[]};}):[]:[]})[_0x8623('0xd')](function(_0x9123a){logger[_0x8623('0xe')](_0x8623('0x22'),_0x543f29);logger[_0x8623('0x11')](_0x8623('0x22'),_0x543f29,JSON[_0x8623('0x23')](_0x9123a));_0x17e1e3(_0x9123a);})[_0x8623('0x17')](function(_0x53756d){logger[_0x8623('0x13')](_0x8623('0x22'),_0x53756d['message'],_0x543f29);_0x5728e1(_0x595295[_0x8623('0x13')](0x1f4,_0x53756d['message']));});});};