Built motion from commit 85f716e9.|2.6.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 _0xbcae=['code','message','result','GetSugarcrmAccount','SugarcrmAccount','findAll','options','raw','where','attributes','limit','include','map','model','debug','catch','find','ShowSugarcrmAccount','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','client','http','request','then','info','SugarcrmAccount,\x20%s,\x20%s','request\x20sent','SugarcrmAccount,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x10d34b,_0x4fef76){var _0x92b0bf=function(_0x16e291){while(--_0x16e291){_0x10d34b['push'](_0x10d34b['shift']());}};_0x92b0bf(++_0x4fef76);}(_0xbcae,0xa2));var _0xebca=function(_0x32960c,_0x1aa103){_0x32960c=_0x32960c-0x0;var _0x225d13=_0xbcae[_0x32960c];return _0x225d13;};'use strict';var _=require('lodash');var util=require(_0xebca('0x0'));var moment=require(_0xebca('0x1'));var BPromise=require(_0xebca('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xebca('0x3'));var db=require(_0xebca('0x4'))['db'];var utils=require(_0xebca('0x5'));var logger=require(_0xebca('0x6'))(_0xebca('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xebca('0x8')][_0xebca('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x4d681e,_0x7414ac,_0x25a16e){return new BPromise(function(_0xfc8b46,_0x3b25e6){return client[_0xebca('0xa')](_0x4d681e,_0x25a16e)[_0xebca('0xb')](function(_0x9a1c35){logger[_0xebca('0xc')](_0xebca('0xd'),_0x7414ac,_0xebca('0xe'));logger['debug'](_0xebca('0xf'),_0x7414ac,_0xebca('0xe'),JSON[_0xebca('0x10')](_0x9a1c35));if(_0x9a1c35[_0xebca('0x11')]){if(_0x9a1c35[_0xebca('0x11')][_0xebca('0x12')]===0x1f4){logger[_0xebca('0x11')](_0xebca('0xd'),_0x7414ac,_0x9a1c35['error']['message']);return _0x3b25e6(_0x9a1c35['error'][_0xebca('0x13')]);}logger['error'](_0xebca('0xd'),_0x7414ac,_0x9a1c35['error'][_0xebca('0x13')]);return _0xfc8b46(_0x9a1c35[_0xebca('0x11')]['message']);}else{logger[_0xebca('0xc')](_0xebca('0xd'),_0x7414ac,_0xebca('0xe'));_0xfc8b46(_0x9a1c35[_0xebca('0x14')]['message']);}})['catch'](function(_0x312ab9){logger['error']('SugarcrmAccount,\x20%s,\x20%s',_0x7414ac,_0x312ab9);_0x3b25e6(_0x312ab9);});});}exports[_0xebca('0x15')]=function(_0x2ef114){var _0x3d80c1=this;return new Promise(function(_0x1ec4c7,_0x17dcfb){return db[_0xebca('0x16')][_0xebca('0x17')]({'raw':_0x2ef114[_0xebca('0x18')]?_0x2ef114[_0xebca('0x18')][_0xebca('0x19')]===undefined?!![]:![]:!![],'where':_0x2ef114[_0xebca('0x18')]?_0x2ef114[_0xebca('0x18')][_0xebca('0x1a')]||null:null,'attributes':_0x2ef114['options']?_0x2ef114[_0xebca('0x18')][_0xebca('0x1b')]||null:null,'limit':_0x2ef114[_0xebca('0x18')]?_0x2ef114['options'][_0xebca('0x1c')]||null:null,'include':_0x2ef114[_0xebca('0x18')]?_0x2ef114[_0xebca('0x18')][_0xebca('0x1d')]?_[_0xebca('0x1e')](_0x2ef114[_0xebca('0x18')]['include'],function(_0x157061){return{'model':db[_0x157061[_0xebca('0x1f')]],'as':_0x157061['as'],'attributes':_0x157061['attributes'],'include':_0x157061[_0xebca('0x1d')]?_[_0xebca('0x1e')](_0x157061[_0xebca('0x1d')],function(_0xd6953b){return{'model':db[_0xd6953b['model']],'as':_0xd6953b['as'],'attributes':_0xd6953b[_0xebca('0x1b')],'include':_0xd6953b[_0xebca('0x1d')]?_[_0xebca('0x1e')](_0xd6953b[_0xebca('0x1d')],function(_0x167a50){return{'model':db[_0x167a50[_0xebca('0x1f')]],'as':_0x167a50['as'],'attributes':_0x167a50['attributes']};}):[]};}):[]};}):[]:[]})[_0xebca('0xb')](function(_0x5bd2de){logger[_0xebca('0xc')](_0xebca('0x15'),_0x2ef114);logger[_0xebca('0x20')]('GetSugarcrmAccount',_0x2ef114,JSON[_0xebca('0x10')](_0x5bd2de));_0x1ec4c7(_0x5bd2de);})[_0xebca('0x21')](function(_0x3fe5f3){logger['error']('GetSugarcrmAccount',_0x3fe5f3[_0xebca('0x13')],_0x2ef114);_0x17dcfb(_0x3d80c1['error'](0x1f4,_0x3fe5f3[_0xebca('0x13')]));});});};exports['ShowSugarcrmAccount']=function(_0x3c41e3){var _0x2a3a42=this;return new Promise(function(_0xefeff2,_0x3e6593){return db['SugarcrmAccount'][_0xebca('0x22')]({'raw':_0x3c41e3['options']?_0x3c41e3['options'][_0xebca('0x19')]===undefined?!![]:![]:!![],'where':_0x3c41e3[_0xebca('0x18')]?_0x3c41e3[_0xebca('0x18')][_0xebca('0x1a')]||null:null,'attributes':_0x3c41e3[_0xebca('0x18')]?_0x3c41e3[_0xebca('0x18')][_0xebca('0x1b')]||null:null,'include':_0x3c41e3[_0xebca('0x18')]?_0x3c41e3[_0xebca('0x18')][_0xebca('0x1d')]?_['map'](_0x3c41e3[_0xebca('0x18')][_0xebca('0x1d')],function(_0x2dc443){return{'model':db[_0x2dc443['model']],'as':_0x2dc443['as'],'attributes':_0x2dc443[_0xebca('0x1b')],'include':_0x2dc443[_0xebca('0x1d')]?_['map'](_0x2dc443[_0xebca('0x1d')],function(_0x3aacc3){return{'model':db[_0x3aacc3[_0xebca('0x1f')]],'as':_0x3aacc3['as'],'attributes':_0x3aacc3['attributes'],'include':_0x3aacc3[_0xebca('0x1d')]?_['map'](_0x3aacc3['include'],function(_0x13b02b){return{'model':db[_0x13b02b['model']],'as':_0x13b02b['as'],'attributes':_0x13b02b[_0xebca('0x1b')]};}):[]};}):[]};}):[]:[]})[_0xebca('0xb')](function(_0x797048){logger[_0xebca('0xc')](_0xebca('0x23'),_0x3c41e3);logger[_0xebca('0x20')](_0xebca('0x23'),_0x3c41e3,JSON[_0xebca('0x10')](_0x797048));_0xefeff2(_0x797048);})[_0xebca('0x21')](function(_0x3c1c96){logger[_0xebca('0x11')](_0xebca('0x23'),_0x3c1c96['message'],_0x3c41e3);_0x3e6593(_0x2a3a42['error'](0x1f4,_0x3c1c96[_0xebca('0x13')]));});});};