d6f3664d9846eeca9b7ac4c6f4f2e8a03e0d3001
[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 _0x731e=['error','code','message','findAll','options','raw','where','limit','include','map','model','attributes','GetVtigerAccount','debug','ShowVtigerAccount','VtigerAccount','find','catch','lodash','util','bluebird','../../mysqldb','../../config/utils','rpc','http','then','info','VtigerAccount,\x20%s,\x20%s','request\x20sent','stringify'];(function(_0x1f8974,_0x1cf003){var _0x28a046=function(_0x1edabd){while(--_0x1edabd){_0x1f8974['push'](_0x1f8974['shift']());}};_0x28a046(++_0x1cf003);}(_0x731e,0x198));var _0xe731=function(_0x3e0c78,_0x347a58){_0x3e0c78=_0x3e0c78-0x0;var _0x201901=_0x731e[_0x3e0c78];return _0x201901;};'use strict';var _=require(_0xe731('0x0'));var util=require(_0xe731('0x1'));var moment=require('moment');var BPromise=require(_0xe731('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xe731('0x3'))['db'];var utils=require(_0xe731('0x4'));var logger=require('../../config/logger')(_0xe731('0x5'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0xe731('0x6')]({'port':0x232a});function respondWithRpcPromise(_0x1b3d6f,_0x13ea51,_0x15a287){return new BPromise(function(_0x31fe18,_0x36cbdf){return client['request'](_0x1b3d6f,_0x15a287)[_0xe731('0x7')](function(_0x47a98b){logger[_0xe731('0x8')](_0xe731('0x9'),_0x13ea51,_0xe731('0xa'));logger['debug']('VtigerAccount,\x20%s,\x20%s,\x20%s',_0x13ea51,_0xe731('0xa'),JSON[_0xe731('0xb')](_0x47a98b));if(_0x47a98b[_0xe731('0xc')]){if(_0x47a98b[_0xe731('0xc')][_0xe731('0xd')]===0x1f4){logger[_0xe731('0xc')]('VtigerAccount,\x20%s,\x20%s',_0x13ea51,_0x47a98b[_0xe731('0xc')][_0xe731('0xe')]);return _0x36cbdf(_0x47a98b[_0xe731('0xc')][_0xe731('0xe')]);}logger[_0xe731('0xc')](_0xe731('0x9'),_0x13ea51,_0x47a98b[_0xe731('0xc')][_0xe731('0xe')]);return _0x31fe18(_0x47a98b[_0xe731('0xc')][_0xe731('0xe')]);}else{logger['info']('VtigerAccount,\x20%s,\x20%s',_0x13ea51,'request\x20sent');_0x31fe18(_0x47a98b['result'][_0xe731('0xe')]);}})['catch'](function(_0x2743e2){logger[_0xe731('0xc')](_0xe731('0x9'),_0x13ea51,_0x2743e2);_0x36cbdf(_0x2743e2);});});}exports['GetVtigerAccount']=function(_0x5e166f){var _0x5f1969=this;return new Promise(function(_0x45b7a4,_0x598a02){return db['VtigerAccount'][_0xe731('0xf')]({'raw':_0x5e166f[_0xe731('0x10')]?_0x5e166f[_0xe731('0x10')][_0xe731('0x11')]===undefined?!![]:![]:!![],'where':_0x5e166f[_0xe731('0x10')]?_0x5e166f['options'][_0xe731('0x12')]||null:null,'attributes':_0x5e166f[_0xe731('0x10')]?_0x5e166f[_0xe731('0x10')]['attributes']||null:null,'limit':_0x5e166f['options']?_0x5e166f['options'][_0xe731('0x13')]||null:null,'include':_0x5e166f['options']?_0x5e166f[_0xe731('0x10')][_0xe731('0x14')]?_[_0xe731('0x15')](_0x5e166f[_0xe731('0x10')][_0xe731('0x14')],function(_0x3e5693){return{'model':db[_0x3e5693[_0xe731('0x16')]],'as':_0x3e5693['as'],'attributes':_0x3e5693['attributes'],'include':_0x3e5693[_0xe731('0x14')]?_[_0xe731('0x15')](_0x3e5693[_0xe731('0x14')],function(_0x35b875){return{'model':db[_0x35b875['model']],'as':_0x35b875['as'],'attributes':_0x35b875['attributes'],'include':_0x35b875[_0xe731('0x14')]?_['map'](_0x35b875[_0xe731('0x14')],function(_0x351c20){return{'model':db[_0x351c20['model']],'as':_0x351c20['as'],'attributes':_0x351c20[_0xe731('0x17')]};}):[]};}):[]};}):[]:[]})[_0xe731('0x7')](function(_0xae06bb){logger[_0xe731('0x8')](_0xe731('0x18'),_0x5e166f);logger[_0xe731('0x19')](_0xe731('0x18'),_0x5e166f,JSON[_0xe731('0xb')](_0xae06bb));_0x45b7a4(_0xae06bb);})['catch'](function(_0x5c23ad){logger[_0xe731('0xc')]('GetVtigerAccount',_0x5c23ad[_0xe731('0xe')],_0x5e166f);_0x598a02(_0x5f1969[_0xe731('0xc')](0x1f4,_0x5c23ad[_0xe731('0xe')]));});});};exports[_0xe731('0x1a')]=function(_0x5607fa){var _0x478c06=this;return new Promise(function(_0x4129dd,_0x1d3ff8){return db[_0xe731('0x1b')][_0xe731('0x1c')]({'raw':_0x5607fa['options']?_0x5607fa[_0xe731('0x10')][_0xe731('0x11')]===undefined?!![]:![]:!![],'where':_0x5607fa['options']?_0x5607fa[_0xe731('0x10')][_0xe731('0x12')]||null:null,'attributes':_0x5607fa['options']?_0x5607fa[_0xe731('0x10')][_0xe731('0x17')]||null:null,'include':_0x5607fa[_0xe731('0x10')]?_0x5607fa[_0xe731('0x10')][_0xe731('0x14')]?_['map'](_0x5607fa['options'][_0xe731('0x14')],function(_0x10ba2d){return{'model':db[_0x10ba2d[_0xe731('0x16')]],'as':_0x10ba2d['as'],'attributes':_0x10ba2d['attributes'],'include':_0x10ba2d['include']?_['map'](_0x10ba2d[_0xe731('0x14')],function(_0x11b482){return{'model':db[_0x11b482['model']],'as':_0x11b482['as'],'attributes':_0x11b482['attributes'],'include':_0x11b482[_0xe731('0x14')]?_[_0xe731('0x15')](_0x11b482[_0xe731('0x14')],function(_0xc7bb69){return{'model':db[_0xc7bb69[_0xe731('0x16')]],'as':_0xc7bb69['as'],'attributes':_0xc7bb69[_0xe731('0x17')]};}):[]};}):[]};}):[]:[]})[_0xe731('0x7')](function(_0x218d46){logger['info']('ShowVtigerAccount',_0x5607fa);logger[_0xe731('0x19')](_0xe731('0x1a'),_0x5607fa,JSON[_0xe731('0xb')](_0x218d46));_0x4129dd(_0x218d46);})[_0xe731('0x1d')](function(_0x54e502){logger[_0xe731('0xc')](_0xe731('0x1a'),_0x54e502[_0xe731('0xe')],_0x5607fa);_0x1d3ff8(_0x478c06[_0xe731('0xc')](0x1f4,_0x54e502[_0xe731('0xe')]));});});};