c9cc611975232751489dfa92740e624d990991f7
[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 _0x15bd=['http','request','then','info','SugarcrmAccount,\x20%s,\x20%s','request\x20sent','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s','error','code','message','catch','GetSugarcrmAccount','SugarcrmAccount','findAll','options','raw','where','limit','include','map','model','attributes','stringify','ShowSugarcrmAccount','find','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','client'];(function(_0x3aaab3,_0xffea8c){var _0x57708f=function(_0x416bfe){while(--_0x416bfe){_0x3aaab3['push'](_0x3aaab3['shift']());}};_0x57708f(++_0xffea8c);}(_0x15bd,0x83));var _0xd15b=function(_0x1d50a3,_0x3213ff){_0x1d50a3=_0x1d50a3-0x0;var _0x4d8902=_0x15bd[_0x1d50a3];return _0x4d8902;};'use strict';var _=require(_0xd15b('0x0'));var util=require(_0xd15b('0x1'));var moment=require(_0xd15b('0x2'));var BPromise=require(_0xd15b('0x3'));var rs=require(_0xd15b('0x4'));var fs=require('fs');var Redis=require(_0xd15b('0x5'));var db=require(_0xd15b('0x6'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xd15b('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xd15b('0x8')][_0xd15b('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x5a5c3f,_0x209391,_0x32b9e6){return new BPromise(function(_0x42a9af,_0xfed42a){return client[_0xd15b('0xa')](_0x5a5c3f,_0x32b9e6)[_0xd15b('0xb')](function(_0x66184){logger[_0xd15b('0xc')](_0xd15b('0xd'),_0x209391,_0xd15b('0xe'));logger[_0xd15b('0xf')](_0xd15b('0x10'),_0x209391,_0xd15b('0xe'),JSON['stringify'](_0x66184));if(_0x66184[_0xd15b('0x11')]){if(_0x66184[_0xd15b('0x11')][_0xd15b('0x12')]===0x1f4){logger[_0xd15b('0x11')]('SugarcrmAccount,\x20%s,\x20%s',_0x209391,_0x66184[_0xd15b('0x11')][_0xd15b('0x13')]);return _0xfed42a(_0x66184[_0xd15b('0x11')]['message']);}logger[_0xd15b('0x11')](_0xd15b('0xd'),_0x209391,_0x66184[_0xd15b('0x11')]['message']);return _0x42a9af(_0x66184[_0xd15b('0x11')][_0xd15b('0x13')]);}else{logger[_0xd15b('0xc')]('SugarcrmAccount,\x20%s,\x20%s',_0x209391,_0xd15b('0xe'));_0x42a9af(_0x66184['result'][_0xd15b('0x13')]);}})[_0xd15b('0x14')](function(_0x5e277a){logger[_0xd15b('0x11')]('SugarcrmAccount,\x20%s,\x20%s',_0x209391,_0x5e277a);_0xfed42a(_0x5e277a);});});}exports[_0xd15b('0x15')]=function(_0x3eb8b0){var _0x3b5a4d=this;return new Promise(function(_0x3e7f79,_0x1b4e36){return db[_0xd15b('0x16')][_0xd15b('0x17')]({'raw':_0x3eb8b0[_0xd15b('0x18')]?_0x3eb8b0['options'][_0xd15b('0x19')]===undefined?!![]:![]:!![],'where':_0x3eb8b0[_0xd15b('0x18')]?_0x3eb8b0['options'][_0xd15b('0x1a')]||null:null,'attributes':_0x3eb8b0[_0xd15b('0x18')]?_0x3eb8b0['options']['attributes']||null:null,'limit':_0x3eb8b0[_0xd15b('0x18')]?_0x3eb8b0['options'][_0xd15b('0x1b')]||null:null,'include':_0x3eb8b0[_0xd15b('0x18')]?_0x3eb8b0[_0xd15b('0x18')][_0xd15b('0x1c')]?_[_0xd15b('0x1d')](_0x3eb8b0['options'][_0xd15b('0x1c')],function(_0x155385){return{'model':db[_0x155385[_0xd15b('0x1e')]],'as':_0x155385['as'],'attributes':_0x155385[_0xd15b('0x1f')],'include':_0x155385['include']?_['map'](_0x155385[_0xd15b('0x1c')],function(_0x324627){return{'model':db[_0x324627['model']],'as':_0x324627['as'],'attributes':_0x324627[_0xd15b('0x1f')],'include':_0x324627['include']?_[_0xd15b('0x1d')](_0x324627[_0xd15b('0x1c')],function(_0x4c1872){return{'model':db[_0x4c1872[_0xd15b('0x1e')]],'as':_0x4c1872['as'],'attributes':_0x4c1872['attributes']};}):[]};}):[]};}):[]:[]})[_0xd15b('0xb')](function(_0x3905b8){logger['info'](_0xd15b('0x15'),_0x3eb8b0);logger['debug'](_0xd15b('0x15'),_0x3eb8b0,JSON[_0xd15b('0x20')](_0x3905b8));_0x3e7f79(_0x3905b8);})[_0xd15b('0x14')](function(_0x15ec38){logger['error'](_0xd15b('0x15'),_0x15ec38['message'],_0x3eb8b0);_0x1b4e36(_0x3b5a4d[_0xd15b('0x11')](0x1f4,_0x15ec38[_0xd15b('0x13')]));});});};exports[_0xd15b('0x21')]=function(_0x561eaf){var _0x1f4518=this;return new Promise(function(_0x20cf88,_0x1afedb){return db[_0xd15b('0x16')][_0xd15b('0x22')]({'raw':_0x561eaf[_0xd15b('0x18')]?_0x561eaf['options'][_0xd15b('0x19')]===undefined?!![]:![]:!![],'where':_0x561eaf['options']?_0x561eaf[_0xd15b('0x18')]['where']||null:null,'attributes':_0x561eaf[_0xd15b('0x18')]?_0x561eaf['options'][_0xd15b('0x1f')]||null:null,'include':_0x561eaf[_0xd15b('0x18')]?_0x561eaf[_0xd15b('0x18')][_0xd15b('0x1c')]?_[_0xd15b('0x1d')](_0x561eaf[_0xd15b('0x18')][_0xd15b('0x1c')],function(_0x2cc6fb){return{'model':db[_0x2cc6fb[_0xd15b('0x1e')]],'as':_0x2cc6fb['as'],'attributes':_0x2cc6fb[_0xd15b('0x1f')],'include':_0x2cc6fb[_0xd15b('0x1c')]?_['map'](_0x2cc6fb[_0xd15b('0x1c')],function(_0x44c5e7){return{'model':db[_0x44c5e7[_0xd15b('0x1e')]],'as':_0x44c5e7['as'],'attributes':_0x44c5e7[_0xd15b('0x1f')],'include':_0x44c5e7[_0xd15b('0x1c')]?_[_0xd15b('0x1d')](_0x44c5e7[_0xd15b('0x1c')],function(_0x31bbab){return{'model':db[_0x31bbab[_0xd15b('0x1e')]],'as':_0x31bbab['as'],'attributes':_0x31bbab[_0xd15b('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xd15b('0xb')](function(_0x492579){logger[_0xd15b('0xc')](_0xd15b('0x21'),_0x561eaf);logger['debug'](_0xd15b('0x21'),_0x561eaf,JSON[_0xd15b('0x20')](_0x492579));_0x20cf88(_0x492579);})['catch'](function(_0x27bf29){logger[_0xd15b('0x11')](_0xd15b('0x21'),_0x27bf29[_0xd15b('0x13')],_0x561eaf);_0x1afedb(_0x1f4518[_0xd15b('0x11')](0x1f4,_0x27bf29['message']));});});};