Built motion from commit f25620e4.|2.6.30
[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 _0x80cf=['../../config/utils','../../config/logger','../../config/environment','jayson/promise','request','then','info','SugarcrmAccount,\x20%s,\x20%s','SugarcrmAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','request\x20sent','result','catch','SugarcrmAccount','findAll','options','raw','where','attributes','limit','map','include','model','debug','GetSugarcrmAccount','ShowSugarcrmAccount','util','moment','ioredis'];(function(_0x45b479,_0x3e6574){var _0x1c3cbe=function(_0xd53e52){while(--_0xd53e52){_0x45b479['push'](_0x45b479['shift']());}};_0x1c3cbe(++_0x3e6574);}(_0x80cf,0x15d));var _0xf80c=function(_0x1ec8e2,_0x43a12b){_0x1ec8e2=_0x1ec8e2-0x0;var _0x407621=_0x80cf[_0x1ec8e2];return _0x407621;};'use strict';var _=require('lodash');var util=require(_0xf80c('0x0'));var moment=require(_0xf80c('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xf80c('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0xf80c('0x3'));var logger=require(_0xf80c('0x4'))('rpc');var config=require(_0xf80c('0x5'));var jayson=require(_0xf80c('0x6'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x10bf50,_0x119be0,_0x7e5a3b){return new BPromise(function(_0x374bdd,_0x223b09){return client[_0xf80c('0x7')](_0x10bf50,_0x7e5a3b)[_0xf80c('0x8')](function(_0xa6929e){logger[_0xf80c('0x9')](_0xf80c('0xa'),_0x119be0,'request\x20sent');logger['debug'](_0xf80c('0xb'),_0x119be0,'request\x20sent',JSON[_0xf80c('0xc')](_0xa6929e));if(_0xa6929e['error']){if(_0xa6929e[_0xf80c('0xd')][_0xf80c('0xe')]===0x1f4){logger['error'](_0xf80c('0xa'),_0x119be0,_0xa6929e['error'][_0xf80c('0xf')]);return _0x223b09(_0xa6929e[_0xf80c('0xd')][_0xf80c('0xf')]);}logger['error'](_0xf80c('0xa'),_0x119be0,_0xa6929e[_0xf80c('0xd')]['message']);return _0x374bdd(_0xa6929e[_0xf80c('0xd')][_0xf80c('0xf')]);}else{logger['info'](_0xf80c('0xa'),_0x119be0,_0xf80c('0x10'));_0x374bdd(_0xa6929e[_0xf80c('0x11')][_0xf80c('0xf')]);}})[_0xf80c('0x12')](function(_0x3efe0a){logger[_0xf80c('0xd')](_0xf80c('0xa'),_0x119be0,_0x3efe0a);_0x223b09(_0x3efe0a);});});}exports['GetSugarcrmAccount']=function(_0x4edd22){var _0x20cb45=this;return new Promise(function(_0x1851e5,_0x2fb023){return db[_0xf80c('0x13')][_0xf80c('0x14')]({'raw':_0x4edd22[_0xf80c('0x15')]?_0x4edd22[_0xf80c('0x15')][_0xf80c('0x16')]===undefined?!![]:![]:!![],'where':_0x4edd22[_0xf80c('0x15')]?_0x4edd22[_0xf80c('0x15')][_0xf80c('0x17')]||null:null,'attributes':_0x4edd22[_0xf80c('0x15')]?_0x4edd22['options'][_0xf80c('0x18')]||null:null,'limit':_0x4edd22['options']?_0x4edd22[_0xf80c('0x15')][_0xf80c('0x19')]||null:null,'include':_0x4edd22['options']?_0x4edd22[_0xf80c('0x15')]['include']?_[_0xf80c('0x1a')](_0x4edd22[_0xf80c('0x15')][_0xf80c('0x1b')],function(_0xed9ce6){return{'model':db[_0xed9ce6[_0xf80c('0x1c')]],'as':_0xed9ce6['as'],'attributes':_0xed9ce6[_0xf80c('0x18')],'include':_0xed9ce6['include']?_['map'](_0xed9ce6[_0xf80c('0x1b')],function(_0x126ad4){return{'model':db[_0x126ad4[_0xf80c('0x1c')]],'as':_0x126ad4['as'],'attributes':_0x126ad4[_0xf80c('0x18')],'include':_0x126ad4[_0xf80c('0x1b')]?_['map'](_0x126ad4[_0xf80c('0x1b')],function(_0x4c7e3d){return{'model':db[_0x4c7e3d['model']],'as':_0x4c7e3d['as'],'attributes':_0x4c7e3d[_0xf80c('0x18')]};}):[]};}):[]};}):[]:[]})[_0xf80c('0x8')](function(_0x3121e5){logger[_0xf80c('0x9')]('GetSugarcrmAccount',_0x4edd22);logger[_0xf80c('0x1d')](_0xf80c('0x1e'),_0x4edd22,JSON[_0xf80c('0xc')](_0x3121e5));_0x1851e5(_0x3121e5);})[_0xf80c('0x12')](function(_0xf9785e){logger[_0xf80c('0xd')](_0xf80c('0x1e'),_0xf9785e[_0xf80c('0xf')],_0x4edd22);_0x2fb023(_0x20cb45[_0xf80c('0xd')](0x1f4,_0xf9785e[_0xf80c('0xf')]));});});};exports[_0xf80c('0x1f')]=function(_0x34f6dd){var _0xa8fa3f=this;return new Promise(function(_0x157f05,_0x12008c){return db[_0xf80c('0x13')]['find']({'raw':_0x34f6dd[_0xf80c('0x15')]?_0x34f6dd[_0xf80c('0x15')][_0xf80c('0x16')]===undefined?!![]:![]:!![],'where':_0x34f6dd[_0xf80c('0x15')]?_0x34f6dd[_0xf80c('0x15')][_0xf80c('0x17')]||null:null,'attributes':_0x34f6dd['options']?_0x34f6dd[_0xf80c('0x15')][_0xf80c('0x18')]||null:null,'include':_0x34f6dd['options']?_0x34f6dd['options'][_0xf80c('0x1b')]?_['map'](_0x34f6dd['options'][_0xf80c('0x1b')],function(_0x41a285){return{'model':db[_0x41a285[_0xf80c('0x1c')]],'as':_0x41a285['as'],'attributes':_0x41a285[_0xf80c('0x18')],'include':_0x41a285[_0xf80c('0x1b')]?_[_0xf80c('0x1a')](_0x41a285[_0xf80c('0x1b')],function(_0x4574f7){return{'model':db[_0x4574f7[_0xf80c('0x1c')]],'as':_0x4574f7['as'],'attributes':_0x4574f7[_0xf80c('0x18')],'include':_0x4574f7[_0xf80c('0x1b')]?_[_0xf80c('0x1a')](_0x4574f7[_0xf80c('0x1b')],function(_0x1c66cf){return{'model':db[_0x1c66cf[_0xf80c('0x1c')]],'as':_0x1c66cf['as'],'attributes':_0x1c66cf[_0xf80c('0x18')]};}):[]};}):[]};}):[]:[]})[_0xf80c('0x8')](function(_0xbfb66e){logger['info'](_0xf80c('0x1f'),_0x34f6dd);logger[_0xf80c('0x1d')](_0xf80c('0x1f'),_0x34f6dd,JSON['stringify'](_0xbfb66e));_0x157f05(_0xbfb66e);})[_0xf80c('0x12')](function(_0x495325){logger['error'](_0xf80c('0x1f'),_0x495325[_0xf80c('0xf')],_0x34f6dd);_0x12008c(_0xa8fa3f['error'](0x1f4,_0x495325['message']));});});};