Built motion from commit e02f907f.|2.6.14
[motion2.git] / server / api / intSalesforceAccount / intSalesforceAccount.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 _0x3f5a=['limit','include','model','ShowSalesforceAccount','find','map','debug','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','then','request\x20sent','SalesforceAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','SalesforceAccount,\x20%s,\x20%s','message','info','catch','GetSalesforceAccount','SalesforceAccount','findAll','options','where','attributes'];(function(_0x131a3f,_0x2b9dd4){var _0xb66809=function(_0x2c0c6c){while(--_0x2c0c6c){_0x131a3f['push'](_0x131a3f['shift']());}};_0xb66809(++_0x2b9dd4);}(_0x3f5a,0x142));var _0xa3f5=function(_0x24061a,_0x1c9f4d){_0x24061a=_0x24061a-0x0;var _0x82054e=_0x3f5a[_0x24061a];return _0x82054e;};'use strict';var _=require(_0xa3f5('0x0'));var util=require(_0xa3f5('0x1'));var moment=require(_0xa3f5('0x2'));var BPromise=require(_0xa3f5('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xa3f5('0x4'));var db=require(_0xa3f5('0x5'))['db'];var utils=require(_0xa3f5('0x6'));var logger=require('../../config/logger')(_0xa3f5('0x7'));var config=require(_0xa3f5('0x8'));var jayson=require(_0xa3f5('0x9'));var client=jayson[_0xa3f5('0xa')][_0xa3f5('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x51eec1,_0x17bb18,_0x5bd513){return new BPromise(function(_0x4ab871,_0x4e96d9){return client['request'](_0x51eec1,_0x5bd513)[_0xa3f5('0xc')](function(_0x100d6d){logger['info']('SalesforceAccount,\x20%s,\x20%s',_0x17bb18,_0xa3f5('0xd'));logger['debug'](_0xa3f5('0xe'),_0x17bb18,'request\x20sent',JSON[_0xa3f5('0xf')](_0x100d6d));if(_0x100d6d[_0xa3f5('0x10')]){if(_0x100d6d[_0xa3f5('0x10')][_0xa3f5('0x11')]===0x1f4){logger['error'](_0xa3f5('0x12'),_0x17bb18,_0x100d6d['error']['message']);return _0x4e96d9(_0x100d6d[_0xa3f5('0x10')][_0xa3f5('0x13')]);}logger[_0xa3f5('0x10')](_0xa3f5('0x12'),_0x17bb18,_0x100d6d[_0xa3f5('0x10')][_0xa3f5('0x13')]);return _0x4ab871(_0x100d6d['error']['message']);}else{logger[_0xa3f5('0x14')](_0xa3f5('0x12'),_0x17bb18,'request\x20sent');_0x4ab871(_0x100d6d['result'][_0xa3f5('0x13')]);}})[_0xa3f5('0x15')](function(_0x506ba0){logger[_0xa3f5('0x10')](_0xa3f5('0x12'),_0x17bb18,_0x506ba0);_0x4e96d9(_0x506ba0);});});}exports[_0xa3f5('0x16')]=function(_0xfe183d){var _0x436674=this;return new Promise(function(_0x1442aa,_0x379182){return db[_0xa3f5('0x17')][_0xa3f5('0x18')]({'raw':_0xfe183d[_0xa3f5('0x19')]?_0xfe183d['options']['raw']===undefined?!![]:![]:!![],'where':_0xfe183d[_0xa3f5('0x19')]?_0xfe183d['options'][_0xa3f5('0x1a')]||null:null,'attributes':_0xfe183d[_0xa3f5('0x19')]?_0xfe183d[_0xa3f5('0x19')][_0xa3f5('0x1b')]||null:null,'limit':_0xfe183d[_0xa3f5('0x19')]?_0xfe183d[_0xa3f5('0x19')][_0xa3f5('0x1c')]||null:null,'include':_0xfe183d[_0xa3f5('0x19')]?_0xfe183d[_0xa3f5('0x19')]['include']?_['map'](_0xfe183d[_0xa3f5('0x19')][_0xa3f5('0x1d')],function(_0x13a74e){return{'model':db[_0x13a74e[_0xa3f5('0x1e')]],'as':_0x13a74e['as'],'attributes':_0x13a74e[_0xa3f5('0x1b')],'include':_0x13a74e[_0xa3f5('0x1d')]?_['map'](_0x13a74e[_0xa3f5('0x1d')],function(_0x3a5cde){return{'model':db[_0x3a5cde['model']],'as':_0x3a5cde['as'],'attributes':_0x3a5cde['attributes'],'include':_0x3a5cde['include']?_['map'](_0x3a5cde[_0xa3f5('0x1d')],function(_0x50b246){return{'model':db[_0x50b246['model']],'as':_0x50b246['as'],'attributes':_0x50b246[_0xa3f5('0x1b')]};}):[]};}):[]};}):[]:[]})[_0xa3f5('0xc')](function(_0xe2ec74){logger[_0xa3f5('0x14')](_0xa3f5('0x16'),_0xfe183d);logger['debug'](_0xa3f5('0x16'),_0xfe183d,JSON['stringify'](_0xe2ec74));_0x1442aa(_0xe2ec74);})['catch'](function(_0x2d2385){logger[_0xa3f5('0x10')](_0xa3f5('0x16'),_0x2d2385[_0xa3f5('0x13')],_0xfe183d);_0x379182(_0x436674[_0xa3f5('0x10')](0x1f4,_0x2d2385[_0xa3f5('0x13')]));});});};exports[_0xa3f5('0x1f')]=function(_0x1b233e){var _0x510da2=this;return new Promise(function(_0x27fc54,_0x1b8447){return db[_0xa3f5('0x17')][_0xa3f5('0x20')]({'raw':_0x1b233e[_0xa3f5('0x19')]?_0x1b233e[_0xa3f5('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x1b233e['options']?_0x1b233e[_0xa3f5('0x19')][_0xa3f5('0x1a')]||null:null,'attributes':_0x1b233e['options']?_0x1b233e[_0xa3f5('0x19')][_0xa3f5('0x1b')]||null:null,'include':_0x1b233e[_0xa3f5('0x19')]?_0x1b233e[_0xa3f5('0x19')][_0xa3f5('0x1d')]?_[_0xa3f5('0x21')](_0x1b233e[_0xa3f5('0x19')][_0xa3f5('0x1d')],function(_0x2aadc2){return{'model':db[_0x2aadc2[_0xa3f5('0x1e')]],'as':_0x2aadc2['as'],'attributes':_0x2aadc2[_0xa3f5('0x1b')],'include':_0x2aadc2['include']?_[_0xa3f5('0x21')](_0x2aadc2[_0xa3f5('0x1d')],function(_0x27c76d){return{'model':db[_0x27c76d[_0xa3f5('0x1e')]],'as':_0x27c76d['as'],'attributes':_0x27c76d[_0xa3f5('0x1b')],'include':_0x27c76d[_0xa3f5('0x1d')]?_[_0xa3f5('0x21')](_0x27c76d[_0xa3f5('0x1d')],function(_0x2a4370){return{'model':db[_0x2a4370[_0xa3f5('0x1e')]],'as':_0x2a4370['as'],'attributes':_0x2a4370[_0xa3f5('0x1b')]};}):[]};}):[]};}):[]:[]})[_0xa3f5('0xc')](function(_0x5d5a49){logger[_0xa3f5('0x14')]('ShowSalesforceAccount',_0x1b233e);logger[_0xa3f5('0x22')](_0xa3f5('0x1f'),_0x1b233e,JSON[_0xa3f5('0xf')](_0x5d5a49));_0x27fc54(_0x5d5a49);})['catch'](function(_0x1e3ff7){logger[_0xa3f5('0x10')](_0xa3f5('0x1f'),_0x1e3ff7['message'],_0x1b233e);_0x1b8447(_0x510da2[_0xa3f5('0x10')](0x1f4,_0x1e3ff7[_0xa3f5('0x13')]));});});};