8b8d9a4c4ea2357c54b0aac4bb81b652de268f73
[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 _0xb647=['raw','where','limit','include','attributes','map','model','stringify','catch','ShowSugarcrmAccount','find','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','SugarcrmAccount,\x20%s,\x20%s','request\x20sent','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s','error','code','message','result','GetSugarcrmAccount','SugarcrmAccount','findAll','options'];(function(_0x465a0c,_0x19d4d5){var _0x1e202e=function(_0x27bd8a){while(--_0x27bd8a){_0x465a0c['push'](_0x465a0c['shift']());}};_0x1e202e(++_0x19d4d5);}(_0xb647,0xce));var _0x7b64=function(_0x564331,_0x4bf98a){_0x564331=_0x564331-0x0;var _0x973c69=_0xb647[_0x564331];return _0x973c69;};'use strict';var _=require(_0x7b64('0x0'));var util=require(_0x7b64('0x1'));var moment=require(_0x7b64('0x2'));var BPromise=require(_0x7b64('0x3'));var rs=require(_0x7b64('0x4'));var fs=require('fs');var Redis=require(_0x7b64('0x5'));var db=require(_0x7b64('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x7b64('0x7'))(_0x7b64('0x8'));var config=require(_0x7b64('0x9'));var jayson=require(_0x7b64('0xa'));var client=jayson[_0x7b64('0xb')][_0x7b64('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x2173f9,_0x385c22,_0x229e03){return new BPromise(function(_0x1a2ae7,_0x8efde4){return client[_0x7b64('0xd')](_0x2173f9,_0x229e03)[_0x7b64('0xe')](function(_0x50a0ea){logger[_0x7b64('0xf')](_0x7b64('0x10'),_0x385c22,_0x7b64('0x11'));logger[_0x7b64('0x12')](_0x7b64('0x13'),_0x385c22,_0x7b64('0x11'),JSON['stringify'](_0x50a0ea));if(_0x50a0ea[_0x7b64('0x14')]){if(_0x50a0ea[_0x7b64('0x14')][_0x7b64('0x15')]===0x1f4){logger['error']('SugarcrmAccount,\x20%s,\x20%s',_0x385c22,_0x50a0ea[_0x7b64('0x14')][_0x7b64('0x16')]);return _0x8efde4(_0x50a0ea['error'][_0x7b64('0x16')]);}logger[_0x7b64('0x14')](_0x7b64('0x10'),_0x385c22,_0x50a0ea[_0x7b64('0x14')][_0x7b64('0x16')]);return _0x1a2ae7(_0x50a0ea['error'][_0x7b64('0x16')]);}else{logger[_0x7b64('0xf')](_0x7b64('0x10'),_0x385c22,_0x7b64('0x11'));_0x1a2ae7(_0x50a0ea[_0x7b64('0x17')][_0x7b64('0x16')]);}})['catch'](function(_0x4e350c){logger[_0x7b64('0x14')](_0x7b64('0x10'),_0x385c22,_0x4e350c);_0x8efde4(_0x4e350c);});});}exports[_0x7b64('0x18')]=function(_0x1b93ad){var _0x48214a=this;return new Promise(function(_0x397ba9,_0x1ae5e5){return db[_0x7b64('0x19')][_0x7b64('0x1a')]({'raw':_0x1b93ad[_0x7b64('0x1b')]?_0x1b93ad[_0x7b64('0x1b')][_0x7b64('0x1c')]===undefined?!![]:![]:!![],'where':_0x1b93ad[_0x7b64('0x1b')]?_0x1b93ad['options'][_0x7b64('0x1d')]||null:null,'attributes':_0x1b93ad['options']?_0x1b93ad[_0x7b64('0x1b')]['attributes']||null:null,'limit':_0x1b93ad[_0x7b64('0x1b')]?_0x1b93ad['options'][_0x7b64('0x1e')]||null:null,'include':_0x1b93ad[_0x7b64('0x1b')]?_0x1b93ad['options'][_0x7b64('0x1f')]?_['map'](_0x1b93ad[_0x7b64('0x1b')][_0x7b64('0x1f')],function(_0x4218c0){return{'model':db[_0x4218c0['model']],'as':_0x4218c0['as'],'attributes':_0x4218c0[_0x7b64('0x20')],'include':_0x4218c0[_0x7b64('0x1f')]?_[_0x7b64('0x21')](_0x4218c0[_0x7b64('0x1f')],function(_0x1ddfba){return{'model':db[_0x1ddfba[_0x7b64('0x22')]],'as':_0x1ddfba['as'],'attributes':_0x1ddfba['attributes'],'include':_0x1ddfba[_0x7b64('0x1f')]?_[_0x7b64('0x21')](_0x1ddfba[_0x7b64('0x1f')],function(_0x29363f){return{'model':db[_0x29363f[_0x7b64('0x22')]],'as':_0x29363f['as'],'attributes':_0x29363f[_0x7b64('0x20')]};}):[]};}):[]};}):[]:[]})[_0x7b64('0xe')](function(_0x3c7c40){logger[_0x7b64('0xf')](_0x7b64('0x18'),_0x1b93ad);logger[_0x7b64('0x12')](_0x7b64('0x18'),_0x1b93ad,JSON[_0x7b64('0x23')](_0x3c7c40));_0x397ba9(_0x3c7c40);})[_0x7b64('0x24')](function(_0x3790ef){logger[_0x7b64('0x14')]('GetSugarcrmAccount',_0x3790ef[_0x7b64('0x16')],_0x1b93ad);_0x1ae5e5(_0x48214a['error'](0x1f4,_0x3790ef[_0x7b64('0x16')]));});});};exports[_0x7b64('0x25')]=function(_0x1bff24){var _0x4db399=this;return new Promise(function(_0x30b842,_0x28cfe9){return db[_0x7b64('0x19')][_0x7b64('0x26')]({'raw':_0x1bff24['options']?_0x1bff24['options'][_0x7b64('0x1c')]===undefined?!![]:![]:!![],'where':_0x1bff24[_0x7b64('0x1b')]?_0x1bff24[_0x7b64('0x1b')]['where']||null:null,'attributes':_0x1bff24[_0x7b64('0x1b')]?_0x1bff24[_0x7b64('0x1b')][_0x7b64('0x20')]||null:null,'include':_0x1bff24['options']?_0x1bff24[_0x7b64('0x1b')][_0x7b64('0x1f')]?_[_0x7b64('0x21')](_0x1bff24[_0x7b64('0x1b')][_0x7b64('0x1f')],function(_0x1d485d){return{'model':db[_0x1d485d['model']],'as':_0x1d485d['as'],'attributes':_0x1d485d[_0x7b64('0x20')],'include':_0x1d485d['include']?_[_0x7b64('0x21')](_0x1d485d[_0x7b64('0x1f')],function(_0x375888){return{'model':db[_0x375888['model']],'as':_0x375888['as'],'attributes':_0x375888['attributes'],'include':_0x375888[_0x7b64('0x1f')]?_[_0x7b64('0x21')](_0x375888[_0x7b64('0x1f')],function(_0x3c466b){return{'model':db[_0x3c466b[_0x7b64('0x22')]],'as':_0x3c466b['as'],'attributes':_0x3c466b[_0x7b64('0x20')]};}):[]};}):[]};}):[]:[]})[_0x7b64('0xe')](function(_0xb83c49){logger['info']('ShowSugarcrmAccount',_0x1bff24);logger[_0x7b64('0x12')]('ShowSugarcrmAccount',_0x1bff24,JSON[_0x7b64('0x23')](_0xb83c49));_0x30b842(_0xb83c49);})[_0x7b64('0x24')](function(_0x11635e){logger[_0x7b64('0x14')]('ShowSugarcrmAccount',_0x11635e[_0x7b64('0x16')],_0x1bff24);_0x28cfe9(_0x4db399['error'](0x1f4,_0x11635e[_0x7b64('0x16')]));});});};