Built motion from commit (unavailable).|2.5.4
[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 _0x537f=['VtigerAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','VtigerAccount','options','raw','limit','include','map','model','attributes','GetVtigerAccount','find','where','ShowVtigerAccount','util','moment','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','client','http','request','then','info','VtigerAccount,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x5f55c6,_0x2f3797){var _0x56605d=function(_0x3de233){while(--_0x3de233){_0x5f55c6['push'](_0x5f55c6['shift']());}};_0x56605d(++_0x2f3797);}(_0x537f,0x1e0));var _0xf537=function(_0x52e876,_0x390b3b){_0x52e876=_0x52e876-0x0;var _0x579b98=_0x537f[_0x52e876];return _0x579b98;};'use strict';var _=require('lodash');var util=require(_0xf537('0x0'));var moment=require(_0xf537('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xf537('0x2'));var db=require(_0xf537('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0xf537('0x4'))(_0xf537('0x5'));var config=require(_0xf537('0x6'));var jayson=require('jayson/promise');var client=jayson[_0xf537('0x7')][_0xf537('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x55891e,_0x30387a,_0xa19af0){return new BPromise(function(_0x4de4a4,_0x550cc8){return client[_0xf537('0x9')](_0x55891e,_0xa19af0)[_0xf537('0xa')](function(_0x76b370){logger[_0xf537('0xb')](_0xf537('0xc'),_0x30387a,_0xf537('0xd'));logger[_0xf537('0xe')](_0xf537('0xf'),_0x30387a,_0xf537('0xd'),JSON[_0xf537('0x10')](_0x76b370));if(_0x76b370[_0xf537('0x11')]){if(_0x76b370[_0xf537('0x11')][_0xf537('0x12')]===0x1f4){logger[_0xf537('0x11')](_0xf537('0xc'),_0x30387a,_0x76b370[_0xf537('0x11')]['message']);return _0x550cc8(_0x76b370[_0xf537('0x11')][_0xf537('0x13')]);}logger[_0xf537('0x11')]('VtigerAccount,\x20%s,\x20%s',_0x30387a,_0x76b370['error'][_0xf537('0x13')]);return _0x4de4a4(_0x76b370[_0xf537('0x11')][_0xf537('0x13')]);}else{logger['info'](_0xf537('0xc'),_0x30387a,_0xf537('0xd'));_0x4de4a4(_0x76b370['result'][_0xf537('0x13')]);}})[_0xf537('0x14')](function(_0x1d048a){logger[_0xf537('0x11')]('VtigerAccount,\x20%s,\x20%s',_0x30387a,_0x1d048a);_0x550cc8(_0x1d048a);});});}exports['GetVtigerAccount']=function(_0x313d96){var _0x569db1=this;return new Promise(function(_0xbcc6f3,_0x381bf7){return db[_0xf537('0x15')]['findAll']({'raw':_0x313d96[_0xf537('0x16')]?_0x313d96[_0xf537('0x16')][_0xf537('0x17')]===undefined?!![]:![]:!![],'where':_0x313d96[_0xf537('0x16')]?_0x313d96[_0xf537('0x16')]['where']||null:null,'attributes':_0x313d96[_0xf537('0x16')]?_0x313d96[_0xf537('0x16')]['attributes']||null:null,'limit':_0x313d96['options']?_0x313d96[_0xf537('0x16')][_0xf537('0x18')]||null:null,'include':_0x313d96[_0xf537('0x16')]?_0x313d96[_0xf537('0x16')][_0xf537('0x19')]?_[_0xf537('0x1a')](_0x313d96[_0xf537('0x16')][_0xf537('0x19')],function(_0x1e4bf9){return{'model':db[_0x1e4bf9['model']],'as':_0x1e4bf9['as'],'attributes':_0x1e4bf9['attributes'],'include':_0x1e4bf9[_0xf537('0x19')]?_['map'](_0x1e4bf9[_0xf537('0x19')],function(_0x1188eb){return{'model':db[_0x1188eb[_0xf537('0x1b')]],'as':_0x1188eb['as'],'attributes':_0x1188eb[_0xf537('0x1c')],'include':_0x1188eb[_0xf537('0x19')]?_['map'](_0x1188eb[_0xf537('0x19')],function(_0x288cf0){return{'model':db[_0x288cf0[_0xf537('0x1b')]],'as':_0x288cf0['as'],'attributes':_0x288cf0[_0xf537('0x1c')]};}):[]};}):[]};}):[]:[]})[_0xf537('0xa')](function(_0x3c8470){logger[_0xf537('0xb')]('GetVtigerAccount',_0x313d96);logger['debug'](_0xf537('0x1d'),_0x313d96,JSON[_0xf537('0x10')](_0x3c8470));_0xbcc6f3(_0x3c8470);})['catch'](function(_0x104a17){logger[_0xf537('0x11')]('GetVtigerAccount',_0x104a17[_0xf537('0x13')],_0x313d96);_0x381bf7(_0x569db1['error'](0x1f4,_0x104a17['message']));});});};exports['ShowVtigerAccount']=function(_0x3653c7){var _0x4a272f=this;return new Promise(function(_0x4a3182,_0xa5ae8c){return db['VtigerAccount'][_0xf537('0x1e')]({'raw':_0x3653c7[_0xf537('0x16')]?_0x3653c7['options'][_0xf537('0x17')]===undefined?!![]:![]:!![],'where':_0x3653c7[_0xf537('0x16')]?_0x3653c7['options'][_0xf537('0x1f')]||null:null,'attributes':_0x3653c7[_0xf537('0x16')]?_0x3653c7[_0xf537('0x16')][_0xf537('0x1c')]||null:null,'include':_0x3653c7['options']?_0x3653c7['options'][_0xf537('0x19')]?_['map'](_0x3653c7['options'][_0xf537('0x19')],function(_0x56f787){return{'model':db[_0x56f787[_0xf537('0x1b')]],'as':_0x56f787['as'],'attributes':_0x56f787['attributes'],'include':_0x56f787[_0xf537('0x19')]?_[_0xf537('0x1a')](_0x56f787['include'],function(_0x663b24){return{'model':db[_0x663b24[_0xf537('0x1b')]],'as':_0x663b24['as'],'attributes':_0x663b24[_0xf537('0x1c')],'include':_0x663b24['include']?_[_0xf537('0x1a')](_0x663b24[_0xf537('0x19')],function(_0x4d6292){return{'model':db[_0x4d6292[_0xf537('0x1b')]],'as':_0x4d6292['as'],'attributes':_0x4d6292[_0xf537('0x1c')]};}):[]};}):[]};}):[]:[]})[_0xf537('0xa')](function(_0x5b5d37){logger['info'](_0xf537('0x20'),_0x3653c7);logger['debug'](_0xf537('0x20'),_0x3653c7,JSON[_0xf537('0x10')](_0x5b5d37));_0x4a3182(_0x5b5d37);})[_0xf537('0x14')](function(_0x5ae589){logger[_0xf537('0x11')]('ShowVtigerAccount',_0x5ae589['message'],_0x3653c7);_0xa5ae8c(_0x4a272f[_0xf537('0x11')](0x1f4,_0x5ae589[_0xf537('0x13')]));});});};