Built motion from commit 52c8a02d.|2.6.29
[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 _0xab26=['stringify','code','error','message','GetFreshdeskAccount','findAll','options','raw','where','attributes','limit','include','map','model','then','debug','FreshdeskAccount','find','ShowFreshdeskAccount','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','info','FreshdeskAccount,\x20%s,\x20%s','request\x20sent','FreshdeskAccount,\x20%s,\x20%s,\x20%s'];(function(_0x3c60fc,_0x593ef5){var _0x495fd2=function(_0x33e7ea){while(--_0x33e7ea){_0x3c60fc['push'](_0x3c60fc['shift']());}};_0x495fd2(++_0x593ef5);}(_0xab26,0x1e7));var _0x6ab2=function(_0x57b54c,_0x54ce0d){_0x57b54c=_0x57b54c-0x0;var _0x59cc19=_0xab26[_0x57b54c];return _0x59cc19;};'use strict';var _=require('lodash');var util=require(_0x6ab2('0x0'));var moment=require(_0x6ab2('0x1'));var BPromise=require(_0x6ab2('0x2'));var rs=require(_0x6ab2('0x3'));var fs=require('fs');var Redis=require(_0x6ab2('0x4'));var db=require(_0x6ab2('0x5'))['db'];var utils=require(_0x6ab2('0x6'));var logger=require(_0x6ab2('0x7'))(_0x6ab2('0x8'));var config=require('../../config/environment');var jayson=require(_0x6ab2('0x9'));var client=jayson[_0x6ab2('0xa')][_0x6ab2('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x254ff4,_0x3f4d6e,_0x1bcccd){return new BPromise(function(_0x3b9adb,_0x226919){return client[_0x6ab2('0xc')](_0x254ff4,_0x1bcccd)['then'](function(_0x2532a9){logger[_0x6ab2('0xd')](_0x6ab2('0xe'),_0x3f4d6e,_0x6ab2('0xf'));logger['debug'](_0x6ab2('0x10'),_0x3f4d6e,_0x6ab2('0xf'),JSON[_0x6ab2('0x11')](_0x2532a9));if(_0x2532a9['error']){if(_0x2532a9['error'][_0x6ab2('0x12')]===0x1f4){logger[_0x6ab2('0x13')](_0x6ab2('0xe'),_0x3f4d6e,_0x2532a9['error'][_0x6ab2('0x14')]);return _0x226919(_0x2532a9[_0x6ab2('0x13')][_0x6ab2('0x14')]);}logger[_0x6ab2('0x13')](_0x6ab2('0xe'),_0x3f4d6e,_0x2532a9[_0x6ab2('0x13')]['message']);return _0x3b9adb(_0x2532a9['error']['message']);}else{logger[_0x6ab2('0xd')](_0x6ab2('0xe'),_0x3f4d6e,_0x6ab2('0xf'));_0x3b9adb(_0x2532a9['result'][_0x6ab2('0x14')]);}})['catch'](function(_0x463ff9){logger[_0x6ab2('0x13')](_0x6ab2('0xe'),_0x3f4d6e,_0x463ff9);_0x226919(_0x463ff9);});});}exports[_0x6ab2('0x15')]=function(_0x570325){var _0x21c2f4=this;return new Promise(function(_0x38ab8c,_0x37e3eb){return db['FreshdeskAccount'][_0x6ab2('0x16')]({'raw':_0x570325['options']?_0x570325[_0x6ab2('0x17')][_0x6ab2('0x18')]===undefined?!![]:![]:!![],'where':_0x570325['options']?_0x570325[_0x6ab2('0x17')][_0x6ab2('0x19')]||null:null,'attributes':_0x570325[_0x6ab2('0x17')]?_0x570325['options'][_0x6ab2('0x1a')]||null:null,'limit':_0x570325[_0x6ab2('0x17')]?_0x570325[_0x6ab2('0x17')][_0x6ab2('0x1b')]||null:null,'include':_0x570325[_0x6ab2('0x17')]?_0x570325['options'][_0x6ab2('0x1c')]?_[_0x6ab2('0x1d')](_0x570325[_0x6ab2('0x17')][_0x6ab2('0x1c')],function(_0x151202){return{'model':db[_0x151202['model']],'as':_0x151202['as'],'attributes':_0x151202[_0x6ab2('0x1a')],'include':_0x151202[_0x6ab2('0x1c')]?_[_0x6ab2('0x1d')](_0x151202[_0x6ab2('0x1c')],function(_0x3133d5){return{'model':db[_0x3133d5[_0x6ab2('0x1e')]],'as':_0x3133d5['as'],'attributes':_0x3133d5[_0x6ab2('0x1a')],'include':_0x3133d5[_0x6ab2('0x1c')]?_['map'](_0x3133d5[_0x6ab2('0x1c')],function(_0x336d04){return{'model':db[_0x336d04[_0x6ab2('0x1e')]],'as':_0x336d04['as'],'attributes':_0x336d04[_0x6ab2('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x6ab2('0x1f')](function(_0x35a5e5){logger[_0x6ab2('0xd')](_0x6ab2('0x15'),_0x570325);logger[_0x6ab2('0x20')](_0x6ab2('0x15'),_0x570325,JSON[_0x6ab2('0x11')](_0x35a5e5));_0x38ab8c(_0x35a5e5);})['catch'](function(_0x22da3f){logger[_0x6ab2('0x13')]('GetFreshdeskAccount',_0x22da3f[_0x6ab2('0x14')],_0x570325);_0x37e3eb(_0x21c2f4[_0x6ab2('0x13')](0x1f4,_0x22da3f[_0x6ab2('0x14')]));});});};exports['ShowFreshdeskAccount']=function(_0x22aaf4){var _0x58c1bd=this;return new Promise(function(_0x59ddff,_0x20ef18){return db[_0x6ab2('0x21')][_0x6ab2('0x22')]({'raw':_0x22aaf4[_0x6ab2('0x17')]?_0x22aaf4[_0x6ab2('0x17')][_0x6ab2('0x18')]===undefined?!![]:![]:!![],'where':_0x22aaf4['options']?_0x22aaf4[_0x6ab2('0x17')][_0x6ab2('0x19')]||null:null,'attributes':_0x22aaf4['options']?_0x22aaf4[_0x6ab2('0x17')][_0x6ab2('0x1a')]||null:null,'include':_0x22aaf4[_0x6ab2('0x17')]?_0x22aaf4[_0x6ab2('0x17')][_0x6ab2('0x1c')]?_['map'](_0x22aaf4['options'][_0x6ab2('0x1c')],function(_0x34e85f){return{'model':db[_0x34e85f[_0x6ab2('0x1e')]],'as':_0x34e85f['as'],'attributes':_0x34e85f[_0x6ab2('0x1a')],'include':_0x34e85f[_0x6ab2('0x1c')]?_[_0x6ab2('0x1d')](_0x34e85f[_0x6ab2('0x1c')],function(_0x5ab347){return{'model':db[_0x5ab347[_0x6ab2('0x1e')]],'as':_0x5ab347['as'],'attributes':_0x5ab347[_0x6ab2('0x1a')],'include':_0x5ab347['include']?_[_0x6ab2('0x1d')](_0x5ab347[_0x6ab2('0x1c')],function(_0x765f6b){return{'model':db[_0x765f6b[_0x6ab2('0x1e')]],'as':_0x765f6b['as'],'attributes':_0x765f6b['attributes']};}):[]};}):[]};}):[]:[]})[_0x6ab2('0x1f')](function(_0x4cfb48){logger['info'](_0x6ab2('0x23'),_0x22aaf4);logger['debug'](_0x6ab2('0x23'),_0x22aaf4,JSON[_0x6ab2('0x11')](_0x4cfb48));_0x59ddff(_0x4cfb48);})['catch'](function(_0x1725e7){logger[_0x6ab2('0x13')](_0x6ab2('0x23'),_0x1725e7[_0x6ab2('0x14')],_0x22aaf4);_0x20ef18(_0x58c1bd['error'](0x1f4,_0x1725e7[_0x6ab2('0x14')]));});});};