0e1bc1d8a4fc8d75f42fab47db0389c8d09e6bc8
[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 _0x4ded=['moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','then','request\x20sent','debug','error','code','VtigerAccount,\x20%s,\x20%s','message','info','result','GetVtigerAccount','VtigerAccount','findAll','options','where','attributes','limit','include','map','model','stringify','find','ShowVtigerAccount','lodash','util'];(function(_0x37f47c,_0xbefd31){var _0x8dee29=function(_0x1c4614){while(--_0x1c4614){_0x37f47c['push'](_0x37f47c['shift']());}};_0x8dee29(++_0xbefd31);}(_0x4ded,0x116));var _0xd4de=function(_0x244e36,_0x15c62c){_0x244e36=_0x244e36-0x0;var _0x754c53=_0x4ded[_0x244e36];return _0x754c53;};'use strict';var _=require(_0xd4de('0x0'));var util=require(_0xd4de('0x1'));var moment=require(_0xd4de('0x2'));var BPromise=require(_0xd4de('0x3'));var rs=require(_0xd4de('0x4'));var fs=require('fs');var Redis=require(_0xd4de('0x5'));var db=require(_0xd4de('0x6'))['db'];var utils=require(_0xd4de('0x7'));var logger=require(_0xd4de('0x8'))(_0xd4de('0x9'));var config=require(_0xd4de('0xa'));var jayson=require(_0xd4de('0xb'));var client=jayson['client'][_0xd4de('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x2433b8,_0x15eb91,_0x2c56d5){return new BPromise(function(_0x4453c2,_0x1e8c35){return client['request'](_0x2433b8,_0x2c56d5)[_0xd4de('0xd')](function(_0x5ebcf3){logger['info']('VtigerAccount,\x20%s,\x20%s',_0x15eb91,_0xd4de('0xe'));logger[_0xd4de('0xf')]('VtigerAccount,\x20%s,\x20%s,\x20%s',_0x15eb91,'request\x20sent',JSON['stringify'](_0x5ebcf3));if(_0x5ebcf3[_0xd4de('0x10')]){if(_0x5ebcf3['error'][_0xd4de('0x11')]===0x1f4){logger[_0xd4de('0x10')](_0xd4de('0x12'),_0x15eb91,_0x5ebcf3[_0xd4de('0x10')][_0xd4de('0x13')]);return _0x1e8c35(_0x5ebcf3[_0xd4de('0x10')][_0xd4de('0x13')]);}logger[_0xd4de('0x10')](_0xd4de('0x12'),_0x15eb91,_0x5ebcf3[_0xd4de('0x10')][_0xd4de('0x13')]);return _0x4453c2(_0x5ebcf3[_0xd4de('0x10')][_0xd4de('0x13')]);}else{logger[_0xd4de('0x14')](_0xd4de('0x12'),_0x15eb91,_0xd4de('0xe'));_0x4453c2(_0x5ebcf3[_0xd4de('0x15')]['message']);}})['catch'](function(_0x3df820){logger[_0xd4de('0x10')](_0xd4de('0x12'),_0x15eb91,_0x3df820);_0x1e8c35(_0x3df820);});});}exports[_0xd4de('0x16')]=function(_0x5b1d1c){var _0x4d0df6=this;return new Promise(function(_0x1e91d5,_0x54b757){return db[_0xd4de('0x17')][_0xd4de('0x18')]({'raw':_0x5b1d1c['options']?_0x5b1d1c[_0xd4de('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x5b1d1c[_0xd4de('0x19')]?_0x5b1d1c[_0xd4de('0x19')][_0xd4de('0x1a')]||null:null,'attributes':_0x5b1d1c[_0xd4de('0x19')]?_0x5b1d1c['options'][_0xd4de('0x1b')]||null:null,'limit':_0x5b1d1c[_0xd4de('0x19')]?_0x5b1d1c[_0xd4de('0x19')][_0xd4de('0x1c')]||null:null,'include':_0x5b1d1c[_0xd4de('0x19')]?_0x5b1d1c[_0xd4de('0x19')][_0xd4de('0x1d')]?_[_0xd4de('0x1e')](_0x5b1d1c[_0xd4de('0x19')][_0xd4de('0x1d')],function(_0x534b37){return{'model':db[_0x534b37[_0xd4de('0x1f')]],'as':_0x534b37['as'],'attributes':_0x534b37[_0xd4de('0x1b')],'include':_0x534b37[_0xd4de('0x1d')]?_[_0xd4de('0x1e')](_0x534b37[_0xd4de('0x1d')],function(_0x984904){return{'model':db[_0x984904[_0xd4de('0x1f')]],'as':_0x984904['as'],'attributes':_0x984904[_0xd4de('0x1b')],'include':_0x984904[_0xd4de('0x1d')]?_[_0xd4de('0x1e')](_0x984904[_0xd4de('0x1d')],function(_0xb2d8a1){return{'model':db[_0xb2d8a1['model']],'as':_0xb2d8a1['as'],'attributes':_0xb2d8a1[_0xd4de('0x1b')]};}):[]};}):[]};}):[]:[]})[_0xd4de('0xd')](function(_0x5005b0){logger[_0xd4de('0x14')]('GetVtigerAccount',_0x5b1d1c);logger[_0xd4de('0xf')](_0xd4de('0x16'),_0x5b1d1c,JSON[_0xd4de('0x20')](_0x5005b0));_0x1e91d5(_0x5005b0);})['catch'](function(_0xd4de93){logger[_0xd4de('0x10')](_0xd4de('0x16'),_0xd4de93['message'],_0x5b1d1c);_0x54b757(_0x4d0df6[_0xd4de('0x10')](0x1f4,_0xd4de93[_0xd4de('0x13')]));});});};exports['ShowVtigerAccount']=function(_0x5103b5){var _0x5706fe=this;return new Promise(function(_0x3f6491,_0x496795){return db[_0xd4de('0x17')][_0xd4de('0x21')]({'raw':_0x5103b5[_0xd4de('0x19')]?_0x5103b5[_0xd4de('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x5103b5[_0xd4de('0x19')]?_0x5103b5[_0xd4de('0x19')]['where']||null:null,'attributes':_0x5103b5[_0xd4de('0x19')]?_0x5103b5[_0xd4de('0x19')]['attributes']||null:null,'include':_0x5103b5['options']?_0x5103b5[_0xd4de('0x19')][_0xd4de('0x1d')]?_[_0xd4de('0x1e')](_0x5103b5[_0xd4de('0x19')]['include'],function(_0x2bdc98){return{'model':db[_0x2bdc98[_0xd4de('0x1f')]],'as':_0x2bdc98['as'],'attributes':_0x2bdc98['attributes'],'include':_0x2bdc98[_0xd4de('0x1d')]?_[_0xd4de('0x1e')](_0x2bdc98[_0xd4de('0x1d')],function(_0x34528a){return{'model':db[_0x34528a[_0xd4de('0x1f')]],'as':_0x34528a['as'],'attributes':_0x34528a[_0xd4de('0x1b')],'include':_0x34528a['include']?_['map'](_0x34528a[_0xd4de('0x1d')],function(_0x2d2fda){return{'model':db[_0x2d2fda[_0xd4de('0x1f')]],'as':_0x2d2fda['as'],'attributes':_0x2d2fda['attributes']};}):[]};}):[]};}):[]:[]})[_0xd4de('0xd')](function(_0x44b96c){logger['info'](_0xd4de('0x22'),_0x5103b5);logger[_0xd4de('0xf')](_0xd4de('0x22'),_0x5103b5,JSON[_0xd4de('0x20')](_0x44b96c));_0x3f6491(_0x44b96c);})['catch'](function(_0x53d7dc){logger[_0xd4de('0x10')]('ShowVtigerAccount',_0x53d7dc[_0xd4de('0x13')],_0x5103b5);_0x496795(_0x5706fe['error'](0x1f4,_0x53d7dc[_0xd4de('0x13')]));});});};