Built motion from commit d5e4af8c.|2.6.23
[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 _0xb688=['request\x20sent','debug','VtigerAccount,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','VtigerAccount','findAll','options','where','attributes','limit','include','map','model','GetVtigerAccount','stringify','ShowVtigerAccount','find','raw','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','info','VtigerAccount,\x20%s,\x20%s'];(function(_0x7cdaf1,_0x40e620){var _0xf58e9a=function(_0xc05694){while(--_0xc05694){_0x7cdaf1['push'](_0x7cdaf1['shift']());}};_0xf58e9a(++_0x40e620);}(_0xb688,0xcf));var _0x8b68=function(_0x150ace,_0x2a956b){_0x150ace=_0x150ace-0x0;var _0x24aff5=_0xb688[_0x150ace];return _0x24aff5;};'use strict';var _=require('lodash');var util=require(_0x8b68('0x0'));var moment=require(_0x8b68('0x1'));var BPromise=require(_0x8b68('0x2'));var rs=require(_0x8b68('0x3'));var fs=require('fs');var Redis=require(_0x8b68('0x4'));var db=require(_0x8b68('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x8b68('0x6'))(_0x8b68('0x7'));var config=require(_0x8b68('0x8'));var jayson=require(_0x8b68('0x9'));var client=jayson['client'][_0x8b68('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x57ee56,_0x37677d,_0x2bbffd){return new BPromise(function(_0x130892,_0xa5571b){return client[_0x8b68('0xb')](_0x57ee56,_0x2bbffd)[_0x8b68('0xc')](function(_0x261753){logger[_0x8b68('0xd')](_0x8b68('0xe'),_0x37677d,_0x8b68('0xf'));logger[_0x8b68('0x10')](_0x8b68('0x11'),_0x37677d,_0x8b68('0xf'),JSON['stringify'](_0x261753));if(_0x261753[_0x8b68('0x12')]){if(_0x261753[_0x8b68('0x12')][_0x8b68('0x13')]===0x1f4){logger[_0x8b68('0x12')](_0x8b68('0xe'),_0x37677d,_0x261753[_0x8b68('0x12')][_0x8b68('0x14')]);return _0xa5571b(_0x261753[_0x8b68('0x12')][_0x8b68('0x14')]);}logger['error'](_0x8b68('0xe'),_0x37677d,_0x261753['error']['message']);return _0x130892(_0x261753[_0x8b68('0x12')][_0x8b68('0x14')]);}else{logger[_0x8b68('0xd')]('VtigerAccount,\x20%s,\x20%s',_0x37677d,'request\x20sent');_0x130892(_0x261753[_0x8b68('0x15')]['message']);}})[_0x8b68('0x16')](function(_0xb44923){logger[_0x8b68('0x12')](_0x8b68('0xe'),_0x37677d,_0xb44923);_0xa5571b(_0xb44923);});});}exports['GetVtigerAccount']=function(_0xd17693){var _0x203dd4=this;return new Promise(function(_0x4a68c7,_0x42b3bd){return db[_0x8b68('0x17')][_0x8b68('0x18')]({'raw':_0xd17693[_0x8b68('0x19')]?_0xd17693[_0x8b68('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0xd17693[_0x8b68('0x19')]?_0xd17693[_0x8b68('0x19')][_0x8b68('0x1a')]||null:null,'attributes':_0xd17693[_0x8b68('0x19')]?_0xd17693[_0x8b68('0x19')][_0x8b68('0x1b')]||null:null,'limit':_0xd17693['options']?_0xd17693['options'][_0x8b68('0x1c')]||null:null,'include':_0xd17693['options']?_0xd17693[_0x8b68('0x19')][_0x8b68('0x1d')]?_[_0x8b68('0x1e')](_0xd17693[_0x8b68('0x19')][_0x8b68('0x1d')],function(_0x173524){return{'model':db[_0x173524['model']],'as':_0x173524['as'],'attributes':_0x173524[_0x8b68('0x1b')],'include':_0x173524[_0x8b68('0x1d')]?_['map'](_0x173524[_0x8b68('0x1d')],function(_0x3cf8d2){return{'model':db[_0x3cf8d2[_0x8b68('0x1f')]],'as':_0x3cf8d2['as'],'attributes':_0x3cf8d2['attributes'],'include':_0x3cf8d2['include']?_['map'](_0x3cf8d2[_0x8b68('0x1d')],function(_0x448e43){return{'model':db[_0x448e43[_0x8b68('0x1f')]],'as':_0x448e43['as'],'attributes':_0x448e43['attributes']};}):[]};}):[]};}):[]:[]})[_0x8b68('0xc')](function(_0x53aaa2){logger['info'](_0x8b68('0x20'),_0xd17693);logger['debug'](_0x8b68('0x20'),_0xd17693,JSON[_0x8b68('0x21')](_0x53aaa2));_0x4a68c7(_0x53aaa2);})['catch'](function(_0x494ce4){logger[_0x8b68('0x12')](_0x8b68('0x20'),_0x494ce4[_0x8b68('0x14')],_0xd17693);_0x42b3bd(_0x203dd4[_0x8b68('0x12')](0x1f4,_0x494ce4[_0x8b68('0x14')]));});});};exports[_0x8b68('0x22')]=function(_0x460c37){var _0x5b7ed1=this;return new Promise(function(_0x3b6d1b,_0x50a1e9){return db[_0x8b68('0x17')][_0x8b68('0x23')]({'raw':_0x460c37['options']?_0x460c37[_0x8b68('0x19')][_0x8b68('0x24')]===undefined?!![]:![]:!![],'where':_0x460c37[_0x8b68('0x19')]?_0x460c37['options']['where']||null:null,'attributes':_0x460c37[_0x8b68('0x19')]?_0x460c37[_0x8b68('0x19')][_0x8b68('0x1b')]||null:null,'include':_0x460c37[_0x8b68('0x19')]?_0x460c37[_0x8b68('0x19')][_0x8b68('0x1d')]?_[_0x8b68('0x1e')](_0x460c37[_0x8b68('0x19')][_0x8b68('0x1d')],function(_0x7fe301){return{'model':db[_0x7fe301[_0x8b68('0x1f')]],'as':_0x7fe301['as'],'attributes':_0x7fe301[_0x8b68('0x1b')],'include':_0x7fe301[_0x8b68('0x1d')]?_[_0x8b68('0x1e')](_0x7fe301[_0x8b68('0x1d')],function(_0x151277){return{'model':db[_0x151277[_0x8b68('0x1f')]],'as':_0x151277['as'],'attributes':_0x151277[_0x8b68('0x1b')],'include':_0x151277[_0x8b68('0x1d')]?_[_0x8b68('0x1e')](_0x151277[_0x8b68('0x1d')],function(_0x43b971){return{'model':db[_0x43b971['model']],'as':_0x43b971['as'],'attributes':_0x43b971['attributes']};}):[]};}):[]};}):[]:[]})[_0x8b68('0xc')](function(_0x262d6c){logger[_0x8b68('0xd')](_0x8b68('0x22'),_0x460c37);logger[_0x8b68('0x10')](_0x8b68('0x22'),_0x460c37,JSON[_0x8b68('0x21')](_0x262d6c));_0x3b6d1b(_0x262d6c);})[_0x8b68('0x16')](function(_0x5b628e){logger[_0x8b68('0x12')](_0x8b68('0x22'),_0x5b628e[_0x8b68('0x14')],_0x460c37);_0x50a1e9(_0x5b7ed1[_0x8b68('0x12')](0x1f4,_0x5b628e[_0x8b68('0x14')]));});});};