b61aed73a6bf48a73a0029231fe46b0e38b4db02
[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 _0x04b8=['jayson/promise','http','then','info','VtigerAccount,\x20%s,\x20%s','request\x20sent','VtigerAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','GetVtigerAccount','VtigerAccount','findAll','options','where','attributes','limit','map','model','include','debug','catch','ShowVtigerAccount','find','util','bluebird','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment'];(function(_0x2741d1,_0x501426){var _0x521e37=function(_0x31b546){while(--_0x31b546){_0x2741d1['push'](_0x2741d1['shift']());}};_0x521e37(++_0x501426);}(_0x04b8,0x159));var _0x804b=function(_0x1ca4e4,_0x64ed76){_0x1ca4e4=_0x1ca4e4-0x0;var _0x2ad214=_0x04b8[_0x1ca4e4];return _0x2ad214;};'use strict';var _=require('lodash');var util=require(_0x804b('0x0'));var moment=require('moment');var BPromise=require(_0x804b('0x1'));var rs=require(_0x804b('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x804b('0x3'))['db'];var utils=require(_0x804b('0x4'));var logger=require('../../config/logger')(_0x804b('0x5'));var config=require(_0x804b('0x6'));var jayson=require(_0x804b('0x7'));var client=jayson['client'][_0x804b('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x3c5404,_0x476262,_0x50826d){return new BPromise(function(_0x27e950,_0x1071b4){return client['request'](_0x3c5404,_0x50826d)[_0x804b('0x9')](function(_0x336325){logger[_0x804b('0xa')](_0x804b('0xb'),_0x476262,_0x804b('0xc'));logger['debug'](_0x804b('0xd'),_0x476262,_0x804b('0xc'),JSON[_0x804b('0xe')](_0x336325));if(_0x336325[_0x804b('0xf')]){if(_0x336325[_0x804b('0xf')][_0x804b('0x10')]===0x1f4){logger['error'](_0x804b('0xb'),_0x476262,_0x336325['error'][_0x804b('0x11')]);return _0x1071b4(_0x336325[_0x804b('0xf')][_0x804b('0x11')]);}logger[_0x804b('0xf')]('VtigerAccount,\x20%s,\x20%s',_0x476262,_0x336325[_0x804b('0xf')][_0x804b('0x11')]);return _0x27e950(_0x336325[_0x804b('0xf')][_0x804b('0x11')]);}else{logger['info'](_0x804b('0xb'),_0x476262,_0x804b('0xc'));_0x27e950(_0x336325['result'][_0x804b('0x11')]);}})['catch'](function(_0x2c90b9){logger[_0x804b('0xf')](_0x804b('0xb'),_0x476262,_0x2c90b9);_0x1071b4(_0x2c90b9);});});}exports[_0x804b('0x12')]=function(_0x3a05c0){var _0x5a0a82=this;return new Promise(function(_0x871d6c,_0x50b4fe){return db[_0x804b('0x13')][_0x804b('0x14')]({'raw':_0x3a05c0[_0x804b('0x15')]?_0x3a05c0[_0x804b('0x15')]['raw']===undefined?!![]:![]:!![],'where':_0x3a05c0[_0x804b('0x15')]?_0x3a05c0[_0x804b('0x15')][_0x804b('0x16')]||null:null,'attributes':_0x3a05c0[_0x804b('0x15')]?_0x3a05c0[_0x804b('0x15')][_0x804b('0x17')]||null:null,'limit':_0x3a05c0[_0x804b('0x15')]?_0x3a05c0[_0x804b('0x15')][_0x804b('0x18')]||null:null,'include':_0x3a05c0[_0x804b('0x15')]?_0x3a05c0[_0x804b('0x15')]['include']?_[_0x804b('0x19')](_0x3a05c0[_0x804b('0x15')]['include'],function(_0x44a921){return{'model':db[_0x44a921[_0x804b('0x1a')]],'as':_0x44a921['as'],'attributes':_0x44a921[_0x804b('0x17')],'include':_0x44a921[_0x804b('0x1b')]?_[_0x804b('0x19')](_0x44a921['include'],function(_0x2de812){return{'model':db[_0x2de812[_0x804b('0x1a')]],'as':_0x2de812['as'],'attributes':_0x2de812['attributes'],'include':_0x2de812[_0x804b('0x1b')]?_[_0x804b('0x19')](_0x2de812[_0x804b('0x1b')],function(_0x27d5ec){return{'model':db[_0x27d5ec[_0x804b('0x1a')]],'as':_0x27d5ec['as'],'attributes':_0x27d5ec['attributes']};}):[]};}):[]};}):[]:[]})[_0x804b('0x9')](function(_0x22f822){logger[_0x804b('0xa')](_0x804b('0x12'),_0x3a05c0);logger[_0x804b('0x1c')]('GetVtigerAccount',_0x3a05c0,JSON[_0x804b('0xe')](_0x22f822));_0x871d6c(_0x22f822);})[_0x804b('0x1d')](function(_0x410871){logger['error'](_0x804b('0x12'),_0x410871[_0x804b('0x11')],_0x3a05c0);_0x50b4fe(_0x5a0a82[_0x804b('0xf')](0x1f4,_0x410871['message']));});});};exports[_0x804b('0x1e')]=function(_0x471c04){var _0x5e8f85=this;return new Promise(function(_0x391376,_0x37dd3e){return db[_0x804b('0x13')][_0x804b('0x1f')]({'raw':_0x471c04[_0x804b('0x15')]?_0x471c04[_0x804b('0x15')]['raw']===undefined?!![]:![]:!![],'where':_0x471c04[_0x804b('0x15')]?_0x471c04[_0x804b('0x15')][_0x804b('0x16')]||null:null,'attributes':_0x471c04[_0x804b('0x15')]?_0x471c04[_0x804b('0x15')][_0x804b('0x17')]||null:null,'include':_0x471c04[_0x804b('0x15')]?_0x471c04[_0x804b('0x15')][_0x804b('0x1b')]?_[_0x804b('0x19')](_0x471c04[_0x804b('0x15')][_0x804b('0x1b')],function(_0x34d5d0){return{'model':db[_0x34d5d0[_0x804b('0x1a')]],'as':_0x34d5d0['as'],'attributes':_0x34d5d0[_0x804b('0x17')],'include':_0x34d5d0[_0x804b('0x1b')]?_[_0x804b('0x19')](_0x34d5d0[_0x804b('0x1b')],function(_0xf47023){return{'model':db[_0xf47023[_0x804b('0x1a')]],'as':_0xf47023['as'],'attributes':_0xf47023[_0x804b('0x17')],'include':_0xf47023[_0x804b('0x1b')]?_[_0x804b('0x19')](_0xf47023[_0x804b('0x1b')],function(_0x35150b){return{'model':db[_0x35150b['model']],'as':_0x35150b['as'],'attributes':_0x35150b['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x3da331){logger[_0x804b('0xa')](_0x804b('0x1e'),_0x471c04);logger['debug']('ShowVtigerAccount',_0x471c04,JSON['stringify'](_0x3da331));_0x391376(_0x3da331);})[_0x804b('0x1d')](function(_0x1aaa47){logger[_0x804b('0xf')](_0x804b('0x1e'),_0x1aaa47[_0x804b('0x11')],_0x471c04);_0x37dd3e(_0x5e8f85[_0x804b('0xf')](0x1f4,_0x1aaa47[_0x804b('0x11')]));});});};