Built motion from commit d5e4af8c.|2.6.23
[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 _0xa1fb=['options','raw','where','limit','include','map','model','attributes','ShowFreshdeskAccount','util','moment','bluebird','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','then','info','request\x20sent','debug','FreshdeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','FreshdeskAccount,\x20%s,\x20%s','message','result','catch','GetFreshdeskAccount','FreshdeskAccount'];(function(_0x357979,_0x56feef){var _0xabb42f=function(_0x447f9d){while(--_0x447f9d){_0x357979['push'](_0x357979['shift']());}};_0xabb42f(++_0x56feef);}(_0xa1fb,0x1c9));var _0xba1f=function(_0x35da42,_0x5c2610){_0x35da42=_0x35da42-0x0;var _0x370035=_0xa1fb[_0x35da42];return _0x370035;};'use strict';var _=require('lodash');var util=require(_0xba1f('0x0'));var moment=require(_0xba1f('0x1'));var BPromise=require(_0xba1f('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xba1f('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0xba1f('0x4'));var logger=require(_0xba1f('0x5'))(_0xba1f('0x6'));var config=require(_0xba1f('0x7'));var jayson=require(_0xba1f('0x8'));var client=jayson['client'][_0xba1f('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x31d4d4,_0x365af2,_0x13749d){return new BPromise(function(_0x44a462,_0x62c9e8){return client['request'](_0x31d4d4,_0x13749d)[_0xba1f('0xa')](function(_0x4c44a7){logger[_0xba1f('0xb')]('FreshdeskAccount,\x20%s,\x20%s',_0x365af2,_0xba1f('0xc'));logger[_0xba1f('0xd')](_0xba1f('0xe'),_0x365af2,_0xba1f('0xc'),JSON[_0xba1f('0xf')](_0x4c44a7));if(_0x4c44a7['error']){if(_0x4c44a7[_0xba1f('0x10')]['code']===0x1f4){logger['error'](_0xba1f('0x11'),_0x365af2,_0x4c44a7[_0xba1f('0x10')][_0xba1f('0x12')]);return _0x62c9e8(_0x4c44a7['error'][_0xba1f('0x12')]);}logger[_0xba1f('0x10')](_0xba1f('0x11'),_0x365af2,_0x4c44a7['error'][_0xba1f('0x12')]);return _0x44a462(_0x4c44a7[_0xba1f('0x10')][_0xba1f('0x12')]);}else{logger['info'](_0xba1f('0x11'),_0x365af2,_0xba1f('0xc'));_0x44a462(_0x4c44a7[_0xba1f('0x13')][_0xba1f('0x12')]);}})[_0xba1f('0x14')](function(_0x25e152){logger[_0xba1f('0x10')](_0xba1f('0x11'),_0x365af2,_0x25e152);_0x62c9e8(_0x25e152);});});}exports[_0xba1f('0x15')]=function(_0x55aeba){var _0x41e81a=this;return new Promise(function(_0x295a24,_0xfeffe){return db[_0xba1f('0x16')]['findAll']({'raw':_0x55aeba[_0xba1f('0x17')]?_0x55aeba[_0xba1f('0x17')][_0xba1f('0x18')]===undefined?!![]:![]:!![],'where':_0x55aeba['options']?_0x55aeba[_0xba1f('0x17')][_0xba1f('0x19')]||null:null,'attributes':_0x55aeba['options']?_0x55aeba[_0xba1f('0x17')]['attributes']||null:null,'limit':_0x55aeba[_0xba1f('0x17')]?_0x55aeba[_0xba1f('0x17')][_0xba1f('0x1a')]||null:null,'include':_0x55aeba[_0xba1f('0x17')]?_0x55aeba[_0xba1f('0x17')][_0xba1f('0x1b')]?_[_0xba1f('0x1c')](_0x55aeba[_0xba1f('0x17')][_0xba1f('0x1b')],function(_0x179a18){return{'model':db[_0x179a18[_0xba1f('0x1d')]],'as':_0x179a18['as'],'attributes':_0x179a18[_0xba1f('0x1e')],'include':_0x179a18[_0xba1f('0x1b')]?_[_0xba1f('0x1c')](_0x179a18[_0xba1f('0x1b')],function(_0x22b038){return{'model':db[_0x22b038['model']],'as':_0x22b038['as'],'attributes':_0x22b038[_0xba1f('0x1e')],'include':_0x22b038[_0xba1f('0x1b')]?_[_0xba1f('0x1c')](_0x22b038[_0xba1f('0x1b')],function(_0x524073){return{'model':db[_0x524073[_0xba1f('0x1d')]],'as':_0x524073['as'],'attributes':_0x524073[_0xba1f('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xba1f('0xa')](function(_0x17d02e){logger[_0xba1f('0xb')]('GetFreshdeskAccount',_0x55aeba);logger[_0xba1f('0xd')](_0xba1f('0x15'),_0x55aeba,JSON[_0xba1f('0xf')](_0x17d02e));_0x295a24(_0x17d02e);})[_0xba1f('0x14')](function(_0x485805){logger[_0xba1f('0x10')](_0xba1f('0x15'),_0x485805[_0xba1f('0x12')],_0x55aeba);_0xfeffe(_0x41e81a[_0xba1f('0x10')](0x1f4,_0x485805[_0xba1f('0x12')]));});});};exports['ShowFreshdeskAccount']=function(_0x405ea0){var _0x56866b=this;return new Promise(function(_0x497c95,_0xde539e){return db[_0xba1f('0x16')]['find']({'raw':_0x405ea0['options']?_0x405ea0[_0xba1f('0x17')][_0xba1f('0x18')]===undefined?!![]:![]:!![],'where':_0x405ea0['options']?_0x405ea0[_0xba1f('0x17')][_0xba1f('0x19')]||null:null,'attributes':_0x405ea0[_0xba1f('0x17')]?_0x405ea0[_0xba1f('0x17')][_0xba1f('0x1e')]||null:null,'include':_0x405ea0['options']?_0x405ea0['options'][_0xba1f('0x1b')]?_[_0xba1f('0x1c')](_0x405ea0[_0xba1f('0x17')]['include'],function(_0x363279){return{'model':db[_0x363279[_0xba1f('0x1d')]],'as':_0x363279['as'],'attributes':_0x363279['attributes'],'include':_0x363279[_0xba1f('0x1b')]?_[_0xba1f('0x1c')](_0x363279[_0xba1f('0x1b')],function(_0x1bfe99){return{'model':db[_0x1bfe99['model']],'as':_0x1bfe99['as'],'attributes':_0x1bfe99[_0xba1f('0x1e')],'include':_0x1bfe99[_0xba1f('0x1b')]?_[_0xba1f('0x1c')](_0x1bfe99[_0xba1f('0x1b')],function(_0x55b692){return{'model':db[_0x55b692[_0xba1f('0x1d')]],'as':_0x55b692['as'],'attributes':_0x55b692[_0xba1f('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x527b79){logger[_0xba1f('0xb')](_0xba1f('0x1f'),_0x405ea0);logger[_0xba1f('0xd')](_0xba1f('0x1f'),_0x405ea0,JSON[_0xba1f('0xf')](_0x527b79));_0x497c95(_0x527b79);})[_0xba1f('0x14')](function(_0x22787f){logger[_0xba1f('0x10')](_0xba1f('0x1f'),_0x22787f[_0xba1f('0x12')],_0x405ea0);_0xde539e(_0x56866b[_0xba1f('0x10')](0x1f4,_0x22787f['message']));});});};