Built motion from commit (unavailable).|2.5.4
[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 _0x83cd=['../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','info','SugarcrmAccount,\x20%s,\x20%s','request\x20sent','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','GetSugarcrmAccount','SugarcrmAccount','findAll','raw','where','options','attributes','limit','include','map','model','then','catch','ShowSugarcrmAccount','lodash','util','randomstring','ioredis','../../mysqldb'];(function(_0x3d6bab,_0x3242db){var _0x348415=function(_0x324f3b){while(--_0x324f3b){_0x3d6bab['push'](_0x3d6bab['shift']());}};_0x348415(++_0x3242db);}(_0x83cd,0xf7));var _0xd83c=function(_0x4d986d,_0x3c4d73){_0x4d986d=_0x4d986d-0x0;var _0x5bb089=_0x83cd[_0x4d986d];return _0x5bb089;};'use strict';var _=require(_0xd83c('0x0'));var util=require(_0xd83c('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xd83c('0x2'));var fs=require('fs');var Redis=require(_0xd83c('0x3'));var db=require(_0xd83c('0x4'))['db'];var utils=require(_0xd83c('0x5'));var logger=require(_0xd83c('0x6'))(_0xd83c('0x7'));var config=require('../../config/environment');var jayson=require(_0xd83c('0x8'));var client=jayson[_0xd83c('0x9')][_0xd83c('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x317f07,_0x33e654,_0x459dfc){return new BPromise(function(_0x4a119d,_0x200c2c){return client[_0xd83c('0xb')](_0x317f07,_0x459dfc)['then'](function(_0x5c5655){logger[_0xd83c('0xc')](_0xd83c('0xd'),_0x33e654,_0xd83c('0xe'));logger[_0xd83c('0xf')](_0xd83c('0x10'),_0x33e654,'request\x20sent',JSON[_0xd83c('0x11')](_0x5c5655));if(_0x5c5655[_0xd83c('0x12')]){if(_0x5c5655['error'][_0xd83c('0x13')]===0x1f4){logger[_0xd83c('0x12')](_0xd83c('0xd'),_0x33e654,_0x5c5655[_0xd83c('0x12')][_0xd83c('0x14')]);return _0x200c2c(_0x5c5655[_0xd83c('0x12')][_0xd83c('0x14')]);}logger[_0xd83c('0x12')](_0xd83c('0xd'),_0x33e654,_0x5c5655[_0xd83c('0x12')][_0xd83c('0x14')]);return _0x4a119d(_0x5c5655[_0xd83c('0x12')]['message']);}else{logger[_0xd83c('0xc')](_0xd83c('0xd'),_0x33e654,'request\x20sent');_0x4a119d(_0x5c5655[_0xd83c('0x15')][_0xd83c('0x14')]);}})['catch'](function(_0x4337cf){logger[_0xd83c('0x12')](_0xd83c('0xd'),_0x33e654,_0x4337cf);_0x200c2c(_0x4337cf);});});}exports[_0xd83c('0x16')]=function(_0x154b81){var _0x24e8e9=this;return new Promise(function(_0x5ee3cc,_0x203c95){return db[_0xd83c('0x17')][_0xd83c('0x18')]({'raw':_0x154b81['options']?_0x154b81['options'][_0xd83c('0x19')]===undefined?!![]:![]:!![],'where':_0x154b81['options']?_0x154b81['options'][_0xd83c('0x1a')]||null:null,'attributes':_0x154b81[_0xd83c('0x1b')]?_0x154b81[_0xd83c('0x1b')][_0xd83c('0x1c')]||null:null,'limit':_0x154b81[_0xd83c('0x1b')]?_0x154b81[_0xd83c('0x1b')][_0xd83c('0x1d')]||null:null,'include':_0x154b81['options']?_0x154b81[_0xd83c('0x1b')][_0xd83c('0x1e')]?_[_0xd83c('0x1f')](_0x154b81[_0xd83c('0x1b')][_0xd83c('0x1e')],function(_0x15645b){return{'model':db[_0x15645b[_0xd83c('0x20')]],'as':_0x15645b['as'],'attributes':_0x15645b['attributes'],'include':_0x15645b[_0xd83c('0x1e')]?_[_0xd83c('0x1f')](_0x15645b[_0xd83c('0x1e')],function(_0x32332f){return{'model':db[_0x32332f[_0xd83c('0x20')]],'as':_0x32332f['as'],'attributes':_0x32332f[_0xd83c('0x1c')],'include':_0x32332f['include']?_[_0xd83c('0x1f')](_0x32332f[_0xd83c('0x1e')],function(_0x1afdcc){return{'model':db[_0x1afdcc['model']],'as':_0x1afdcc['as'],'attributes':_0x1afdcc[_0xd83c('0x1c')]};}):[]};}):[]};}):[]:[]})[_0xd83c('0x21')](function(_0xeeda73){logger['info']('GetSugarcrmAccount',_0x154b81);logger[_0xd83c('0xf')]('GetSugarcrmAccount',_0x154b81,JSON['stringify'](_0xeeda73));_0x5ee3cc(_0xeeda73);})[_0xd83c('0x22')](function(_0x26cac9){logger[_0xd83c('0x12')](_0xd83c('0x16'),_0x26cac9['message'],_0x154b81);_0x203c95(_0x24e8e9['error'](0x1f4,_0x26cac9[_0xd83c('0x14')]));});});};exports[_0xd83c('0x23')]=function(_0x4f7de1){var _0x4008ca=this;return new Promise(function(_0x319de8,_0x6a562a){return db[_0xd83c('0x17')]['find']({'raw':_0x4f7de1[_0xd83c('0x1b')]?_0x4f7de1['options']['raw']===undefined?!![]:![]:!![],'where':_0x4f7de1[_0xd83c('0x1b')]?_0x4f7de1['options'][_0xd83c('0x1a')]||null:null,'attributes':_0x4f7de1['options']?_0x4f7de1[_0xd83c('0x1b')][_0xd83c('0x1c')]||null:null,'include':_0x4f7de1[_0xd83c('0x1b')]?_0x4f7de1[_0xd83c('0x1b')][_0xd83c('0x1e')]?_['map'](_0x4f7de1[_0xd83c('0x1b')][_0xd83c('0x1e')],function(_0x5c7fff){return{'model':db[_0x5c7fff[_0xd83c('0x20')]],'as':_0x5c7fff['as'],'attributes':_0x5c7fff[_0xd83c('0x1c')],'include':_0x5c7fff['include']?_[_0xd83c('0x1f')](_0x5c7fff[_0xd83c('0x1e')],function(_0x4f841e){return{'model':db[_0x4f841e[_0xd83c('0x20')]],'as':_0x4f841e['as'],'attributes':_0x4f841e[_0xd83c('0x1c')],'include':_0x4f841e['include']?_[_0xd83c('0x1f')](_0x4f841e[_0xd83c('0x1e')],function(_0x2f2626){return{'model':db[_0x2f2626[_0xd83c('0x20')]],'as':_0x2f2626['as'],'attributes':_0x2f2626[_0xd83c('0x1c')]};}):[]};}):[]};}):[]:[]})[_0xd83c('0x21')](function(_0x441b81){logger['info']('ShowSugarcrmAccount',_0x4f7de1);logger[_0xd83c('0xf')](_0xd83c('0x23'),_0x4f7de1,JSON[_0xd83c('0x11')](_0x441b81));_0x319de8(_0x441b81);})[_0xd83c('0x22')](function(_0x109a2e){logger['error'](_0xd83c('0x23'),_0x109a2e[_0xd83c('0x14')],_0x4f7de1);_0x6a562a(_0x4008ca[_0xd83c('0x12')](0x1f4,_0x109a2e[_0xd83c('0x14')]));});});};