Built motion from commit (unavailable).|2.0.84
[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 _0x4444=['raw','limit','include','map','model','attributes','then','ShowSugarcrmAccount','find','where','lodash','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','SugarcrmAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','info','result','catch','GetSugarcrmAccount','SugarcrmAccount','options'];(function(_0x5ab5bd,_0x12c446){var _0x3dddd8=function(_0x5ea7d0){while(--_0x5ea7d0){_0x5ab5bd['push'](_0x5ab5bd['shift']());}};_0x3dddd8(++_0x12c446);}(_0x4444,0x17e));var _0x4444=function(_0x23c2c3,_0x27ecc8){_0x23c2c3=_0x23c2c3-0x0;var _0x41e09f=_0x4444[_0x23c2c3];return _0x41e09f;};'use strict';var _=require(_0x4444('0x0'));var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x4444('0x1'));var fs=require('fs');var Redis=require(_0x4444('0x2'));var db=require(_0x4444('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x4444('0x4'))(_0x4444('0x5'));var config=require(_0x4444('0x6'));var jayson=require(_0x4444('0x7'));var client=jayson[_0x4444('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x337cc7,_0x49948c,_0x442f55){return new BPromise(function(_0x4ff5a7,_0x1426fc){return client['request'](_0x337cc7,_0x442f55)['then'](function(_0x31e179){logger['info'](_0x4444('0x9'),_0x49948c,_0x4444('0xa'));logger[_0x4444('0xb')]('SugarcrmAccount,\x20%s,\x20%s,\x20%s',_0x49948c,_0x4444('0xa'),JSON[_0x4444('0xc')](_0x31e179));if(_0x31e179[_0x4444('0xd')]){if(_0x31e179[_0x4444('0xd')]['code']===0x1f4){logger[_0x4444('0xd')]('SugarcrmAccount,\x20%s,\x20%s',_0x49948c,_0x31e179[_0x4444('0xd')][_0x4444('0xe')]);return _0x1426fc(_0x31e179[_0x4444('0xd')][_0x4444('0xe')]);}logger['error']('SugarcrmAccount,\x20%s,\x20%s',_0x49948c,_0x31e179[_0x4444('0xd')][_0x4444('0xe')]);return _0x4ff5a7(_0x31e179['error']['message']);}else{logger[_0x4444('0xf')](_0x4444('0x9'),_0x49948c,_0x4444('0xa'));_0x4ff5a7(_0x31e179[_0x4444('0x10')]['message']);}})[_0x4444('0x11')](function(_0x38c3bf){logger['error']('SugarcrmAccount,\x20%s,\x20%s',_0x49948c,_0x38c3bf);_0x1426fc(_0x38c3bf);});});}exports[_0x4444('0x12')]=function(_0x107909){var _0x59e2d8=this;return new Promise(function(_0x597a44,_0x3a8ecd){return db[_0x4444('0x13')]['findAll']({'raw':_0x107909[_0x4444('0x14')]?_0x107909['options'][_0x4444('0x15')]===undefined?!![]:![]:!![],'where':_0x107909[_0x4444('0x14')]?_0x107909['options']['where']||null:null,'attributes':_0x107909[_0x4444('0x14')]?_0x107909['options']['attributes']||null:null,'limit':_0x107909['options']?_0x107909[_0x4444('0x14')][_0x4444('0x16')]||null:null,'include':_0x107909[_0x4444('0x14')]?_0x107909['options'][_0x4444('0x17')]?_[_0x4444('0x18')](_0x107909[_0x4444('0x14')][_0x4444('0x17')],function(_0x1034cc){return{'model':db[_0x1034cc['model']],'as':_0x1034cc['as'],'attributes':_0x1034cc['attributes'],'include':_0x1034cc[_0x4444('0x17')]?_[_0x4444('0x18')](_0x1034cc[_0x4444('0x17')],function(_0x32a1d1){return{'model':db[_0x32a1d1[_0x4444('0x19')]],'as':_0x32a1d1['as'],'attributes':_0x32a1d1[_0x4444('0x1a')],'include':_0x32a1d1[_0x4444('0x17')]?_[_0x4444('0x18')](_0x32a1d1[_0x4444('0x17')],function(_0x509840){return{'model':db[_0x509840['model']],'as':_0x509840['as'],'attributes':_0x509840[_0x4444('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x4444('0x1b')](function(_0x5b0db9){logger['info'](_0x4444('0x12'),_0x107909);logger[_0x4444('0xb')](_0x4444('0x12'),_0x107909,JSON[_0x4444('0xc')](_0x5b0db9));_0x597a44(_0x5b0db9);})[_0x4444('0x11')](function(_0x2bb1f6){logger[_0x4444('0xd')](_0x4444('0x12'),_0x2bb1f6[_0x4444('0xe')],_0x107909);_0x3a8ecd(_0x59e2d8[_0x4444('0xd')](0x1f4,_0x2bb1f6[_0x4444('0xe')]));});});};exports[_0x4444('0x1c')]=function(_0x94f69c){var _0xcffa52=this;return new Promise(function(_0x1c0fc1,_0x19ac5c){return db[_0x4444('0x13')][_0x4444('0x1d')]({'raw':_0x94f69c[_0x4444('0x14')]?_0x94f69c[_0x4444('0x14')][_0x4444('0x15')]===undefined?!![]:![]:!![],'where':_0x94f69c[_0x4444('0x14')]?_0x94f69c[_0x4444('0x14')][_0x4444('0x1e')]||null:null,'attributes':_0x94f69c[_0x4444('0x14')]?_0x94f69c[_0x4444('0x14')][_0x4444('0x1a')]||null:null,'include':_0x94f69c[_0x4444('0x14')]?_0x94f69c[_0x4444('0x14')]['include']?_['map'](_0x94f69c[_0x4444('0x14')][_0x4444('0x17')],function(_0x21a889){return{'model':db[_0x21a889[_0x4444('0x19')]],'as':_0x21a889['as'],'attributes':_0x21a889[_0x4444('0x1a')],'include':_0x21a889['include']?_[_0x4444('0x18')](_0x21a889[_0x4444('0x17')],function(_0x52da80){return{'model':db[_0x52da80['model']],'as':_0x52da80['as'],'attributes':_0x52da80[_0x4444('0x1a')],'include':_0x52da80[_0x4444('0x17')]?_[_0x4444('0x18')](_0x52da80[_0x4444('0x17')],function(_0x2230a4){return{'model':db[_0x2230a4[_0x4444('0x19')]],'as':_0x2230a4['as'],'attributes':_0x2230a4[_0x4444('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x4444('0x1b')](function(_0x5d562b){logger[_0x4444('0xf')]('ShowSugarcrmAccount',_0x94f69c);logger[_0x4444('0xb')](_0x4444('0x1c'),_0x94f69c,JSON['stringify'](_0x5d562b));_0x1c0fc1(_0x5d562b);})['catch'](function(_0x23ed2d){logger['error'](_0x4444('0x1c'),_0x23ed2d[_0x4444('0xe')],_0x94f69c);_0x19ac5c(_0xcffa52[_0x4444('0xd')](0x1f4,_0x23ed2d['message']));});});};