Built motion from commit (unavailable).|2.5.14
[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 _0x56fc=['../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','then','debug','request\x20sent','stringify','error','code','SugarcrmAccount,\x20%s,\x20%s','message','info','result','catch','GetSugarcrmAccount','SugarcrmAccount','findAll','options','where','attributes','limit','include','map','model','ShowSugarcrmAccount','find','util','bluebird','../../mysqldb'];(function(_0x134804,_0x6f47b1){var _0x284b8d=function(_0x5bf290){while(--_0x5bf290){_0x134804['push'](_0x134804['shift']());}};_0x284b8d(++_0x6f47b1);}(_0x56fc,0x189));var _0xc56f=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x56fc[_0x3dd15e];return _0x231fd0;};'use strict';var _=require('lodash');var util=require(_0xc56f('0x0'));var moment=require('moment');var BPromise=require(_0xc56f('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xc56f('0x2'))['db'];var utils=require(_0xc56f('0x3'));var logger=require(_0xc56f('0x4'))(_0xc56f('0x5'));var config=require(_0xc56f('0x6'));var jayson=require('jayson/promise');var client=jayson[_0xc56f('0x7')][_0xc56f('0x8')]({'port':0x232a});function respondWithRpcPromise(_0xd0e293,_0x5b536b,_0x3a3fb6){return new BPromise(function(_0x2df1da,_0x126d72){return client[_0xc56f('0x9')](_0xd0e293,_0x3a3fb6)[_0xc56f('0xa')](function(_0x108e8b){logger['info']('SugarcrmAccount,\x20%s,\x20%s',_0x5b536b,'request\x20sent');logger[_0xc56f('0xb')]('SugarcrmAccount,\x20%s,\x20%s,\x20%s',_0x5b536b,_0xc56f('0xc'),JSON[_0xc56f('0xd')](_0x108e8b));if(_0x108e8b[_0xc56f('0xe')]){if(_0x108e8b[_0xc56f('0xe')][_0xc56f('0xf')]===0x1f4){logger[_0xc56f('0xe')](_0xc56f('0x10'),_0x5b536b,_0x108e8b[_0xc56f('0xe')][_0xc56f('0x11')]);return _0x126d72(_0x108e8b[_0xc56f('0xe')]['message']);}logger['error'](_0xc56f('0x10'),_0x5b536b,_0x108e8b[_0xc56f('0xe')]['message']);return _0x2df1da(_0x108e8b[_0xc56f('0xe')][_0xc56f('0x11')]);}else{logger[_0xc56f('0x12')](_0xc56f('0x10'),_0x5b536b,_0xc56f('0xc'));_0x2df1da(_0x108e8b[_0xc56f('0x13')]['message']);}})[_0xc56f('0x14')](function(_0x10645a){logger['error']('SugarcrmAccount,\x20%s,\x20%s',_0x5b536b,_0x10645a);_0x126d72(_0x10645a);});});}exports[_0xc56f('0x15')]=function(_0x1316b9){var _0x20cd98=this;return new Promise(function(_0x3a5df0,_0x34c7fe){return db[_0xc56f('0x16')][_0xc56f('0x17')]({'raw':_0x1316b9[_0xc56f('0x18')]?_0x1316b9[_0xc56f('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x1316b9['options']?_0x1316b9[_0xc56f('0x18')][_0xc56f('0x19')]||null:null,'attributes':_0x1316b9[_0xc56f('0x18')]?_0x1316b9[_0xc56f('0x18')][_0xc56f('0x1a')]||null:null,'limit':_0x1316b9[_0xc56f('0x18')]?_0x1316b9['options'][_0xc56f('0x1b')]||null:null,'include':_0x1316b9[_0xc56f('0x18')]?_0x1316b9[_0xc56f('0x18')][_0xc56f('0x1c')]?_[_0xc56f('0x1d')](_0x1316b9[_0xc56f('0x18')]['include'],function(_0x1591b2){return{'model':db[_0x1591b2[_0xc56f('0x1e')]],'as':_0x1591b2['as'],'attributes':_0x1591b2['attributes'],'include':_0x1591b2['include']?_['map'](_0x1591b2['include'],function(_0x21a371){return{'model':db[_0x21a371[_0xc56f('0x1e')]],'as':_0x21a371['as'],'attributes':_0x21a371[_0xc56f('0x1a')],'include':_0x21a371[_0xc56f('0x1c')]?_[_0xc56f('0x1d')](_0x21a371['include'],function(_0x19d89f){return{'model':db[_0x19d89f[_0xc56f('0x1e')]],'as':_0x19d89f['as'],'attributes':_0x19d89f['attributes']};}):[]};}):[]};}):[]:[]})[_0xc56f('0xa')](function(_0x4bd87a){logger[_0xc56f('0x12')]('GetSugarcrmAccount',_0x1316b9);logger['debug'](_0xc56f('0x15'),_0x1316b9,JSON[_0xc56f('0xd')](_0x4bd87a));_0x3a5df0(_0x4bd87a);})[_0xc56f('0x14')](function(_0x34ae74){logger[_0xc56f('0xe')](_0xc56f('0x15'),_0x34ae74['message'],_0x1316b9);_0x34c7fe(_0x20cd98[_0xc56f('0xe')](0x1f4,_0x34ae74[_0xc56f('0x11')]));});});};exports[_0xc56f('0x1f')]=function(_0x300989){var _0xbc6c3d=this;return new Promise(function(_0x383fd3,_0x18fc1a){return db[_0xc56f('0x16')][_0xc56f('0x20')]({'raw':_0x300989[_0xc56f('0x18')]?_0x300989['options']['raw']===undefined?!![]:![]:!![],'where':_0x300989[_0xc56f('0x18')]?_0x300989[_0xc56f('0x18')]['where']||null:null,'attributes':_0x300989[_0xc56f('0x18')]?_0x300989[_0xc56f('0x18')][_0xc56f('0x1a')]||null:null,'include':_0x300989[_0xc56f('0x18')]?_0x300989[_0xc56f('0x18')]['include']?_[_0xc56f('0x1d')](_0x300989[_0xc56f('0x18')][_0xc56f('0x1c')],function(_0x35e875){return{'model':db[_0x35e875[_0xc56f('0x1e')]],'as':_0x35e875['as'],'attributes':_0x35e875['attributes'],'include':_0x35e875[_0xc56f('0x1c')]?_[_0xc56f('0x1d')](_0x35e875[_0xc56f('0x1c')],function(_0x59dea6){return{'model':db[_0x59dea6[_0xc56f('0x1e')]],'as':_0x59dea6['as'],'attributes':_0x59dea6['attributes'],'include':_0x59dea6[_0xc56f('0x1c')]?_[_0xc56f('0x1d')](_0x59dea6['include'],function(_0x26907b){return{'model':db[_0x26907b[_0xc56f('0x1e')]],'as':_0x26907b['as'],'attributes':_0x26907b['attributes']};}):[]};}):[]};}):[]:[]})[_0xc56f('0xa')](function(_0x73e348){logger[_0xc56f('0x12')]('ShowSugarcrmAccount',_0x300989);logger[_0xc56f('0xb')](_0xc56f('0x1f'),_0x300989,JSON[_0xc56f('0xd')](_0x73e348));_0x383fd3(_0x73e348);})['catch'](function(_0x4aac75){logger[_0xc56f('0xe')]('ShowSugarcrmAccount',_0x4aac75['message'],_0x300989);_0x18fc1a(_0xbc6c3d[_0xc56f('0xe')](0x1f4,_0x4aac75[_0xc56f('0x11')]));});});};