672d1643cd141c2758bfa1552f168ea668ac42c0
[motion2.git] / server / api / intSugarcrmAccount / intSugarcrmAccount.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 _0x7d39=['randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','http','request','then','info','SugarcrmAccount,\x20%s,\x20%s','SugarcrmAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','GetSugarcrmAccount','SugarcrmAccount','findAll','options','raw','where','attributes','include','map','model','ShowSugarcrmAccount','find','debug','lodash','moment','bluebird'];(function(_0x2aee46,_0x183d19){var _0x11117f=function(_0x506f25){while(--_0x506f25){_0x2aee46['push'](_0x2aee46['shift']());}};_0x11117f(++_0x183d19);}(_0x7d39,0x89));var _0x97d3=function(_0x5b3e47,_0x31ee5f){_0x5b3e47=_0x5b3e47-0x0;var _0x31c9a1=_0x7d39[_0x5b3e47];return _0x31c9a1;};'use strict';var _=require(_0x97d3('0x0'));var util=require('util');var moment=require(_0x97d3('0x1'));var BPromise=require(_0x97d3('0x2'));var rs=require(_0x97d3('0x3'));var fs=require('fs');var Redis=require(_0x97d3('0x4'));var db=require(_0x97d3('0x5'))['db'];var utils=require(_0x97d3('0x6'));var logger=require('../../config/logger')(_0x97d3('0x7'));var config=require(_0x97d3('0x8'));var jayson=require(_0x97d3('0x9'));var client=jayson['client'][_0x97d3('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x52e805,_0x245528,_0x370101){return new BPromise(function(_0x36f70a,_0x585c3f){return client[_0x97d3('0xb')](_0x52e805,_0x370101)[_0x97d3('0xc')](function(_0x305d4e){logger[_0x97d3('0xd')](_0x97d3('0xe'),_0x245528,'request\x20sent');logger['debug'](_0x97d3('0xf'),_0x245528,_0x97d3('0x10'),JSON[_0x97d3('0x11')](_0x305d4e));if(_0x305d4e['error']){if(_0x305d4e[_0x97d3('0x12')]['code']===0x1f4){logger[_0x97d3('0x12')]('SugarcrmAccount,\x20%s,\x20%s',_0x245528,_0x305d4e[_0x97d3('0x12')][_0x97d3('0x13')]);return _0x585c3f(_0x305d4e['error'][_0x97d3('0x13')]);}logger[_0x97d3('0x12')](_0x97d3('0xe'),_0x245528,_0x305d4e[_0x97d3('0x12')][_0x97d3('0x13')]);return _0x36f70a(_0x305d4e[_0x97d3('0x12')][_0x97d3('0x13')]);}else{logger[_0x97d3('0xd')](_0x97d3('0xe'),_0x245528,'request\x20sent');_0x36f70a(_0x305d4e[_0x97d3('0x14')][_0x97d3('0x13')]);}})[_0x97d3('0x15')](function(_0x31f35c){logger['error']('SugarcrmAccount,\x20%s,\x20%s',_0x245528,_0x31f35c);_0x585c3f(_0x31f35c);});});}exports[_0x97d3('0x16')]=function(_0x2e4098){var _0xe813d7=this;return new Promise(function(_0x5bc30d,_0x253b2d){return db[_0x97d3('0x17')][_0x97d3('0x18')]({'raw':_0x2e4098[_0x97d3('0x19')]?_0x2e4098[_0x97d3('0x19')][_0x97d3('0x1a')]===undefined?!![]:![]:!![],'where':_0x2e4098[_0x97d3('0x19')]?_0x2e4098[_0x97d3('0x19')][_0x97d3('0x1b')]||null:null,'attributes':_0x2e4098['options']?_0x2e4098['options'][_0x97d3('0x1c')]||null:null,'limit':_0x2e4098[_0x97d3('0x19')]?_0x2e4098[_0x97d3('0x19')]['limit']||null:null,'include':_0x2e4098[_0x97d3('0x19')]?_0x2e4098['options'][_0x97d3('0x1d')]?_[_0x97d3('0x1e')](_0x2e4098[_0x97d3('0x19')]['include'],function(_0x2e7852){return{'model':db[_0x2e7852[_0x97d3('0x1f')]],'as':_0x2e7852['as'],'attributes':_0x2e7852[_0x97d3('0x1c')],'include':_0x2e7852[_0x97d3('0x1d')]?_[_0x97d3('0x1e')](_0x2e7852[_0x97d3('0x1d')],function(_0x213830){return{'model':db[_0x213830[_0x97d3('0x1f')]],'as':_0x213830['as'],'attributes':_0x213830[_0x97d3('0x1c')],'include':_0x213830['include']?_['map'](_0x213830[_0x97d3('0x1d')],function(_0x684678){return{'model':db[_0x684678[_0x97d3('0x1f')]],'as':_0x684678['as'],'attributes':_0x684678[_0x97d3('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x97d3('0xc')](function(_0x13d891){logger[_0x97d3('0xd')](_0x97d3('0x16'),_0x2e4098);logger['debug'](_0x97d3('0x16'),_0x2e4098,JSON[_0x97d3('0x11')](_0x13d891));_0x5bc30d(_0x13d891);})[_0x97d3('0x15')](function(_0x15d1ea){logger[_0x97d3('0x12')](_0x97d3('0x16'),_0x15d1ea[_0x97d3('0x13')],_0x2e4098);_0x253b2d(_0xe813d7[_0x97d3('0x12')](0x1f4,_0x15d1ea[_0x97d3('0x13')]));});});};exports[_0x97d3('0x20')]=function(_0x4c3e28){var _0x24e6eb=this;return new Promise(function(_0x1c845f,_0x42753f){return db['SugarcrmAccount'][_0x97d3('0x21')]({'raw':_0x4c3e28[_0x97d3('0x19')]?_0x4c3e28[_0x97d3('0x19')][_0x97d3('0x1a')]===undefined?!![]:![]:!![],'where':_0x4c3e28[_0x97d3('0x19')]?_0x4c3e28[_0x97d3('0x19')][_0x97d3('0x1b')]||null:null,'attributes':_0x4c3e28[_0x97d3('0x19')]?_0x4c3e28['options'][_0x97d3('0x1c')]||null:null,'include':_0x4c3e28['options']?_0x4c3e28[_0x97d3('0x19')][_0x97d3('0x1d')]?_[_0x97d3('0x1e')](_0x4c3e28[_0x97d3('0x19')][_0x97d3('0x1d')],function(_0x231def){return{'model':db[_0x231def[_0x97d3('0x1f')]],'as':_0x231def['as'],'attributes':_0x231def[_0x97d3('0x1c')],'include':_0x231def[_0x97d3('0x1d')]?_[_0x97d3('0x1e')](_0x231def[_0x97d3('0x1d')],function(_0x51b9a8){return{'model':db[_0x51b9a8[_0x97d3('0x1f')]],'as':_0x51b9a8['as'],'attributes':_0x51b9a8[_0x97d3('0x1c')],'include':_0x51b9a8[_0x97d3('0x1d')]?_[_0x97d3('0x1e')](_0x51b9a8[_0x97d3('0x1d')],function(_0x3f159b){return{'model':db[_0x3f159b[_0x97d3('0x1f')]],'as':_0x3f159b['as'],'attributes':_0x3f159b[_0x97d3('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x97d3('0xc')](function(_0x9e8ecd){logger[_0x97d3('0xd')](_0x97d3('0x20'),_0x4c3e28);logger[_0x97d3('0x22')](_0x97d3('0x20'),_0x4c3e28,JSON['stringify'](_0x9e8ecd));_0x1c845f(_0x9e8ecd);})[_0x97d3('0x15')](function(_0x49b801){logger[_0x97d3('0x12')](_0x97d3('0x20'),_0x49b801['message'],_0x4c3e28);_0x42753f(_0x24e6eb[_0x97d3('0x12')](0x1f4,_0x49b801['message']));});});};