Built motion from commit (unavailable).|2.4.4
[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 _0x340f=['then','info','FreshdeskAccount,\x20%s,\x20%s','request\x20sent','debug','FreshdeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','GetFreshdeskAccount','FreshdeskAccount','findAll','options','raw','where','attributes','limit','include','model','map','ShowFreshdeskAccount','lodash','util','moment','bluebird','ioredis','../../mysqldb','rpc','jayson/promise','client','http'];(function(_0x233694,_0x1adcbe){var _0x1a511f=function(_0xdf785){while(--_0xdf785){_0x233694['push'](_0x233694['shift']());}};_0x1a511f(++_0x1adcbe);}(_0x340f,0x7a));var _0xf340=function(_0x27595f,_0x4afd27){_0x27595f=_0x27595f-0x0;var _0x4ec706=_0x340f[_0x27595f];return _0x4ec706;};'use strict';var _=require(_0xf340('0x0'));var util=require(_0xf340('0x1'));var moment=require(_0xf340('0x2'));var BPromise=require(_0xf340('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xf340('0x4'));var db=require(_0xf340('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xf340('0x6'));var config=require('../../config/environment');var jayson=require(_0xf340('0x7'));var client=jayson[_0xf340('0x8')][_0xf340('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x19500b,_0x433264,_0x28471d){return new BPromise(function(_0x3e2475,_0x5c7a92){return client['request'](_0x19500b,_0x28471d)[_0xf340('0xa')](function(_0x49dc4e){logger[_0xf340('0xb')](_0xf340('0xc'),_0x433264,_0xf340('0xd'));logger[_0xf340('0xe')](_0xf340('0xf'),_0x433264,_0xf340('0xd'),JSON[_0xf340('0x10')](_0x49dc4e));if(_0x49dc4e[_0xf340('0x11')]){if(_0x49dc4e[_0xf340('0x11')][_0xf340('0x12')]===0x1f4){logger['error'](_0xf340('0xc'),_0x433264,_0x49dc4e[_0xf340('0x11')][_0xf340('0x13')]);return _0x5c7a92(_0x49dc4e[_0xf340('0x11')][_0xf340('0x13')]);}logger['error'](_0xf340('0xc'),_0x433264,_0x49dc4e[_0xf340('0x11')][_0xf340('0x13')]);return _0x3e2475(_0x49dc4e[_0xf340('0x11')][_0xf340('0x13')]);}else{logger[_0xf340('0xb')](_0xf340('0xc'),_0x433264,_0xf340('0xd'));_0x3e2475(_0x49dc4e['result']['message']);}})[_0xf340('0x14')](function(_0x13f28d){logger[_0xf340('0x11')]('FreshdeskAccount,\x20%s,\x20%s',_0x433264,_0x13f28d);_0x5c7a92(_0x13f28d);});});}exports[_0xf340('0x15')]=function(_0xe18f00){var _0x58fa16=this;return new Promise(function(_0x3e3ece,_0x147f64){return db[_0xf340('0x16')][_0xf340('0x17')]({'raw':_0xe18f00[_0xf340('0x18')]?_0xe18f00[_0xf340('0x18')][_0xf340('0x19')]===undefined?!![]:![]:!![],'where':_0xe18f00[_0xf340('0x18')]?_0xe18f00['options'][_0xf340('0x1a')]||null:null,'attributes':_0xe18f00[_0xf340('0x18')]?_0xe18f00[_0xf340('0x18')][_0xf340('0x1b')]||null:null,'limit':_0xe18f00[_0xf340('0x18')]?_0xe18f00['options'][_0xf340('0x1c')]||null:null,'include':_0xe18f00[_0xf340('0x18')]?_0xe18f00['options']['include']?_['map'](_0xe18f00['options'][_0xf340('0x1d')],function(_0x27edc4){return{'model':db[_0x27edc4[_0xf340('0x1e')]],'as':_0x27edc4['as'],'attributes':_0x27edc4['attributes'],'include':_0x27edc4[_0xf340('0x1d')]?_['map'](_0x27edc4[_0xf340('0x1d')],function(_0x36465c){return{'model':db[_0x36465c[_0xf340('0x1e')]],'as':_0x36465c['as'],'attributes':_0x36465c[_0xf340('0x1b')],'include':_0x36465c[_0xf340('0x1d')]?_[_0xf340('0x1f')](_0x36465c['include'],function(_0x176a33){return{'model':db[_0x176a33[_0xf340('0x1e')]],'as':_0x176a33['as'],'attributes':_0x176a33[_0xf340('0x1b')]};}):[]};}):[]};}):[]:[]})[_0xf340('0xa')](function(_0x400d90){logger['info'](_0xf340('0x15'),_0xe18f00);logger[_0xf340('0xe')](_0xf340('0x15'),_0xe18f00,JSON['stringify'](_0x400d90));_0x3e3ece(_0x400d90);})[_0xf340('0x14')](function(_0x4c1c66){logger[_0xf340('0x11')](_0xf340('0x15'),_0x4c1c66[_0xf340('0x13')],_0xe18f00);_0x147f64(_0x58fa16['error'](0x1f4,_0x4c1c66[_0xf340('0x13')]));});});};exports[_0xf340('0x20')]=function(_0x15f1dd){var _0x5a8682=this;return new Promise(function(_0xa79825,_0x42249e){return db['FreshdeskAccount']['find']({'raw':_0x15f1dd['options']?_0x15f1dd[_0xf340('0x18')][_0xf340('0x19')]===undefined?!![]:![]:!![],'where':_0x15f1dd[_0xf340('0x18')]?_0x15f1dd[_0xf340('0x18')][_0xf340('0x1a')]||null:null,'attributes':_0x15f1dd[_0xf340('0x18')]?_0x15f1dd[_0xf340('0x18')]['attributes']||null:null,'include':_0x15f1dd['options']?_0x15f1dd[_0xf340('0x18')][_0xf340('0x1d')]?_[_0xf340('0x1f')](_0x15f1dd[_0xf340('0x18')][_0xf340('0x1d')],function(_0x100392){return{'model':db[_0x100392[_0xf340('0x1e')]],'as':_0x100392['as'],'attributes':_0x100392['attributes'],'include':_0x100392[_0xf340('0x1d')]?_[_0xf340('0x1f')](_0x100392['include'],function(_0x40eeb7){return{'model':db[_0x40eeb7[_0xf340('0x1e')]],'as':_0x40eeb7['as'],'attributes':_0x40eeb7[_0xf340('0x1b')],'include':_0x40eeb7[_0xf340('0x1d')]?_[_0xf340('0x1f')](_0x40eeb7[_0xf340('0x1d')],function(_0x1ff0d0){return{'model':db[_0x1ff0d0[_0xf340('0x1e')]],'as':_0x1ff0d0['as'],'attributes':_0x1ff0d0[_0xf340('0x1b')]};}):[]};}):[]};}):[]:[]})[_0xf340('0xa')](function(_0x4bc7f9){logger[_0xf340('0xb')](_0xf340('0x20'),_0x15f1dd);logger[_0xf340('0xe')](_0xf340('0x20'),_0x15f1dd,JSON['stringify'](_0x4bc7f9));_0xa79825(_0x4bc7f9);})[_0xf340('0x14')](function(_0x306179){logger[_0xf340('0x11')](_0xf340('0x20'),_0x306179[_0xf340('0x13')],_0x15f1dd);_0x42249e(_0x5a8682[_0xf340('0x11')](0x1f4,_0x306179[_0xf340('0x13')]));});});};