Built motion from commit bab6f49e.|2.6.17
[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 _0xba34=['request\x20sent','debug','FreshsalesAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetFreshsalesAccount','FreshsalesAccount','findAll','options','raw','where','attributes','limit','include','map','model','ShowFreshsalesAccount','find','lodash','util','moment','bluebird','randomstring','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','FreshsalesAccount,\x20%s,\x20%s'];(function(_0x340cbb,_0xc1482){var _0x522c95=function(_0x47260e){while(--_0x47260e){_0x340cbb['push'](_0x340cbb['shift']());}};_0x522c95(++_0xc1482);}(_0xba34,0x119));var _0x4ba3=function(_0xea5287,_0x1f655f){_0xea5287=_0xea5287-0x0;var _0x5b361c=_0xba34[_0xea5287];return _0x5b361c;};'use strict';var _=require(_0x4ba3('0x0'));var util=require(_0x4ba3('0x1'));var moment=require(_0x4ba3('0x2'));var BPromise=require(_0x4ba3('0x3'));var rs=require(_0x4ba3('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x4ba3('0x5'))(_0x4ba3('0x6'));var config=require(_0x4ba3('0x7'));var jayson=require(_0x4ba3('0x8'));var client=jayson[_0x4ba3('0x9')][_0x4ba3('0xa')]({'port':0x232a});function respondWithRpcPromise(_0xe5f99a,_0x585f2d,_0x6254fb){return new BPromise(function(_0x368eee,_0x2df7f3){return client[_0x4ba3('0xb')](_0xe5f99a,_0x6254fb)[_0x4ba3('0xc')](function(_0xcf1ec3){logger[_0x4ba3('0xd')](_0x4ba3('0xe'),_0x585f2d,_0x4ba3('0xf'));logger[_0x4ba3('0x10')](_0x4ba3('0x11'),_0x585f2d,'request\x20sent',JSON[_0x4ba3('0x12')](_0xcf1ec3));if(_0xcf1ec3[_0x4ba3('0x13')]){if(_0xcf1ec3['error'][_0x4ba3('0x14')]===0x1f4){logger['error'](_0x4ba3('0xe'),_0x585f2d,_0xcf1ec3['error'][_0x4ba3('0x15')]);return _0x2df7f3(_0xcf1ec3[_0x4ba3('0x13')][_0x4ba3('0x15')]);}logger[_0x4ba3('0x13')](_0x4ba3('0xe'),_0x585f2d,_0xcf1ec3[_0x4ba3('0x13')][_0x4ba3('0x15')]);return _0x368eee(_0xcf1ec3[_0x4ba3('0x13')][_0x4ba3('0x15')]);}else{logger[_0x4ba3('0xd')](_0x4ba3('0xe'),_0x585f2d,_0x4ba3('0xf'));_0x368eee(_0xcf1ec3[_0x4ba3('0x16')][_0x4ba3('0x15')]);}})[_0x4ba3('0x17')](function(_0x1b7776){logger['error'](_0x4ba3('0xe'),_0x585f2d,_0x1b7776);_0x2df7f3(_0x1b7776);});});}exports[_0x4ba3('0x18')]=function(_0x5ff7ce){var _0x451c92=this;return new Promise(function(_0x556290,_0x2519bb){return db[_0x4ba3('0x19')][_0x4ba3('0x1a')]({'raw':_0x5ff7ce[_0x4ba3('0x1b')]?_0x5ff7ce[_0x4ba3('0x1b')][_0x4ba3('0x1c')]===undefined?!![]:![]:!![],'where':_0x5ff7ce['options']?_0x5ff7ce['options'][_0x4ba3('0x1d')]||null:null,'attributes':_0x5ff7ce['options']?_0x5ff7ce[_0x4ba3('0x1b')][_0x4ba3('0x1e')]||null:null,'limit':_0x5ff7ce[_0x4ba3('0x1b')]?_0x5ff7ce[_0x4ba3('0x1b')][_0x4ba3('0x1f')]||null:null,'include':_0x5ff7ce[_0x4ba3('0x1b')]?_0x5ff7ce['options'][_0x4ba3('0x20')]?_[_0x4ba3('0x21')](_0x5ff7ce['options'][_0x4ba3('0x20')],function(_0x4ffe39){return{'model':db[_0x4ffe39[_0x4ba3('0x22')]],'as':_0x4ffe39['as'],'attributes':_0x4ffe39[_0x4ba3('0x1e')],'include':_0x4ffe39[_0x4ba3('0x20')]?_[_0x4ba3('0x21')](_0x4ffe39[_0x4ba3('0x20')],function(_0xe29a49){return{'model':db[_0xe29a49[_0x4ba3('0x22')]],'as':_0xe29a49['as'],'attributes':_0xe29a49[_0x4ba3('0x1e')],'include':_0xe29a49[_0x4ba3('0x20')]?_[_0x4ba3('0x21')](_0xe29a49['include'],function(_0x252f37){return{'model':db[_0x252f37[_0x4ba3('0x22')]],'as':_0x252f37['as'],'attributes':_0x252f37[_0x4ba3('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x10537e){logger[_0x4ba3('0xd')](_0x4ba3('0x18'),_0x5ff7ce);logger['debug'](_0x4ba3('0x18'),_0x5ff7ce,JSON[_0x4ba3('0x12')](_0x10537e));_0x556290(_0x10537e);})[_0x4ba3('0x17')](function(_0x22394d){logger['error']('GetFreshsalesAccount',_0x22394d[_0x4ba3('0x15')],_0x5ff7ce);_0x2519bb(_0x451c92[_0x4ba3('0x13')](0x1f4,_0x22394d[_0x4ba3('0x15')]));});});};exports[_0x4ba3('0x23')]=function(_0x2cb5d5){var _0x11f88f=this;return new Promise(function(_0x48b3b7,_0x27444b){return db[_0x4ba3('0x19')][_0x4ba3('0x24')]({'raw':_0x2cb5d5[_0x4ba3('0x1b')]?_0x2cb5d5[_0x4ba3('0x1b')][_0x4ba3('0x1c')]===undefined?!![]:![]:!![],'where':_0x2cb5d5[_0x4ba3('0x1b')]?_0x2cb5d5[_0x4ba3('0x1b')][_0x4ba3('0x1d')]||null:null,'attributes':_0x2cb5d5[_0x4ba3('0x1b')]?_0x2cb5d5['options']['attributes']||null:null,'include':_0x2cb5d5['options']?_0x2cb5d5[_0x4ba3('0x1b')][_0x4ba3('0x20')]?_[_0x4ba3('0x21')](_0x2cb5d5[_0x4ba3('0x1b')][_0x4ba3('0x20')],function(_0x137f9b){return{'model':db[_0x137f9b[_0x4ba3('0x22')]],'as':_0x137f9b['as'],'attributes':_0x137f9b[_0x4ba3('0x1e')],'include':_0x137f9b[_0x4ba3('0x20')]?_[_0x4ba3('0x21')](_0x137f9b[_0x4ba3('0x20')],function(_0x3439cb){return{'model':db[_0x3439cb['model']],'as':_0x3439cb['as'],'attributes':_0x3439cb[_0x4ba3('0x1e')],'include':_0x3439cb[_0x4ba3('0x20')]?_[_0x4ba3('0x21')](_0x3439cb['include'],function(_0x188f8c){return{'model':db[_0x188f8c['model']],'as':_0x188f8c['as'],'attributes':_0x188f8c[_0x4ba3('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x4ba3('0xc')](function(_0x426e11){logger[_0x4ba3('0xd')](_0x4ba3('0x23'),_0x2cb5d5);logger[_0x4ba3('0x10')]('ShowFreshsalesAccount',_0x2cb5d5,JSON[_0x4ba3('0x12')](_0x426e11));_0x48b3b7(_0x426e11);})[_0x4ba3('0x17')](function(_0x2e77d4){logger['error'](_0x4ba3('0x23'),_0x2e77d4[_0x4ba3('0x15')],_0x2cb5d5);_0x27444b(_0x11f88f['error'](0x1f4,_0x2e77d4[_0x4ba3('0x15')]));});});};