d668f6d1eea5a8d8ad217cca7a7035b043c2bb2b
[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 _0x5430=['map','model','find','ShowFreshsalesAccount','lodash','util','moment','bluebird','randomstring','ioredis','../../config/logger','jayson/promise','client','http','request','then','info','request\x20sent','debug','stringify','error','code','FreshsalesAccount,\x20%s,\x20%s','message','result','GetFreshsalesAccount','FreshsalesAccount','options','raw','where','attributes','limit','include'];(function(_0x122e84,_0x29feba){var _0x5cb947=function(_0x4b20f4){while(--_0x4b20f4){_0x122e84['push'](_0x122e84['shift']());}};_0x5cb947(++_0x29feba);}(_0x5430,0x10c));var _0x0543=function(_0x29d7f3,_0xc5928a){_0x29d7f3=_0x29d7f3-0x0;var _0x1d7631=_0x5430[_0x29d7f3];return _0x1d7631;};'use strict';var _=require(_0x0543('0x0'));var util=require(_0x0543('0x1'));var moment=require(_0x0543('0x2'));var BPromise=require(_0x0543('0x3'));var rs=require(_0x0543('0x4'));var fs=require('fs');var Redis=require(_0x0543('0x5'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x0543('0x6'))('rpc');var config=require('../../config/environment');var jayson=require(_0x0543('0x7'));var client=jayson[_0x0543('0x8')][_0x0543('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x319568,_0x46bca7,_0x5ac352){return new BPromise(function(_0x372974,_0x7b8280){return client[_0x0543('0xa')](_0x319568,_0x5ac352)[_0x0543('0xb')](function(_0x2fb723){logger[_0x0543('0xc')]('FreshsalesAccount,\x20%s,\x20%s',_0x46bca7,_0x0543('0xd'));logger[_0x0543('0xe')]('FreshsalesAccount,\x20%s,\x20%s,\x20%s',_0x46bca7,_0x0543('0xd'),JSON[_0x0543('0xf')](_0x2fb723));if(_0x2fb723[_0x0543('0x10')]){if(_0x2fb723[_0x0543('0x10')][_0x0543('0x11')]===0x1f4){logger[_0x0543('0x10')](_0x0543('0x12'),_0x46bca7,_0x2fb723[_0x0543('0x10')][_0x0543('0x13')]);return _0x7b8280(_0x2fb723[_0x0543('0x10')][_0x0543('0x13')]);}logger[_0x0543('0x10')]('FreshsalesAccount,\x20%s,\x20%s',_0x46bca7,_0x2fb723[_0x0543('0x10')][_0x0543('0x13')]);return _0x372974(_0x2fb723['error']['message']);}else{logger[_0x0543('0xc')](_0x0543('0x12'),_0x46bca7,_0x0543('0xd'));_0x372974(_0x2fb723[_0x0543('0x14')][_0x0543('0x13')]);}})['catch'](function(_0xe69a3d){logger[_0x0543('0x10')](_0x0543('0x12'),_0x46bca7,_0xe69a3d);_0x7b8280(_0xe69a3d);});});}exports[_0x0543('0x15')]=function(_0x20b396){var _0x285080=this;return new Promise(function(_0x577cf0,_0x5eb03e){return db[_0x0543('0x16')]['findAll']({'raw':_0x20b396['options']?_0x20b396[_0x0543('0x17')][_0x0543('0x18')]===undefined?!![]:![]:!![],'where':_0x20b396[_0x0543('0x17')]?_0x20b396['options'][_0x0543('0x19')]||null:null,'attributes':_0x20b396['options']?_0x20b396[_0x0543('0x17')][_0x0543('0x1a')]||null:null,'limit':_0x20b396['options']?_0x20b396[_0x0543('0x17')][_0x0543('0x1b')]||null:null,'include':_0x20b396[_0x0543('0x17')]?_0x20b396[_0x0543('0x17')][_0x0543('0x1c')]?_[_0x0543('0x1d')](_0x20b396['options']['include'],function(_0x59f1b2){return{'model':db[_0x59f1b2[_0x0543('0x1e')]],'as':_0x59f1b2['as'],'attributes':_0x59f1b2[_0x0543('0x1a')],'include':_0x59f1b2[_0x0543('0x1c')]?_[_0x0543('0x1d')](_0x59f1b2[_0x0543('0x1c')],function(_0x26e500){return{'model':db[_0x26e500[_0x0543('0x1e')]],'as':_0x26e500['as'],'attributes':_0x26e500[_0x0543('0x1a')],'include':_0x26e500[_0x0543('0x1c')]?_[_0x0543('0x1d')](_0x26e500[_0x0543('0x1c')],function(_0x21fc63){return{'model':db[_0x21fc63['model']],'as':_0x21fc63['as'],'attributes':_0x21fc63[_0x0543('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x0543('0xb')](function(_0x30ad9e){logger['info'](_0x0543('0x15'),_0x20b396);logger[_0x0543('0xe')](_0x0543('0x15'),_0x20b396,JSON[_0x0543('0xf')](_0x30ad9e));_0x577cf0(_0x30ad9e);})['catch'](function(_0x1732be){logger[_0x0543('0x10')]('GetFreshsalesAccount',_0x1732be['message'],_0x20b396);_0x5eb03e(_0x285080[_0x0543('0x10')](0x1f4,_0x1732be[_0x0543('0x13')]));});});};exports['ShowFreshsalesAccount']=function(_0x3b879b){var _0x2e03d1=this;return new Promise(function(_0x931ccc,_0x2bd6ce){return db[_0x0543('0x16')][_0x0543('0x1f')]({'raw':_0x3b879b[_0x0543('0x17')]?_0x3b879b['options'][_0x0543('0x18')]===undefined?!![]:![]:!![],'where':_0x3b879b['options']?_0x3b879b[_0x0543('0x17')][_0x0543('0x19')]||null:null,'attributes':_0x3b879b[_0x0543('0x17')]?_0x3b879b[_0x0543('0x17')][_0x0543('0x1a')]||null:null,'include':_0x3b879b['options']?_0x3b879b[_0x0543('0x17')]['include']?_[_0x0543('0x1d')](_0x3b879b[_0x0543('0x17')][_0x0543('0x1c')],function(_0x327027){return{'model':db[_0x327027['model']],'as':_0x327027['as'],'attributes':_0x327027[_0x0543('0x1a')],'include':_0x327027['include']?_[_0x0543('0x1d')](_0x327027[_0x0543('0x1c')],function(_0x3fbf5f){return{'model':db[_0x3fbf5f[_0x0543('0x1e')]],'as':_0x3fbf5f['as'],'attributes':_0x3fbf5f[_0x0543('0x1a')],'include':_0x3fbf5f[_0x0543('0x1c')]?_[_0x0543('0x1d')](_0x3fbf5f[_0x0543('0x1c')],function(_0x8ef4d4){return{'model':db[_0x8ef4d4[_0x0543('0x1e')]],'as':_0x8ef4d4['as'],'attributes':_0x8ef4d4['attributes']};}):[]};}):[]};}):[]:[]})[_0x0543('0xb')](function(_0x2d76d6){logger['info'](_0x0543('0x20'),_0x3b879b);logger['debug'](_0x0543('0x20'),_0x3b879b,JSON[_0x0543('0xf')](_0x2d76d6));_0x931ccc(_0x2d76d6);})['catch'](function(_0x5e8800){logger[_0x0543('0x10')](_0x0543('0x20'),_0x5e8800['message'],_0x3b879b);_0x2bd6ce(_0x2e03d1[_0x0543('0x10')](0x1f4,_0x5e8800[_0x0543('0x13')]));});});};