Built motion from commit (unavailable).|2.5.25
[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 _0xdd88=['randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','stringify','error','SugarcrmAccount,\x20%s,\x20%s','message','info','request\x20sent','GetSugarcrmAccount','findAll','options','raw','where','limit','map','model','include','attributes','then','debug','ShowSugarcrmAccount','SugarcrmAccount','find','catch','lodash','util'];(function(_0x14bbdc,_0x3828fa){var _0x18aa19=function(_0x4bf890){while(--_0x4bf890){_0x14bbdc['push'](_0x14bbdc['shift']());}};_0x18aa19(++_0x3828fa);}(_0xdd88,0xa8));var _0x8dd8=function(_0x59f962,_0x62fc73){_0x59f962=_0x59f962-0x0;var _0x23808f=_0xdd88[_0x59f962];return _0x23808f;};'use strict';var _=require(_0x8dd8('0x0'));var util=require(_0x8dd8('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x8dd8('0x2'));var fs=require('fs');var Redis=require(_0x8dd8('0x3'));var db=require(_0x8dd8('0x4'))['db'];var utils=require(_0x8dd8('0x5'));var logger=require(_0x8dd8('0x6'))(_0x8dd8('0x7'));var config=require(_0x8dd8('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x8dd8('0x9')][_0x8dd8('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x37c861,_0x22974d,_0x1713f5){return new BPromise(function(_0xf346af,_0x5d7eac){return client[_0x8dd8('0xb')](_0x37c861,_0x1713f5)['then'](function(_0x1b4287){logger['info']('SugarcrmAccount,\x20%s,\x20%s',_0x22974d,'request\x20sent');logger['debug']('SugarcrmAccount,\x20%s,\x20%s,\x20%s',_0x22974d,'request\x20sent',JSON[_0x8dd8('0xc')](_0x1b4287));if(_0x1b4287[_0x8dd8('0xd')]){if(_0x1b4287['error']['code']===0x1f4){logger[_0x8dd8('0xd')](_0x8dd8('0xe'),_0x22974d,_0x1b4287[_0x8dd8('0xd')][_0x8dd8('0xf')]);return _0x5d7eac(_0x1b4287[_0x8dd8('0xd')]['message']);}logger[_0x8dd8('0xd')]('SugarcrmAccount,\x20%s,\x20%s',_0x22974d,_0x1b4287[_0x8dd8('0xd')][_0x8dd8('0xf')]);return _0xf346af(_0x1b4287[_0x8dd8('0xd')][_0x8dd8('0xf')]);}else{logger[_0x8dd8('0x10')](_0x8dd8('0xe'),_0x22974d,_0x8dd8('0x11'));_0xf346af(_0x1b4287['result'][_0x8dd8('0xf')]);}})['catch'](function(_0x53b064){logger[_0x8dd8('0xd')](_0x8dd8('0xe'),_0x22974d,_0x53b064);_0x5d7eac(_0x53b064);});});}exports[_0x8dd8('0x12')]=function(_0xe6bc87){var _0x49c83f=this;return new Promise(function(_0x1d020b,_0x2e4987){return db['SugarcrmAccount'][_0x8dd8('0x13')]({'raw':_0xe6bc87[_0x8dd8('0x14')]?_0xe6bc87[_0x8dd8('0x14')][_0x8dd8('0x15')]===undefined?!![]:![]:!![],'where':_0xe6bc87[_0x8dd8('0x14')]?_0xe6bc87['options'][_0x8dd8('0x16')]||null:null,'attributes':_0xe6bc87['options']?_0xe6bc87['options']['attributes']||null:null,'limit':_0xe6bc87[_0x8dd8('0x14')]?_0xe6bc87['options'][_0x8dd8('0x17')]||null:null,'include':_0xe6bc87['options']?_0xe6bc87[_0x8dd8('0x14')]['include']?_[_0x8dd8('0x18')](_0xe6bc87['options']['include'],function(_0x593609){return{'model':db[_0x593609[_0x8dd8('0x19')]],'as':_0x593609['as'],'attributes':_0x593609['attributes'],'include':_0x593609['include']?_[_0x8dd8('0x18')](_0x593609[_0x8dd8('0x1a')],function(_0x8b98b9){return{'model':db[_0x8b98b9['model']],'as':_0x8b98b9['as'],'attributes':_0x8b98b9[_0x8dd8('0x1b')],'include':_0x8b98b9[_0x8dd8('0x1a')]?_['map'](_0x8b98b9[_0x8dd8('0x1a')],function(_0x3fb373){return{'model':db[_0x3fb373[_0x8dd8('0x19')]],'as':_0x3fb373['as'],'attributes':_0x3fb373[_0x8dd8('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x8dd8('0x1c')](function(_0x1908a5){logger[_0x8dd8('0x10')](_0x8dd8('0x12'),_0xe6bc87);logger[_0x8dd8('0x1d')](_0x8dd8('0x12'),_0xe6bc87,JSON['stringify'](_0x1908a5));_0x1d020b(_0x1908a5);})['catch'](function(_0x190856){logger[_0x8dd8('0xd')]('GetSugarcrmAccount',_0x190856[_0x8dd8('0xf')],_0xe6bc87);_0x2e4987(_0x49c83f[_0x8dd8('0xd')](0x1f4,_0x190856['message']));});});};exports[_0x8dd8('0x1e')]=function(_0x5b3837){var _0x12b53f=this;return new Promise(function(_0x223937,_0x3a5221){return db[_0x8dd8('0x1f')][_0x8dd8('0x20')]({'raw':_0x5b3837[_0x8dd8('0x14')]?_0x5b3837[_0x8dd8('0x14')][_0x8dd8('0x15')]===undefined?!![]:![]:!![],'where':_0x5b3837[_0x8dd8('0x14')]?_0x5b3837[_0x8dd8('0x14')][_0x8dd8('0x16')]||null:null,'attributes':_0x5b3837[_0x8dd8('0x14')]?_0x5b3837[_0x8dd8('0x14')]['attributes']||null:null,'include':_0x5b3837['options']?_0x5b3837[_0x8dd8('0x14')][_0x8dd8('0x1a')]?_[_0x8dd8('0x18')](_0x5b3837['options']['include'],function(_0x49b699){return{'model':db[_0x49b699[_0x8dd8('0x19')]],'as':_0x49b699['as'],'attributes':_0x49b699[_0x8dd8('0x1b')],'include':_0x49b699[_0x8dd8('0x1a')]?_[_0x8dd8('0x18')](_0x49b699[_0x8dd8('0x1a')],function(_0x53d2de){return{'model':db[_0x53d2de[_0x8dd8('0x19')]],'as':_0x53d2de['as'],'attributes':_0x53d2de[_0x8dd8('0x1b')],'include':_0x53d2de[_0x8dd8('0x1a')]?_['map'](_0x53d2de[_0x8dd8('0x1a')],function(_0x24470f){return{'model':db[_0x24470f[_0x8dd8('0x19')]],'as':_0x24470f['as'],'attributes':_0x24470f[_0x8dd8('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x8dd8('0x1c')](function(_0xafce69){logger[_0x8dd8('0x10')](_0x8dd8('0x1e'),_0x5b3837);logger[_0x8dd8('0x1d')]('ShowSugarcrmAccount',_0x5b3837,JSON[_0x8dd8('0xc')](_0xafce69));_0x223937(_0xafce69);})[_0x8dd8('0x21')](function(_0x20bc96){logger[_0x8dd8('0xd')]('ShowSugarcrmAccount',_0x20bc96[_0x8dd8('0xf')],_0x5b3837);_0x3a5221(_0x12b53f[_0x8dd8('0xd')](0x1f4,_0x20bc96[_0x8dd8('0xf')]));});});};