Built motion from commit (unavailable).|2.5.19
[motion2.git] / server / api / intFreshdeskAccount / intFreshdeskAccount.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 _0x2eca=['FreshdeskAccount,\x20%s,\x20%s','request\x20sent','error','message','result','catch','GetFreshdeskAccount','FreshdeskAccount','findAll','options','raw','where','limit','include','map','model','attributes','stringify','ShowFreshdeskAccount','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','client','http','request','then','info'];(function(_0x5f09c5,_0x2bfca0){var _0x426ad9=function(_0x18fe5f){while(--_0x18fe5f){_0x5f09c5['push'](_0x5f09c5['shift']());}};_0x426ad9(++_0x2bfca0);}(_0x2eca,0x1c0));var _0xa2ec=function(_0x504df1,_0x289598){_0x504df1=_0x504df1-0x0;var _0x1063b5=_0x2eca[_0x504df1];return _0x1063b5;};'use strict';var _=require(_0xa2ec('0x0'));var util=require(_0xa2ec('0x1'));var moment=require('moment');var BPromise=require(_0xa2ec('0x2'));var rs=require(_0xa2ec('0x3'));var fs=require('fs');var Redis=require(_0xa2ec('0x4'));var db=require(_0xa2ec('0x5'))['db'];var utils=require(_0xa2ec('0x6'));var logger=require(_0xa2ec('0x7'))('rpc');var config=require('../../config/environment');var jayson=require(_0xa2ec('0x8'));var client=jayson[_0xa2ec('0x9')][_0xa2ec('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x65fe78,_0x5a0f5d,_0x48be0f){return new BPromise(function(_0x5bf389,_0x253bf0){return client[_0xa2ec('0xb')](_0x65fe78,_0x48be0f)[_0xa2ec('0xc')](function(_0x22a055){logger[_0xa2ec('0xd')](_0xa2ec('0xe'),_0x5a0f5d,_0xa2ec('0xf'));logger['debug']('FreshdeskAccount,\x20%s,\x20%s,\x20%s',_0x5a0f5d,_0xa2ec('0xf'),JSON['stringify'](_0x22a055));if(_0x22a055[_0xa2ec('0x10')]){if(_0x22a055['error']['code']===0x1f4){logger[_0xa2ec('0x10')]('FreshdeskAccount,\x20%s,\x20%s',_0x5a0f5d,_0x22a055['error'][_0xa2ec('0x11')]);return _0x253bf0(_0x22a055['error']['message']);}logger['error'](_0xa2ec('0xe'),_0x5a0f5d,_0x22a055[_0xa2ec('0x10')][_0xa2ec('0x11')]);return _0x5bf389(_0x22a055[_0xa2ec('0x10')]['message']);}else{logger[_0xa2ec('0xd')]('FreshdeskAccount,\x20%s,\x20%s',_0x5a0f5d,_0xa2ec('0xf'));_0x5bf389(_0x22a055[_0xa2ec('0x12')]['message']);}})[_0xa2ec('0x13')](function(_0x296b7e){logger[_0xa2ec('0x10')](_0xa2ec('0xe'),_0x5a0f5d,_0x296b7e);_0x253bf0(_0x296b7e);});});}exports[_0xa2ec('0x14')]=function(_0x2e4b88){var _0x581f2f=this;return new Promise(function(_0x500e7a,_0x3399a3){return db[_0xa2ec('0x15')][_0xa2ec('0x16')]({'raw':_0x2e4b88[_0xa2ec('0x17')]?_0x2e4b88['options'][_0xa2ec('0x18')]===undefined?!![]:![]:!![],'where':_0x2e4b88[_0xa2ec('0x17')]?_0x2e4b88['options'][_0xa2ec('0x19')]||null:null,'attributes':_0x2e4b88[_0xa2ec('0x17')]?_0x2e4b88[_0xa2ec('0x17')]['attributes']||null:null,'limit':_0x2e4b88[_0xa2ec('0x17')]?_0x2e4b88[_0xa2ec('0x17')][_0xa2ec('0x1a')]||null:null,'include':_0x2e4b88['options']?_0x2e4b88[_0xa2ec('0x17')][_0xa2ec('0x1b')]?_[_0xa2ec('0x1c')](_0x2e4b88['options'][_0xa2ec('0x1b')],function(_0x2f0f7a){return{'model':db[_0x2f0f7a[_0xa2ec('0x1d')]],'as':_0x2f0f7a['as'],'attributes':_0x2f0f7a[_0xa2ec('0x1e')],'include':_0x2f0f7a[_0xa2ec('0x1b')]?_[_0xa2ec('0x1c')](_0x2f0f7a['include'],function(_0x16e7c9){return{'model':db[_0x16e7c9[_0xa2ec('0x1d')]],'as':_0x16e7c9['as'],'attributes':_0x16e7c9[_0xa2ec('0x1e')],'include':_0x16e7c9[_0xa2ec('0x1b')]?_[_0xa2ec('0x1c')](_0x16e7c9[_0xa2ec('0x1b')],function(_0xcadf5){return{'model':db[_0xcadf5[_0xa2ec('0x1d')]],'as':_0xcadf5['as'],'attributes':_0xcadf5[_0xa2ec('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xa2ec('0xc')](function(_0x454c64){logger[_0xa2ec('0xd')](_0xa2ec('0x14'),_0x2e4b88);logger['debug'](_0xa2ec('0x14'),_0x2e4b88,JSON[_0xa2ec('0x1f')](_0x454c64));_0x500e7a(_0x454c64);})[_0xa2ec('0x13')](function(_0x28ab65){logger[_0xa2ec('0x10')](_0xa2ec('0x14'),_0x28ab65['message'],_0x2e4b88);_0x3399a3(_0x581f2f['error'](0x1f4,_0x28ab65[_0xa2ec('0x11')]));});});};exports[_0xa2ec('0x20')]=function(_0x560b6d){var _0xf0075c=this;return new Promise(function(_0x2525ff,_0x36d94a){return db[_0xa2ec('0x15')]['find']({'raw':_0x560b6d['options']?_0x560b6d[_0xa2ec('0x17')][_0xa2ec('0x18')]===undefined?!![]:![]:!![],'where':_0x560b6d[_0xa2ec('0x17')]?_0x560b6d['options']['where']||null:null,'attributes':_0x560b6d[_0xa2ec('0x17')]?_0x560b6d[_0xa2ec('0x17')]['attributes']||null:null,'include':_0x560b6d['options']?_0x560b6d[_0xa2ec('0x17')]['include']?_[_0xa2ec('0x1c')](_0x560b6d['options'][_0xa2ec('0x1b')],function(_0x8a4bad){return{'model':db[_0x8a4bad['model']],'as':_0x8a4bad['as'],'attributes':_0x8a4bad['attributes'],'include':_0x8a4bad[_0xa2ec('0x1b')]?_[_0xa2ec('0x1c')](_0x8a4bad['include'],function(_0x8eeedc){return{'model':db[_0x8eeedc['model']],'as':_0x8eeedc['as'],'attributes':_0x8eeedc[_0xa2ec('0x1e')],'include':_0x8eeedc[_0xa2ec('0x1b')]?_[_0xa2ec('0x1c')](_0x8eeedc[_0xa2ec('0x1b')],function(_0x359a3a){return{'model':db[_0x359a3a['model']],'as':_0x359a3a['as'],'attributes':_0x359a3a[_0xa2ec('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1682bd){logger[_0xa2ec('0xd')](_0xa2ec('0x20'),_0x560b6d);logger['debug'](_0xa2ec('0x20'),_0x560b6d,JSON[_0xa2ec('0x1f')](_0x1682bd));_0x2525ff(_0x1682bd);})[_0xa2ec('0x13')](function(_0x29de26){logger['error'](_0xa2ec('0x20'),_0x29de26['message'],_0x560b6d);_0x36d94a(_0xf0075c[_0xa2ec('0x10')](0x1f4,_0x29de26[_0xa2ec('0x11')]));});});};