Built motion from commit (unavailable).|2.0.72
[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 _0x9084=['SugarcrmAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','GetSugarcrmAccount','SugarcrmAccount','findAll','options','raw','where','attributes','limit','include','map','model','then','ShowSugarcrmAccount','debug','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','request','info','SugarcrmAccount,\x20%s,\x20%s'];(function(_0x312440,_0x10c4aa){var _0x145314=function(_0x508530){while(--_0x508530){_0x312440['push'](_0x312440['shift']());}};_0x145314(++_0x10c4aa);}(_0x9084,0xcf));var _0x4908=function(_0xd2be97,_0x4952d2){_0xd2be97=_0xd2be97-0x0;var _0xb112f5=_0x9084[_0xd2be97];return _0xb112f5;};'use strict';var _=require(_0x4908('0x0'));var util=require(_0x4908('0x1'));var moment=require(_0x4908('0x2'));var BPromise=require(_0x4908('0x3'));var rs=require(_0x4908('0x4'));var fs=require('fs');var db=require(_0x4908('0x5'))['db'];var utils=require(_0x4908('0x6'));var logger=require(_0x4908('0x7'))('rpc');var config=require(_0x4908('0x8'));var jayson=require(_0x4908('0x9'));var client=jayson[_0x4908('0xa')][_0x4908('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x40349d,_0x46f048,_0x5ea11c){return new BPromise(function(_0x2640d8,_0x42a57c){return client[_0x4908('0xc')](_0x40349d,_0x5ea11c)['then'](function(_0x3e5a83){logger[_0x4908('0xd')](_0x4908('0xe'),_0x46f048,'request\x20sent');logger['debug'](_0x4908('0xf'),_0x46f048,_0x4908('0x10'),JSON[_0x4908('0x11')](_0x3e5a83));if(_0x3e5a83[_0x4908('0x12')]){if(_0x3e5a83['error'][_0x4908('0x13')]===0x1f4){logger[_0x4908('0x12')](_0x4908('0xe'),_0x46f048,_0x3e5a83[_0x4908('0x12')][_0x4908('0x14')]);return _0x42a57c(_0x3e5a83[_0x4908('0x12')][_0x4908('0x14')]);}logger['error']('SugarcrmAccount,\x20%s,\x20%s',_0x46f048,_0x3e5a83[_0x4908('0x12')]['message']);return _0x2640d8(_0x3e5a83[_0x4908('0x12')][_0x4908('0x14')]);}else{logger[_0x4908('0xd')](_0x4908('0xe'),_0x46f048,_0x4908('0x10'));_0x2640d8(_0x3e5a83[_0x4908('0x15')][_0x4908('0x14')]);}})[_0x4908('0x16')](function(_0x50390c){logger[_0x4908('0x12')]('SugarcrmAccount,\x20%s,\x20%s',_0x46f048,_0x50390c);_0x42a57c(_0x50390c);});});}exports[_0x4908('0x17')]=function(_0x166074){var _0x4cb8bb=this;return new Promise(function(_0x5e88af,_0xdfbcdb){return db[_0x4908('0x18')][_0x4908('0x19')]({'raw':_0x166074[_0x4908('0x1a')]?_0x166074[_0x4908('0x1a')][_0x4908('0x1b')]===undefined?!![]:![]:!![],'where':_0x166074[_0x4908('0x1a')]?_0x166074[_0x4908('0x1a')][_0x4908('0x1c')]||null:null,'attributes':_0x166074[_0x4908('0x1a')]?_0x166074['options'][_0x4908('0x1d')]||null:null,'limit':_0x166074[_0x4908('0x1a')]?_0x166074['options'][_0x4908('0x1e')]||null:null,'include':_0x166074[_0x4908('0x1a')]?_0x166074['options'][_0x4908('0x1f')]?_[_0x4908('0x20')](_0x166074[_0x4908('0x1a')][_0x4908('0x1f')],function(_0x41eb2f){return{'model':db[_0x41eb2f[_0x4908('0x21')]],'as':_0x41eb2f['as'],'attributes':_0x41eb2f[_0x4908('0x1d')],'include':_0x41eb2f[_0x4908('0x1f')]?_['map'](_0x41eb2f[_0x4908('0x1f')],function(_0x33c9fb){return{'model':db[_0x33c9fb[_0x4908('0x21')]],'as':_0x33c9fb['as'],'attributes':_0x33c9fb[_0x4908('0x1d')],'include':_0x33c9fb[_0x4908('0x1f')]?_[_0x4908('0x20')](_0x33c9fb[_0x4908('0x1f')],function(_0x3d66b3){return{'model':db[_0x3d66b3['model']],'as':_0x3d66b3['as'],'attributes':_0x3d66b3[_0x4908('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x4908('0x22')](function(_0x53a347){logger[_0x4908('0xd')]('GetSugarcrmAccount',_0x166074);logger['debug']('GetSugarcrmAccount',_0x166074,JSON[_0x4908('0x11')](_0x53a347));_0x5e88af(_0x53a347);})[_0x4908('0x16')](function(_0x320c2f){logger[_0x4908('0x12')](_0x4908('0x17'),_0x320c2f[_0x4908('0x14')],_0x166074);_0xdfbcdb(_0x4cb8bb[_0x4908('0x12')](0x1f4,_0x320c2f['message']));});});};exports[_0x4908('0x23')]=function(_0x2c7baa){var _0x3f821c=this;return new Promise(function(_0x2bc339,_0x1c3345){return db[_0x4908('0x18')]['find']({'raw':_0x2c7baa[_0x4908('0x1a')]?_0x2c7baa[_0x4908('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x2c7baa[_0x4908('0x1a')]?_0x2c7baa['options'][_0x4908('0x1c')]||null:null,'attributes':_0x2c7baa[_0x4908('0x1a')]?_0x2c7baa[_0x4908('0x1a')]['attributes']||null:null,'include':_0x2c7baa[_0x4908('0x1a')]?_0x2c7baa[_0x4908('0x1a')][_0x4908('0x1f')]?_[_0x4908('0x20')](_0x2c7baa[_0x4908('0x1a')][_0x4908('0x1f')],function(_0x25f132){return{'model':db[_0x25f132[_0x4908('0x21')]],'as':_0x25f132['as'],'attributes':_0x25f132[_0x4908('0x1d')],'include':_0x25f132[_0x4908('0x1f')]?_[_0x4908('0x20')](_0x25f132['include'],function(_0xf79fd2){return{'model':db[_0xf79fd2[_0x4908('0x21')]],'as':_0xf79fd2['as'],'attributes':_0xf79fd2[_0x4908('0x1d')],'include':_0xf79fd2[_0x4908('0x1f')]?_[_0x4908('0x20')](_0xf79fd2[_0x4908('0x1f')],function(_0x5a1232){return{'model':db[_0x5a1232[_0x4908('0x21')]],'as':_0x5a1232['as'],'attributes':_0x5a1232[_0x4908('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x4908('0x22')](function(_0x5b457d){logger['info'](_0x4908('0x23'),_0x2c7baa);logger[_0x4908('0x24')](_0x4908('0x23'),_0x2c7baa,JSON[_0x4908('0x11')](_0x5b457d));_0x2bc339(_0x5b457d);})[_0x4908('0x16')](function(_0x306f57){logger[_0x4908('0x12')]('ShowSugarcrmAccount',_0x306f57['message'],_0x2c7baa);_0x1c3345(_0x3f821c[_0x4908('0x12')](0x1f4,_0x306f57[_0x4908('0x14')]));});});};