Built motion from commit (unavailable).|2.5.15
[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 _0x1900=['../../mysqldb','../../config/logger','rpc','jayson/promise','http','request','then','info','VtigerAccount,\x20%s,\x20%s','request\x20sent','debug','VtigerAccount,\x20%s,\x20%s,\x20%s','stringify','code','error','message','result','catch','GetVtigerAccount','VtigerAccount','findAll','options','raw','where','attributes','include','map','model','ShowVtigerAccount','find','lodash','util','moment','bluebird','ioredis'];(function(_0x44cad0,_0x229ce2){var _0x360e6f=function(_0x5a185e){while(--_0x5a185e){_0x44cad0['push'](_0x44cad0['shift']());}};_0x360e6f(++_0x229ce2);}(_0x1900,0x19f));var _0x0190=function(_0x12a530,_0x19a689){_0x12a530=_0x12a530-0x0;var _0x74d3e6=_0x1900[_0x12a530];return _0x74d3e6;};'use strict';var _=require(_0x0190('0x0'));var util=require(_0x0190('0x1'));var moment=require(_0x0190('0x2'));var BPromise=require(_0x0190('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0190('0x4'));var db=require(_0x0190('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x0190('0x6'))(_0x0190('0x7'));var config=require('../../config/environment');var jayson=require(_0x0190('0x8'));var client=jayson['client'][_0x0190('0x9')]({'port':0x232a});function respondWithRpcPromise(_0xde2881,_0x645414,_0x58f426){return new BPromise(function(_0x432300,_0x504d77){return client[_0x0190('0xa')](_0xde2881,_0x58f426)[_0x0190('0xb')](function(_0x58dc67){logger[_0x0190('0xc')](_0x0190('0xd'),_0x645414,_0x0190('0xe'));logger[_0x0190('0xf')](_0x0190('0x10'),_0x645414,'request\x20sent',JSON[_0x0190('0x11')](_0x58dc67));if(_0x58dc67['error']){if(_0x58dc67['error'][_0x0190('0x12')]===0x1f4){logger['error'](_0x0190('0xd'),_0x645414,_0x58dc67['error']['message']);return _0x504d77(_0x58dc67[_0x0190('0x13')][_0x0190('0x14')]);}logger['error'](_0x0190('0xd'),_0x645414,_0x58dc67['error'][_0x0190('0x14')]);return _0x432300(_0x58dc67['error'][_0x0190('0x14')]);}else{logger[_0x0190('0xc')](_0x0190('0xd'),_0x645414,_0x0190('0xe'));_0x432300(_0x58dc67[_0x0190('0x15')][_0x0190('0x14')]);}})[_0x0190('0x16')](function(_0x3574ed){logger[_0x0190('0x13')](_0x0190('0xd'),_0x645414,_0x3574ed);_0x504d77(_0x3574ed);});});}exports[_0x0190('0x17')]=function(_0x65bdff){var _0x2c45b0=this;return new Promise(function(_0x260e6a,_0x32c9d6){return db[_0x0190('0x18')][_0x0190('0x19')]({'raw':_0x65bdff[_0x0190('0x1a')]?_0x65bdff[_0x0190('0x1a')][_0x0190('0x1b')]===undefined?!![]:![]:!![],'where':_0x65bdff[_0x0190('0x1a')]?_0x65bdff[_0x0190('0x1a')][_0x0190('0x1c')]||null:null,'attributes':_0x65bdff[_0x0190('0x1a')]?_0x65bdff[_0x0190('0x1a')][_0x0190('0x1d')]||null:null,'limit':_0x65bdff[_0x0190('0x1a')]?_0x65bdff[_0x0190('0x1a')]['limit']||null:null,'include':_0x65bdff['options']?_0x65bdff[_0x0190('0x1a')][_0x0190('0x1e')]?_[_0x0190('0x1f')](_0x65bdff[_0x0190('0x1a')]['include'],function(_0x2b4fd4){return{'model':db[_0x2b4fd4[_0x0190('0x20')]],'as':_0x2b4fd4['as'],'attributes':_0x2b4fd4[_0x0190('0x1d')],'include':_0x2b4fd4[_0x0190('0x1e')]?_[_0x0190('0x1f')](_0x2b4fd4[_0x0190('0x1e')],function(_0x1f2fad){return{'model':db[_0x1f2fad['model']],'as':_0x1f2fad['as'],'attributes':_0x1f2fad['attributes'],'include':_0x1f2fad[_0x0190('0x1e')]?_[_0x0190('0x1f')](_0x1f2fad[_0x0190('0x1e')],function(_0x4e5199){return{'model':db[_0x4e5199[_0x0190('0x20')]],'as':_0x4e5199['as'],'attributes':_0x4e5199[_0x0190('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x0190('0xb')](function(_0x1d55e2){logger['info']('GetVtigerAccount',_0x65bdff);logger[_0x0190('0xf')](_0x0190('0x17'),_0x65bdff,JSON[_0x0190('0x11')](_0x1d55e2));_0x260e6a(_0x1d55e2);})[_0x0190('0x16')](function(_0xcf5f09){logger[_0x0190('0x13')](_0x0190('0x17'),_0xcf5f09[_0x0190('0x14')],_0x65bdff);_0x32c9d6(_0x2c45b0[_0x0190('0x13')](0x1f4,_0xcf5f09['message']));});});};exports[_0x0190('0x21')]=function(_0x42aaa8){var _0x2312a6=this;return new Promise(function(_0x34290d,_0x2f9e57){return db['VtigerAccount'][_0x0190('0x22')]({'raw':_0x42aaa8[_0x0190('0x1a')]?_0x42aaa8[_0x0190('0x1a')][_0x0190('0x1b')]===undefined?!![]:![]:!![],'where':_0x42aaa8[_0x0190('0x1a')]?_0x42aaa8[_0x0190('0x1a')][_0x0190('0x1c')]||null:null,'attributes':_0x42aaa8[_0x0190('0x1a')]?_0x42aaa8[_0x0190('0x1a')][_0x0190('0x1d')]||null:null,'include':_0x42aaa8[_0x0190('0x1a')]?_0x42aaa8[_0x0190('0x1a')]['include']?_[_0x0190('0x1f')](_0x42aaa8[_0x0190('0x1a')][_0x0190('0x1e')],function(_0x166cfc){return{'model':db[_0x166cfc[_0x0190('0x20')]],'as':_0x166cfc['as'],'attributes':_0x166cfc[_0x0190('0x1d')],'include':_0x166cfc[_0x0190('0x1e')]?_[_0x0190('0x1f')](_0x166cfc['include'],function(_0x449e53){return{'model':db[_0x449e53['model']],'as':_0x449e53['as'],'attributes':_0x449e53[_0x0190('0x1d')],'include':_0x449e53['include']?_[_0x0190('0x1f')](_0x449e53[_0x0190('0x1e')],function(_0x107b32){return{'model':db[_0x107b32[_0x0190('0x20')]],'as':_0x107b32['as'],'attributes':_0x107b32[_0x0190('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1671e9){logger['info']('ShowVtigerAccount',_0x42aaa8);logger[_0x0190('0xf')](_0x0190('0x21'),_0x42aaa8,JSON[_0x0190('0x11')](_0x1671e9));_0x34290d(_0x1671e9);})[_0x0190('0x16')](function(_0x3ff377){logger[_0x0190('0x13')](_0x0190('0x21'),_0x3ff377['message'],_0x42aaa8);_0x2f9e57(_0x2312a6[_0x0190('0x13')](0x1f4,_0x3ff377[_0x0190('0x14')]));});});};