Built motion from commit caf7d5f0.|2.5.39
[motion2.git] / server / api / intFreshsalesAccount / intFreshsalesAccount.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 _0x33af=['include','map','model','ShowFreshsalesAccount','find','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','http','then','info','FreshsalesAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','GetFreshsalesAccount','FreshsalesAccount','options','raw','where','attributes','limit'];(function(_0x4b7b62,_0x4920a9){var _0x2280df=function(_0x21e1f8){while(--_0x21e1f8){_0x4b7b62['push'](_0x4b7b62['shift']());}};_0x2280df(++_0x4920a9);}(_0x33af,0xec));var _0xf33a=function(_0x1649af,_0x9522f8){_0x1649af=_0x1649af-0x0;var _0x28359a=_0x33af[_0x1649af];return _0x28359a;};'use strict';var _=require('lodash');var util=require(_0xf33a('0x0'));var moment=require('moment');var BPromise=require(_0xf33a('0x1'));var rs=require(_0xf33a('0x2'));var fs=require('fs');var Redis=require(_0xf33a('0x3'));var db=require(_0xf33a('0x4'))['db'];var utils=require(_0xf33a('0x5'));var logger=require(_0xf33a('0x6'))('rpc');var config=require(_0xf33a('0x7'));var jayson=require(_0xf33a('0x8'));var client=jayson['client'][_0xf33a('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x384b14,_0x1b2b01,_0x2f3730){return new BPromise(function(_0x2baabb,_0x2cb169){return client['request'](_0x384b14,_0x2f3730)[_0xf33a('0xa')](function(_0x14eb0e){logger[_0xf33a('0xb')](_0xf33a('0xc'),_0x1b2b01,_0xf33a('0xd'));logger[_0xf33a('0xe')]('FreshsalesAccount,\x20%s,\x20%s,\x20%s',_0x1b2b01,'request\x20sent',JSON[_0xf33a('0xf')](_0x14eb0e));if(_0x14eb0e[_0xf33a('0x10')]){if(_0x14eb0e[_0xf33a('0x10')][_0xf33a('0x11')]===0x1f4){logger[_0xf33a('0x10')]('FreshsalesAccount,\x20%s,\x20%s',_0x1b2b01,_0x14eb0e[_0xf33a('0x10')][_0xf33a('0x12')]);return _0x2cb169(_0x14eb0e['error']['message']);}logger[_0xf33a('0x10')](_0xf33a('0xc'),_0x1b2b01,_0x14eb0e[_0xf33a('0x10')][_0xf33a('0x12')]);return _0x2baabb(_0x14eb0e[_0xf33a('0x10')][_0xf33a('0x12')]);}else{logger[_0xf33a('0xb')](_0xf33a('0xc'),_0x1b2b01,'request\x20sent');_0x2baabb(_0x14eb0e[_0xf33a('0x13')]['message']);}})[_0xf33a('0x14')](function(_0x229389){logger['error'](_0xf33a('0xc'),_0x1b2b01,_0x229389);_0x2cb169(_0x229389);});});}exports[_0xf33a('0x15')]=function(_0x524109){var _0x2946ef=this;return new Promise(function(_0x23d9e2,_0x38d69a){return db[_0xf33a('0x16')]['findAll']({'raw':_0x524109[_0xf33a('0x17')]?_0x524109[_0xf33a('0x17')][_0xf33a('0x18')]===undefined?!![]:![]:!![],'where':_0x524109[_0xf33a('0x17')]?_0x524109[_0xf33a('0x17')][_0xf33a('0x19')]||null:null,'attributes':_0x524109[_0xf33a('0x17')]?_0x524109[_0xf33a('0x17')][_0xf33a('0x1a')]||null:null,'limit':_0x524109[_0xf33a('0x17')]?_0x524109['options'][_0xf33a('0x1b')]||null:null,'include':_0x524109[_0xf33a('0x17')]?_0x524109[_0xf33a('0x17')][_0xf33a('0x1c')]?_[_0xf33a('0x1d')](_0x524109['options'][_0xf33a('0x1c')],function(_0x5882ba){return{'model':db[_0x5882ba[_0xf33a('0x1e')]],'as':_0x5882ba['as'],'attributes':_0x5882ba[_0xf33a('0x1a')],'include':_0x5882ba[_0xf33a('0x1c')]?_[_0xf33a('0x1d')](_0x5882ba[_0xf33a('0x1c')],function(_0x4b9801){return{'model':db[_0x4b9801[_0xf33a('0x1e')]],'as':_0x4b9801['as'],'attributes':_0x4b9801[_0xf33a('0x1a')],'include':_0x4b9801['include']?_['map'](_0x4b9801[_0xf33a('0x1c')],function(_0x5f0a53){return{'model':db[_0x5f0a53['model']],'as':_0x5f0a53['as'],'attributes':_0x5f0a53[_0xf33a('0x1a')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x79d653){logger['info'](_0xf33a('0x15'),_0x524109);logger[_0xf33a('0xe')](_0xf33a('0x15'),_0x524109,JSON[_0xf33a('0xf')](_0x79d653));_0x23d9e2(_0x79d653);})[_0xf33a('0x14')](function(_0x3068a9){logger[_0xf33a('0x10')](_0xf33a('0x15'),_0x3068a9[_0xf33a('0x12')],_0x524109);_0x38d69a(_0x2946ef[_0xf33a('0x10')](0x1f4,_0x3068a9[_0xf33a('0x12')]));});});};exports[_0xf33a('0x1f')]=function(_0x22c9f2){var _0x3f714e=this;return new Promise(function(_0x2fd098,_0x5eb14a){return db[_0xf33a('0x16')][_0xf33a('0x20')]({'raw':_0x22c9f2[_0xf33a('0x17')]?_0x22c9f2[_0xf33a('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x22c9f2[_0xf33a('0x17')]?_0x22c9f2[_0xf33a('0x17')][_0xf33a('0x19')]||null:null,'attributes':_0x22c9f2[_0xf33a('0x17')]?_0x22c9f2[_0xf33a('0x17')][_0xf33a('0x1a')]||null:null,'include':_0x22c9f2['options']?_0x22c9f2[_0xf33a('0x17')][_0xf33a('0x1c')]?_[_0xf33a('0x1d')](_0x22c9f2[_0xf33a('0x17')][_0xf33a('0x1c')],function(_0x57e7be){return{'model':db[_0x57e7be['model']],'as':_0x57e7be['as'],'attributes':_0x57e7be[_0xf33a('0x1a')],'include':_0x57e7be['include']?_['map'](_0x57e7be['include'],function(_0x2c4840){return{'model':db[_0x2c4840[_0xf33a('0x1e')]],'as':_0x2c4840['as'],'attributes':_0x2c4840['attributes'],'include':_0x2c4840[_0xf33a('0x1c')]?_['map'](_0x2c4840[_0xf33a('0x1c')],function(_0x1f11b3){return{'model':db[_0x1f11b3[_0xf33a('0x1e')]],'as':_0x1f11b3['as'],'attributes':_0x1f11b3[_0xf33a('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xf33a('0xa')](function(_0x23c92b){logger['info'](_0xf33a('0x1f'),_0x22c9f2);logger[_0xf33a('0xe')]('ShowFreshsalesAccount',_0x22c9f2,JSON[_0xf33a('0xf')](_0x23c92b));_0x2fd098(_0x23c92b);})[_0xf33a('0x14')](function(_0x3e0a98){logger['error'](_0xf33a('0x1f'),_0x3e0a98[_0xf33a('0x12')],_0x22c9f2);_0x5eb14a(_0x3f714e[_0xf33a('0x10')](0x1f4,_0x3e0a98[_0xf33a('0x12')]));});});};