Built motion from commit (unavailable).|2.5.8
[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 _0xe88b=['map','find','where','ShowSugarcrmAccount','lodash','util','moment','bluebird','randomstring','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','SugarcrmAccount,\x20%s,\x20%s','request\x20sent','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','catch','GetSugarcrmAccount','SugarcrmAccount','findAll','options','raw','attributes','limit','include','model'];(function(_0x1e46a5,_0x5b094e){var _0x35a2cf=function(_0x5e7c65){while(--_0x5e7c65){_0x1e46a5['push'](_0x1e46a5['shift']());}};_0x35a2cf(++_0x5b094e);}(_0xe88b,0x90));var _0xbe88=function(_0x519c88,_0xb84103){_0x519c88=_0x519c88-0x0;var _0x4668d7=_0xe88b[_0x519c88];return _0x4668d7;};'use strict';var _=require(_0xbe88('0x0'));var util=require(_0xbe88('0x1'));var moment=require(_0xbe88('0x2'));var BPromise=require(_0xbe88('0x3'));var rs=require(_0xbe88('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xbe88('0x5'))(_0xbe88('0x6'));var config=require(_0xbe88('0x7'));var jayson=require(_0xbe88('0x8'));var client=jayson['client'][_0xbe88('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x5bda03,_0x1a6a2c,_0x28262f){return new BPromise(function(_0x2d50c3,_0x5d674e){return client[_0xbe88('0xa')](_0x5bda03,_0x28262f)[_0xbe88('0xb')](function(_0x21fbd3){logger['info'](_0xbe88('0xc'),_0x1a6a2c,_0xbe88('0xd'));logger[_0xbe88('0xe')](_0xbe88('0xf'),_0x1a6a2c,_0xbe88('0xd'),JSON[_0xbe88('0x10')](_0x21fbd3));if(_0x21fbd3[_0xbe88('0x11')]){if(_0x21fbd3[_0xbe88('0x11')]['code']===0x1f4){logger[_0xbe88('0x11')](_0xbe88('0xc'),_0x1a6a2c,_0x21fbd3[_0xbe88('0x11')][_0xbe88('0x12')]);return _0x5d674e(_0x21fbd3[_0xbe88('0x11')][_0xbe88('0x12')]);}logger[_0xbe88('0x11')](_0xbe88('0xc'),_0x1a6a2c,_0x21fbd3[_0xbe88('0x11')][_0xbe88('0x12')]);return _0x2d50c3(_0x21fbd3[_0xbe88('0x11')][_0xbe88('0x12')]);}else{logger[_0xbe88('0x13')]('SugarcrmAccount,\x20%s,\x20%s',_0x1a6a2c,_0xbe88('0xd'));_0x2d50c3(_0x21fbd3[_0xbe88('0x14')][_0xbe88('0x12')]);}})[_0xbe88('0x15')](function(_0x38e825){logger[_0xbe88('0x11')](_0xbe88('0xc'),_0x1a6a2c,_0x38e825);_0x5d674e(_0x38e825);});});}exports[_0xbe88('0x16')]=function(_0x401cbb){var _0x4fa0bc=this;return new Promise(function(_0xcc8000,_0x4eb451){return db[_0xbe88('0x17')][_0xbe88('0x18')]({'raw':_0x401cbb[_0xbe88('0x19')]?_0x401cbb[_0xbe88('0x19')][_0xbe88('0x1a')]===undefined?!![]:![]:!![],'where':_0x401cbb[_0xbe88('0x19')]?_0x401cbb['options']['where']||null:null,'attributes':_0x401cbb[_0xbe88('0x19')]?_0x401cbb[_0xbe88('0x19')][_0xbe88('0x1b')]||null:null,'limit':_0x401cbb[_0xbe88('0x19')]?_0x401cbb[_0xbe88('0x19')][_0xbe88('0x1c')]||null:null,'include':_0x401cbb[_0xbe88('0x19')]?_0x401cbb[_0xbe88('0x19')]['include']?_['map'](_0x401cbb['options'][_0xbe88('0x1d')],function(_0x56a79c){return{'model':db[_0x56a79c[_0xbe88('0x1e')]],'as':_0x56a79c['as'],'attributes':_0x56a79c[_0xbe88('0x1b')],'include':_0x56a79c[_0xbe88('0x1d')]?_[_0xbe88('0x1f')](_0x56a79c[_0xbe88('0x1d')],function(_0x49f7c2){return{'model':db[_0x49f7c2[_0xbe88('0x1e')]],'as':_0x49f7c2['as'],'attributes':_0x49f7c2['attributes'],'include':_0x49f7c2['include']?_[_0xbe88('0x1f')](_0x49f7c2[_0xbe88('0x1d')],function(_0x2d5a0b){return{'model':db[_0x2d5a0b['model']],'as':_0x2d5a0b['as'],'attributes':_0x2d5a0b['attributes']};}):[]};}):[]};}):[]:[]})[_0xbe88('0xb')](function(_0x49bd1c){logger[_0xbe88('0x13')](_0xbe88('0x16'),_0x401cbb);logger[_0xbe88('0xe')](_0xbe88('0x16'),_0x401cbb,JSON[_0xbe88('0x10')](_0x49bd1c));_0xcc8000(_0x49bd1c);})[_0xbe88('0x15')](function(_0x5cc3a1){logger[_0xbe88('0x11')]('GetSugarcrmAccount',_0x5cc3a1['message'],_0x401cbb);_0x4eb451(_0x4fa0bc[_0xbe88('0x11')](0x1f4,_0x5cc3a1[_0xbe88('0x12')]));});});};exports['ShowSugarcrmAccount']=function(_0xea16fc){var _0x3e8b5c=this;return new Promise(function(_0x163867,_0x56a4a1){return db['SugarcrmAccount'][_0xbe88('0x20')]({'raw':_0xea16fc[_0xbe88('0x19')]?_0xea16fc['options'][_0xbe88('0x1a')]===undefined?!![]:![]:!![],'where':_0xea16fc['options']?_0xea16fc[_0xbe88('0x19')][_0xbe88('0x21')]||null:null,'attributes':_0xea16fc[_0xbe88('0x19')]?_0xea16fc[_0xbe88('0x19')][_0xbe88('0x1b')]||null:null,'include':_0xea16fc[_0xbe88('0x19')]?_0xea16fc[_0xbe88('0x19')][_0xbe88('0x1d')]?_[_0xbe88('0x1f')](_0xea16fc[_0xbe88('0x19')][_0xbe88('0x1d')],function(_0x236445){return{'model':db[_0x236445[_0xbe88('0x1e')]],'as':_0x236445['as'],'attributes':_0x236445['attributes'],'include':_0x236445['include']?_['map'](_0x236445[_0xbe88('0x1d')],function(_0x59986d){return{'model':db[_0x59986d[_0xbe88('0x1e')]],'as':_0x59986d['as'],'attributes':_0x59986d[_0xbe88('0x1b')],'include':_0x59986d['include']?_[_0xbe88('0x1f')](_0x59986d[_0xbe88('0x1d')],function(_0x4cee7d){return{'model':db[_0x4cee7d['model']],'as':_0x4cee7d['as'],'attributes':_0x4cee7d['attributes']};}):[]};}):[]};}):[]:[]})[_0xbe88('0xb')](function(_0x1a1df9){logger[_0xbe88('0x13')](_0xbe88('0x22'),_0xea16fc);logger[_0xbe88('0xe')](_0xbe88('0x22'),_0xea16fc,JSON[_0xbe88('0x10')](_0x1a1df9));_0x163867(_0x1a1df9);})[_0xbe88('0x15')](function(_0x17e8c3){logger[_0xbe88('0x11')]('ShowSugarcrmAccount',_0x17e8c3[_0xbe88('0x12')],_0xea16fc);_0x56a4a1(_0x3e8b5c[_0xbe88('0x11')](0x1f4,_0x17e8c3['message']));});});};