00d27de91918e673b8f28bf21514f225b588ba84
[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 _0x7900=['where','attributes','limit','include','map','model','catch','ShowSugarcrmAccount','find','raw','debug','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','then','request\x20sent','SugarcrmAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','SugarcrmAccount,\x20%s,\x20%s','info','result','GetSugarcrmAccount','SugarcrmAccount','findAll','options'];(function(_0xefd519,_0xc62635){var _0x4bb882=function(_0x37e0a1){while(--_0x37e0a1){_0xefd519['push'](_0xefd519['shift']());}};_0x4bb882(++_0xc62635);}(_0x7900,0x158));var _0x0790=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0x7900[_0x20a584];return _0x4b41a8;};'use strict';var _=require(_0x0790('0x0'));var util=require(_0x0790('0x1'));var moment=require(_0x0790('0x2'));var BPromise=require('bluebird');var rs=require(_0x0790('0x3'));var fs=require('fs');var Redis=require(_0x0790('0x4'));var db=require(_0x0790('0x5'))['db'];var utils=require(_0x0790('0x6'));var logger=require(_0x0790('0x7'))(_0x0790('0x8'));var config=require('../../config/environment');var jayson=require(_0x0790('0x9'));var client=jayson[_0x0790('0xa')][_0x0790('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x13f5f9,_0x417e03,_0x5c6b76){return new BPromise(function(_0xe3f143,_0xad8c45){return client[_0x0790('0xc')](_0x13f5f9,_0x5c6b76)[_0x0790('0xd')](function(_0x4ba239){logger['info']('SugarcrmAccount,\x20%s,\x20%s',_0x417e03,_0x0790('0xe'));logger['debug'](_0x0790('0xf'),_0x417e03,'request\x20sent',JSON[_0x0790('0x10')](_0x4ba239));if(_0x4ba239[_0x0790('0x11')]){if(_0x4ba239[_0x0790('0x11')]['code']===0x1f4){logger[_0x0790('0x11')]('SugarcrmAccount,\x20%s,\x20%s',_0x417e03,_0x4ba239[_0x0790('0x11')][_0x0790('0x12')]);return _0xad8c45(_0x4ba239[_0x0790('0x11')][_0x0790('0x12')]);}logger['error'](_0x0790('0x13'),_0x417e03,_0x4ba239[_0x0790('0x11')][_0x0790('0x12')]);return _0xe3f143(_0x4ba239[_0x0790('0x11')][_0x0790('0x12')]);}else{logger[_0x0790('0x14')]('SugarcrmAccount,\x20%s,\x20%s',_0x417e03,_0x0790('0xe'));_0xe3f143(_0x4ba239[_0x0790('0x15')][_0x0790('0x12')]);}})['catch'](function(_0x30064a){logger['error'](_0x0790('0x13'),_0x417e03,_0x30064a);_0xad8c45(_0x30064a);});});}exports[_0x0790('0x16')]=function(_0x1e573a){var _0x480e40=this;return new Promise(function(_0x486079,_0x152793){return db[_0x0790('0x17')][_0x0790('0x18')]({'raw':_0x1e573a[_0x0790('0x19')]?_0x1e573a[_0x0790('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x1e573a[_0x0790('0x19')]?_0x1e573a['options'][_0x0790('0x1a')]||null:null,'attributes':_0x1e573a[_0x0790('0x19')]?_0x1e573a[_0x0790('0x19')][_0x0790('0x1b')]||null:null,'limit':_0x1e573a[_0x0790('0x19')]?_0x1e573a[_0x0790('0x19')][_0x0790('0x1c')]||null:null,'include':_0x1e573a[_0x0790('0x19')]?_0x1e573a[_0x0790('0x19')][_0x0790('0x1d')]?_[_0x0790('0x1e')](_0x1e573a[_0x0790('0x19')][_0x0790('0x1d')],function(_0x3588de){return{'model':db[_0x3588de[_0x0790('0x1f')]],'as':_0x3588de['as'],'attributes':_0x3588de[_0x0790('0x1b')],'include':_0x3588de[_0x0790('0x1d')]?_[_0x0790('0x1e')](_0x3588de[_0x0790('0x1d')],function(_0x54b5ba){return{'model':db[_0x54b5ba[_0x0790('0x1f')]],'as':_0x54b5ba['as'],'attributes':_0x54b5ba[_0x0790('0x1b')],'include':_0x54b5ba[_0x0790('0x1d')]?_[_0x0790('0x1e')](_0x54b5ba[_0x0790('0x1d')],function(_0x2dea32){return{'model':db[_0x2dea32[_0x0790('0x1f')]],'as':_0x2dea32['as'],'attributes':_0x2dea32['attributes']};}):[]};}):[]};}):[]:[]})[_0x0790('0xd')](function(_0x5aa01c){logger['info'](_0x0790('0x16'),_0x1e573a);logger['debug'](_0x0790('0x16'),_0x1e573a,JSON[_0x0790('0x10')](_0x5aa01c));_0x486079(_0x5aa01c);})[_0x0790('0x20')](function(_0x380b45){logger[_0x0790('0x11')](_0x0790('0x16'),_0x380b45[_0x0790('0x12')],_0x1e573a);_0x152793(_0x480e40[_0x0790('0x11')](0x1f4,_0x380b45[_0x0790('0x12')]));});});};exports[_0x0790('0x21')]=function(_0x5a4c55){var _0x2a7703=this;return new Promise(function(_0x27dc31,_0x29f1fa){return db[_0x0790('0x17')][_0x0790('0x22')]({'raw':_0x5a4c55[_0x0790('0x19')]?_0x5a4c55[_0x0790('0x19')][_0x0790('0x23')]===undefined?!![]:![]:!![],'where':_0x5a4c55[_0x0790('0x19')]?_0x5a4c55['options'][_0x0790('0x1a')]||null:null,'attributes':_0x5a4c55[_0x0790('0x19')]?_0x5a4c55[_0x0790('0x19')][_0x0790('0x1b')]||null:null,'include':_0x5a4c55['options']?_0x5a4c55[_0x0790('0x19')][_0x0790('0x1d')]?_[_0x0790('0x1e')](_0x5a4c55[_0x0790('0x19')][_0x0790('0x1d')],function(_0x2f9975){return{'model':db[_0x2f9975[_0x0790('0x1f')]],'as':_0x2f9975['as'],'attributes':_0x2f9975[_0x0790('0x1b')],'include':_0x2f9975['include']?_[_0x0790('0x1e')](_0x2f9975[_0x0790('0x1d')],function(_0x49b543){return{'model':db[_0x49b543[_0x0790('0x1f')]],'as':_0x49b543['as'],'attributes':_0x49b543[_0x0790('0x1b')],'include':_0x49b543[_0x0790('0x1d')]?_[_0x0790('0x1e')](_0x49b543[_0x0790('0x1d')],function(_0x13302a){return{'model':db[_0x13302a['model']],'as':_0x13302a['as'],'attributes':_0x13302a['attributes']};}):[]};}):[]};}):[]:[]})[_0x0790('0xd')](function(_0x12d778){logger[_0x0790('0x14')](_0x0790('0x21'),_0x5a4c55);logger[_0x0790('0x24')]('ShowSugarcrmAccount',_0x5a4c55,JSON['stringify'](_0x12d778));_0x27dc31(_0x12d778);})[_0x0790('0x20')](function(_0x13fb3d){logger[_0x0790('0x11')](_0x0790('0x21'),_0x13fb3d[_0x0790('0x12')],_0x5a4c55);_0x29f1fa(_0x2a7703[_0x0790('0x11')](0x1f4,_0x13fb3d[_0x0790('0x12')]));});});};