Built motion from commit da24aabd.|2.6.20
[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 _0xc627=['where','lodash','moment','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','request\x20sent','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','SugarcrmAccount,\x20%s,\x20%s','info','catch','GetSugarcrmAccount','SugarcrmAccount','options','raw','attributes','include','map','model','ShowSugarcrmAccount','find'];(function(_0x1227b8,_0x30767f){var _0x257e17=function(_0x26c59d){while(--_0x26c59d){_0x1227b8['push'](_0x1227b8['shift']());}};_0x257e17(++_0x30767f);}(_0xc627,0xa1));var _0x7c62=function(_0x48dc45,_0x8930da){_0x48dc45=_0x48dc45-0x0;var _0xcf044f=_0xc627[_0x48dc45];return _0xcf044f;};'use strict';var _=require(_0x7c62('0x0'));var util=require('util');var moment=require(_0x7c62('0x1'));var BPromise=require(_0x7c62('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x7c62('0x3'));var db=require(_0x7c62('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x7c62('0x5'))(_0x7c62('0x6'));var config=require(_0x7c62('0x7'));var jayson=require(_0x7c62('0x8'));var client=jayson['client'][_0x7c62('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x1c9486,_0x1eae01,_0x2f6133){return new BPromise(function(_0x566234,_0x2e50c9){return client[_0x7c62('0xa')](_0x1c9486,_0x2f6133)[_0x7c62('0xb')](function(_0xabb24c){logger['info']('SugarcrmAccount,\x20%s,\x20%s',_0x1eae01,_0x7c62('0xc'));logger[_0x7c62('0xd')](_0x7c62('0xe'),_0x1eae01,'request\x20sent',JSON[_0x7c62('0xf')](_0xabb24c));if(_0xabb24c[_0x7c62('0x10')]){if(_0xabb24c[_0x7c62('0x10')]['code']===0x1f4){logger[_0x7c62('0x10')]('SugarcrmAccount,\x20%s,\x20%s',_0x1eae01,_0xabb24c[_0x7c62('0x10')][_0x7c62('0x11')]);return _0x2e50c9(_0xabb24c['error'][_0x7c62('0x11')]);}logger['error'](_0x7c62('0x12'),_0x1eae01,_0xabb24c[_0x7c62('0x10')][_0x7c62('0x11')]);return _0x566234(_0xabb24c['error']['message']);}else{logger[_0x7c62('0x13')](_0x7c62('0x12'),_0x1eae01,_0x7c62('0xc'));_0x566234(_0xabb24c['result'][_0x7c62('0x11')]);}})[_0x7c62('0x14')](function(_0x51fb30){logger[_0x7c62('0x10')](_0x7c62('0x12'),_0x1eae01,_0x51fb30);_0x2e50c9(_0x51fb30);});});}exports[_0x7c62('0x15')]=function(_0x3d2898){var _0x39b34d=this;return new Promise(function(_0x46a173,_0x19046d){return db[_0x7c62('0x16')]['findAll']({'raw':_0x3d2898[_0x7c62('0x17')]?_0x3d2898['options'][_0x7c62('0x18')]===undefined?!![]:![]:!![],'where':_0x3d2898[_0x7c62('0x17')]?_0x3d2898['options']['where']||null:null,'attributes':_0x3d2898[_0x7c62('0x17')]?_0x3d2898[_0x7c62('0x17')][_0x7c62('0x19')]||null:null,'limit':_0x3d2898[_0x7c62('0x17')]?_0x3d2898[_0x7c62('0x17')]['limit']||null:null,'include':_0x3d2898[_0x7c62('0x17')]?_0x3d2898[_0x7c62('0x17')][_0x7c62('0x1a')]?_[_0x7c62('0x1b')](_0x3d2898[_0x7c62('0x17')][_0x7c62('0x1a')],function(_0x5521b2){return{'model':db[_0x5521b2[_0x7c62('0x1c')]],'as':_0x5521b2['as'],'attributes':_0x5521b2['attributes'],'include':_0x5521b2[_0x7c62('0x1a')]?_[_0x7c62('0x1b')](_0x5521b2[_0x7c62('0x1a')],function(_0x47ae0a){return{'model':db[_0x47ae0a[_0x7c62('0x1c')]],'as':_0x47ae0a['as'],'attributes':_0x47ae0a[_0x7c62('0x19')],'include':_0x47ae0a[_0x7c62('0x1a')]?_[_0x7c62('0x1b')](_0x47ae0a[_0x7c62('0x1a')],function(_0x21d35d){return{'model':db[_0x21d35d[_0x7c62('0x1c')]],'as':_0x21d35d['as'],'attributes':_0x21d35d[_0x7c62('0x19')]};}):[]};}):[]};}):[]:[]})[_0x7c62('0xb')](function(_0x3fa200){logger[_0x7c62('0x13')](_0x7c62('0x15'),_0x3d2898);logger[_0x7c62('0xd')]('GetSugarcrmAccount',_0x3d2898,JSON['stringify'](_0x3fa200));_0x46a173(_0x3fa200);})[_0x7c62('0x14')](function(_0x440d63){logger[_0x7c62('0x10')](_0x7c62('0x15'),_0x440d63[_0x7c62('0x11')],_0x3d2898);_0x19046d(_0x39b34d[_0x7c62('0x10')](0x1f4,_0x440d63[_0x7c62('0x11')]));});});};exports[_0x7c62('0x1d')]=function(_0x57b61b){var _0x29994a=this;return new Promise(function(_0x18f0a4,_0x3e7ec){return db['SugarcrmAccount'][_0x7c62('0x1e')]({'raw':_0x57b61b['options']?_0x57b61b[_0x7c62('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x57b61b['options']?_0x57b61b[_0x7c62('0x17')][_0x7c62('0x1f')]||null:null,'attributes':_0x57b61b[_0x7c62('0x17')]?_0x57b61b[_0x7c62('0x17')][_0x7c62('0x19')]||null:null,'include':_0x57b61b[_0x7c62('0x17')]?_0x57b61b['options'][_0x7c62('0x1a')]?_[_0x7c62('0x1b')](_0x57b61b[_0x7c62('0x17')]['include'],function(_0x3db69a){return{'model':db[_0x3db69a[_0x7c62('0x1c')]],'as':_0x3db69a['as'],'attributes':_0x3db69a['attributes'],'include':_0x3db69a[_0x7c62('0x1a')]?_['map'](_0x3db69a[_0x7c62('0x1a')],function(_0x5957d1){return{'model':db[_0x5957d1['model']],'as':_0x5957d1['as'],'attributes':_0x5957d1['attributes'],'include':_0x5957d1[_0x7c62('0x1a')]?_['map'](_0x5957d1[_0x7c62('0x1a')],function(_0x167172){return{'model':db[_0x167172[_0x7c62('0x1c')]],'as':_0x167172['as'],'attributes':_0x167172[_0x7c62('0x19')]};}):[]};}):[]};}):[]:[]})[_0x7c62('0xb')](function(_0xb67b58){logger[_0x7c62('0x13')]('ShowSugarcrmAccount',_0x57b61b);logger['debug'](_0x7c62('0x1d'),_0x57b61b,JSON[_0x7c62('0xf')](_0xb67b58));_0x18f0a4(_0xb67b58);})[_0x7c62('0x14')](function(_0x24bf02){logger['error']('ShowSugarcrmAccount',_0x24bf02[_0x7c62('0x11')],_0x57b61b);_0x3e7ec(_0x29994a[_0x7c62('0x10')](0x1f4,_0x24bf02[_0x7c62('0x11')]));});});};