Built motion from commit bab6f49e.|2.6.17
[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 _0x7b4a=['limit','map','include','model','debug','catch','ShowFreshdeskAccount','FreshdeskAccount','raw','lodash','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','then','info','FreshdeskAccount,\x20%s,\x20%s','request\x20sent','FreshdeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','GetFreshdeskAccount','findAll','options','where','attributes'];(function(_0x596894,_0xc196df){var _0x298f45=function(_0xed42ed){while(--_0xed42ed){_0x596894['push'](_0x596894['shift']());}};_0x298f45(++_0xc196df);}(_0x7b4a,0x119));var _0xa7b4=function(_0x311f34,_0xf0697f){_0x311f34=_0x311f34-0x0;var _0xcc2d4e=_0x7b4a[_0x311f34];return _0xcc2d4e;};'use strict';var _=require(_0xa7b4('0x0'));var util=require('util');var moment=require(_0xa7b4('0x1'));var BPromise=require('bluebird');var rs=require(_0xa7b4('0x2'));var fs=require('fs');var Redis=require(_0xa7b4('0x3'));var db=require(_0xa7b4('0x4'))['db'];var utils=require(_0xa7b4('0x5'));var logger=require(_0xa7b4('0x6'))(_0xa7b4('0x7'));var config=require(_0xa7b4('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xa7b4('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x1cd1e9,_0x3d5cd7,_0x42af0c){return new BPromise(function(_0xdf64c7,_0x39b77f){return client['request'](_0x1cd1e9,_0x42af0c)[_0xa7b4('0xa')](function(_0x351b9f){logger[_0xa7b4('0xb')](_0xa7b4('0xc'),_0x3d5cd7,_0xa7b4('0xd'));logger['debug'](_0xa7b4('0xe'),_0x3d5cd7,_0xa7b4('0xd'),JSON[_0xa7b4('0xf')](_0x351b9f));if(_0x351b9f[_0xa7b4('0x10')]){if(_0x351b9f[_0xa7b4('0x10')][_0xa7b4('0x11')]===0x1f4){logger[_0xa7b4('0x10')](_0xa7b4('0xc'),_0x3d5cd7,_0x351b9f[_0xa7b4('0x10')]['message']);return _0x39b77f(_0x351b9f[_0xa7b4('0x10')][_0xa7b4('0x12')]);}logger[_0xa7b4('0x10')]('FreshdeskAccount,\x20%s,\x20%s',_0x3d5cd7,_0x351b9f[_0xa7b4('0x10')]['message']);return _0xdf64c7(_0x351b9f['error'][_0xa7b4('0x12')]);}else{logger['info'](_0xa7b4('0xc'),_0x3d5cd7,_0xa7b4('0xd'));_0xdf64c7(_0x351b9f[_0xa7b4('0x13')][_0xa7b4('0x12')]);}})['catch'](function(_0xdbbe43){logger[_0xa7b4('0x10')](_0xa7b4('0xc'),_0x3d5cd7,_0xdbbe43);_0x39b77f(_0xdbbe43);});});}exports[_0xa7b4('0x14')]=function(_0x576dca){var _0x75b69=this;return new Promise(function(_0x4342fe,_0x49ea8c){return db['FreshdeskAccount'][_0xa7b4('0x15')]({'raw':_0x576dca[_0xa7b4('0x16')]?_0x576dca['options']['raw']===undefined?!![]:![]:!![],'where':_0x576dca['options']?_0x576dca['options'][_0xa7b4('0x17')]||null:null,'attributes':_0x576dca['options']?_0x576dca['options'][_0xa7b4('0x18')]||null:null,'limit':_0x576dca[_0xa7b4('0x16')]?_0x576dca[_0xa7b4('0x16')][_0xa7b4('0x19')]||null:null,'include':_0x576dca[_0xa7b4('0x16')]?_0x576dca[_0xa7b4('0x16')]['include']?_[_0xa7b4('0x1a')](_0x576dca[_0xa7b4('0x16')][_0xa7b4('0x1b')],function(_0x31a218){return{'model':db[_0x31a218[_0xa7b4('0x1c')]],'as':_0x31a218['as'],'attributes':_0x31a218[_0xa7b4('0x18')],'include':_0x31a218['include']?_['map'](_0x31a218[_0xa7b4('0x1b')],function(_0x50753c){return{'model':db[_0x50753c[_0xa7b4('0x1c')]],'as':_0x50753c['as'],'attributes':_0x50753c[_0xa7b4('0x18')],'include':_0x50753c['include']?_[_0xa7b4('0x1a')](_0x50753c['include'],function(_0x38a895){return{'model':db[_0x38a895[_0xa7b4('0x1c')]],'as':_0x38a895['as'],'attributes':_0x38a895[_0xa7b4('0x18')]};}):[]};}):[]};}):[]:[]})[_0xa7b4('0xa')](function(_0x58b669){logger[_0xa7b4('0xb')]('GetFreshdeskAccount',_0x576dca);logger[_0xa7b4('0x1d')](_0xa7b4('0x14'),_0x576dca,JSON['stringify'](_0x58b669));_0x4342fe(_0x58b669);})[_0xa7b4('0x1e')](function(_0x5166c9){logger['error'](_0xa7b4('0x14'),_0x5166c9[_0xa7b4('0x12')],_0x576dca);_0x49ea8c(_0x75b69[_0xa7b4('0x10')](0x1f4,_0x5166c9[_0xa7b4('0x12')]));});});};exports[_0xa7b4('0x1f')]=function(_0x468740){var _0x2e618b=this;return new Promise(function(_0x573c84,_0x110591){return db[_0xa7b4('0x20')]['find']({'raw':_0x468740[_0xa7b4('0x16')]?_0x468740['options'][_0xa7b4('0x21')]===undefined?!![]:![]:!![],'where':_0x468740[_0xa7b4('0x16')]?_0x468740[_0xa7b4('0x16')][_0xa7b4('0x17')]||null:null,'attributes':_0x468740['options']?_0x468740[_0xa7b4('0x16')][_0xa7b4('0x18')]||null:null,'include':_0x468740[_0xa7b4('0x16')]?_0x468740[_0xa7b4('0x16')][_0xa7b4('0x1b')]?_['map'](_0x468740['options'][_0xa7b4('0x1b')],function(_0x2d015d){return{'model':db[_0x2d015d[_0xa7b4('0x1c')]],'as':_0x2d015d['as'],'attributes':_0x2d015d[_0xa7b4('0x18')],'include':_0x2d015d[_0xa7b4('0x1b')]?_['map'](_0x2d015d[_0xa7b4('0x1b')],function(_0x5e1a48){return{'model':db[_0x5e1a48[_0xa7b4('0x1c')]],'as':_0x5e1a48['as'],'attributes':_0x5e1a48['attributes'],'include':_0x5e1a48[_0xa7b4('0x1b')]?_['map'](_0x5e1a48[_0xa7b4('0x1b')],function(_0x33815f){return{'model':db[_0x33815f[_0xa7b4('0x1c')]],'as':_0x33815f['as'],'attributes':_0x33815f[_0xa7b4('0x18')]};}):[]};}):[]};}):[]:[]})[_0xa7b4('0xa')](function(_0x54aaf5){logger[_0xa7b4('0xb')](_0xa7b4('0x1f'),_0x468740);logger[_0xa7b4('0x1d')](_0xa7b4('0x1f'),_0x468740,JSON[_0xa7b4('0xf')](_0x54aaf5));_0x573c84(_0x54aaf5);})[_0xa7b4('0x1e')](function(_0x5e279b){logger[_0xa7b4('0x10')](_0xa7b4('0x1f'),_0x5e279b[_0xa7b4('0x12')],_0x468740);_0x110591(_0x2e618b[_0xa7b4('0x10')](0x1f4,_0x5e279b[_0xa7b4('0x12')]));});});};