Built motion from commit f0b1811d.|2.6.6
[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 _0x888f=['stringify','error','code','SugarcrmAccount,\x20%s,\x20%s','message','result','catch','SugarcrmAccount','findAll','options','limit','include','map','model','attributes','GetSugarcrmAccount','ShowSugarcrmAccount','find','raw','where','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','then','info','request\x20sent','debug'];(function(_0x162d2a,_0x5661bc){var _0x3a6fb3=function(_0x4cbf91){while(--_0x4cbf91){_0x162d2a['push'](_0x162d2a['shift']());}};_0x3a6fb3(++_0x5661bc);}(_0x888f,0x1b8));var _0xf888=function(_0x1baedf,_0x22eacf){_0x1baedf=_0x1baedf-0x0;var _0x4e6817=_0x888f[_0x1baedf];return _0x4e6817;};'use strict';var _=require(_0xf888('0x0'));var util=require(_0xf888('0x1'));var moment=require(_0xf888('0x2'));var BPromise=require(_0xf888('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xf888('0x4'));var db=require(_0xf888('0x5'))['db'];var utils=require(_0xf888('0x6'));var logger=require(_0xf888('0x7'))(_0xf888('0x8'));var config=require('../../config/environment');var jayson=require(_0xf888('0x9'));var client=jayson[_0xf888('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x293526,_0x504c03,_0x12b951){return new BPromise(function(_0x170076,_0x5068ed){return client['request'](_0x293526,_0x12b951)[_0xf888('0xb')](function(_0x47be85){logger[_0xf888('0xc')]('SugarcrmAccount,\x20%s,\x20%s',_0x504c03,_0xf888('0xd'));logger[_0xf888('0xe')]('SugarcrmAccount,\x20%s,\x20%s,\x20%s',_0x504c03,'request\x20sent',JSON[_0xf888('0xf')](_0x47be85));if(_0x47be85[_0xf888('0x10')]){if(_0x47be85[_0xf888('0x10')][_0xf888('0x11')]===0x1f4){logger[_0xf888('0x10')](_0xf888('0x12'),_0x504c03,_0x47be85[_0xf888('0x10')][_0xf888('0x13')]);return _0x5068ed(_0x47be85[_0xf888('0x10')]['message']);}logger[_0xf888('0x10')](_0xf888('0x12'),_0x504c03,_0x47be85[_0xf888('0x10')][_0xf888('0x13')]);return _0x170076(_0x47be85[_0xf888('0x10')][_0xf888('0x13')]);}else{logger[_0xf888('0xc')](_0xf888('0x12'),_0x504c03,_0xf888('0xd'));_0x170076(_0x47be85[_0xf888('0x14')][_0xf888('0x13')]);}})[_0xf888('0x15')](function(_0x5b1f16){logger[_0xf888('0x10')](_0xf888('0x12'),_0x504c03,_0x5b1f16);_0x5068ed(_0x5b1f16);});});}exports['GetSugarcrmAccount']=function(_0x37c88b){var _0x2b4930=this;return new Promise(function(_0xd42bd8,_0x46190d){return db[_0xf888('0x16')][_0xf888('0x17')]({'raw':_0x37c88b[_0xf888('0x18')]?_0x37c88b['options']['raw']===undefined?!![]:![]:!![],'where':_0x37c88b[_0xf888('0x18')]?_0x37c88b[_0xf888('0x18')]['where']||null:null,'attributes':_0x37c88b[_0xf888('0x18')]?_0x37c88b[_0xf888('0x18')]['attributes']||null:null,'limit':_0x37c88b[_0xf888('0x18')]?_0x37c88b[_0xf888('0x18')][_0xf888('0x19')]||null:null,'include':_0x37c88b['options']?_0x37c88b[_0xf888('0x18')][_0xf888('0x1a')]?_[_0xf888('0x1b')](_0x37c88b[_0xf888('0x18')][_0xf888('0x1a')],function(_0x3515ab){return{'model':db[_0x3515ab[_0xf888('0x1c')]],'as':_0x3515ab['as'],'attributes':_0x3515ab[_0xf888('0x1d')],'include':_0x3515ab[_0xf888('0x1a')]?_['map'](_0x3515ab[_0xf888('0x1a')],function(_0x5b3e8f){return{'model':db[_0x5b3e8f[_0xf888('0x1c')]],'as':_0x5b3e8f['as'],'attributes':_0x5b3e8f[_0xf888('0x1d')],'include':_0x5b3e8f[_0xf888('0x1a')]?_[_0xf888('0x1b')](_0x5b3e8f[_0xf888('0x1a')],function(_0x198f0a){return{'model':db[_0x198f0a['model']],'as':_0x198f0a['as'],'attributes':_0x198f0a[_0xf888('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xf888('0xb')](function(_0x2f5deb){logger[_0xf888('0xc')](_0xf888('0x1e'),_0x37c88b);logger[_0xf888('0xe')](_0xf888('0x1e'),_0x37c88b,JSON['stringify'](_0x2f5deb));_0xd42bd8(_0x2f5deb);})['catch'](function(_0x275add){logger[_0xf888('0x10')](_0xf888('0x1e'),_0x275add['message'],_0x37c88b);_0x46190d(_0x2b4930[_0xf888('0x10')](0x1f4,_0x275add[_0xf888('0x13')]));});});};exports[_0xf888('0x1f')]=function(_0x4bf296){var _0x5557dd=this;return new Promise(function(_0x1a60b9,_0x43fd9f){return db[_0xf888('0x16')][_0xf888('0x20')]({'raw':_0x4bf296['options']?_0x4bf296[_0xf888('0x18')][_0xf888('0x21')]===undefined?!![]:![]:!![],'where':_0x4bf296[_0xf888('0x18')]?_0x4bf296[_0xf888('0x18')][_0xf888('0x22')]||null:null,'attributes':_0x4bf296[_0xf888('0x18')]?_0x4bf296['options']['attributes']||null:null,'include':_0x4bf296[_0xf888('0x18')]?_0x4bf296[_0xf888('0x18')][_0xf888('0x1a')]?_[_0xf888('0x1b')](_0x4bf296[_0xf888('0x18')][_0xf888('0x1a')],function(_0x4b9103){return{'model':db[_0x4b9103[_0xf888('0x1c')]],'as':_0x4b9103['as'],'attributes':_0x4b9103['attributes'],'include':_0x4b9103[_0xf888('0x1a')]?_[_0xf888('0x1b')](_0x4b9103[_0xf888('0x1a')],function(_0x193e46){return{'model':db[_0x193e46[_0xf888('0x1c')]],'as':_0x193e46['as'],'attributes':_0x193e46['attributes'],'include':_0x193e46['include']?_['map'](_0x193e46['include'],function(_0xe138e1){return{'model':db[_0xe138e1[_0xf888('0x1c')]],'as':_0xe138e1['as'],'attributes':_0xe138e1['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0xd84fe2){logger[_0xf888('0xc')]('ShowSugarcrmAccount',_0x4bf296);logger[_0xf888('0xe')](_0xf888('0x1f'),_0x4bf296,JSON[_0xf888('0xf')](_0xd84fe2));_0x1a60b9(_0xd84fe2);})[_0xf888('0x15')](function(_0xe3988){logger['error'](_0xf888('0x1f'),_0xe3988[_0xf888('0x13')],_0x4bf296);_0x43fd9f(_0x5557dd[_0xf888('0x10')](0x1f4,_0xe3988['message']));});});};