5b969dd3dc4f111d921c35b5865f7bb484bb2323
[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 _0x4b68=['code','message','info','catch','FreshdeskAccount','options','raw','where','attributes','limit','map','include','model','GetFreshdeskAccount','stringify','ShowFreshdeskAccount','find','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','request','then','FreshdeskAccount,\x20%s,\x20%s','request\x20sent','debug','FreshdeskAccount,\x20%s,\x20%s,\x20%s','error'];(function(_0x39b801,_0x1fdd40){var _0x53acb1=function(_0x19607f){while(--_0x19607f){_0x39b801['push'](_0x39b801['shift']());}};_0x53acb1(++_0x1fdd40);}(_0x4b68,0x129));var _0x84b6=function(_0x19950b,_0x53d0d7){_0x19950b=_0x19950b-0x0;var _0x3c6b41=_0x4b68[_0x19950b];return _0x3c6b41;};'use strict';var _=require(_0x84b6('0x0'));var util=require(_0x84b6('0x1'));var moment=require(_0x84b6('0x2'));var BPromise=require(_0x84b6('0x3'));var rs=require(_0x84b6('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x84b6('0x5'))['db'];var utils=require(_0x84b6('0x6'));var logger=require(_0x84b6('0x7'))(_0x84b6('0x8'));var config=require('../../config/environment');var jayson=require(_0x84b6('0x9'));var client=jayson[_0x84b6('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x3892fd,_0x5e8cf8,_0x20ba3a){return new BPromise(function(_0x3ff6e1,_0x226aed){return client[_0x84b6('0xb')](_0x3892fd,_0x20ba3a)[_0x84b6('0xc')](function(_0x4586c0){logger['info'](_0x84b6('0xd'),_0x5e8cf8,_0x84b6('0xe'));logger[_0x84b6('0xf')](_0x84b6('0x10'),_0x5e8cf8,_0x84b6('0xe'),JSON['stringify'](_0x4586c0));if(_0x4586c0[_0x84b6('0x11')]){if(_0x4586c0[_0x84b6('0x11')][_0x84b6('0x12')]===0x1f4){logger['error'](_0x84b6('0xd'),_0x5e8cf8,_0x4586c0[_0x84b6('0x11')][_0x84b6('0x13')]);return _0x226aed(_0x4586c0[_0x84b6('0x11')][_0x84b6('0x13')]);}logger[_0x84b6('0x11')]('FreshdeskAccount,\x20%s,\x20%s',_0x5e8cf8,_0x4586c0[_0x84b6('0x11')][_0x84b6('0x13')]);return _0x3ff6e1(_0x4586c0['error']['message']);}else{logger[_0x84b6('0x14')](_0x84b6('0xd'),_0x5e8cf8,_0x84b6('0xe'));_0x3ff6e1(_0x4586c0['result']['message']);}})[_0x84b6('0x15')](function(_0x16ae4d){logger[_0x84b6('0x11')](_0x84b6('0xd'),_0x5e8cf8,_0x16ae4d);_0x226aed(_0x16ae4d);});});}exports['GetFreshdeskAccount']=function(_0x5310a6){var _0x24fb95=this;return new Promise(function(_0x3b8af5,_0x369842){return db[_0x84b6('0x16')]['findAll']({'raw':_0x5310a6[_0x84b6('0x17')]?_0x5310a6[_0x84b6('0x17')][_0x84b6('0x18')]===undefined?!![]:![]:!![],'where':_0x5310a6[_0x84b6('0x17')]?_0x5310a6['options'][_0x84b6('0x19')]||null:null,'attributes':_0x5310a6['options']?_0x5310a6[_0x84b6('0x17')][_0x84b6('0x1a')]||null:null,'limit':_0x5310a6[_0x84b6('0x17')]?_0x5310a6[_0x84b6('0x17')][_0x84b6('0x1b')]||null:null,'include':_0x5310a6[_0x84b6('0x17')]?_0x5310a6[_0x84b6('0x17')]['include']?_[_0x84b6('0x1c')](_0x5310a6[_0x84b6('0x17')][_0x84b6('0x1d')],function(_0x2cb07b){return{'model':db[_0x2cb07b['model']],'as':_0x2cb07b['as'],'attributes':_0x2cb07b[_0x84b6('0x1a')],'include':_0x2cb07b['include']?_['map'](_0x2cb07b[_0x84b6('0x1d')],function(_0x2f75ec){return{'model':db[_0x2f75ec[_0x84b6('0x1e')]],'as':_0x2f75ec['as'],'attributes':_0x2f75ec[_0x84b6('0x1a')],'include':_0x2f75ec[_0x84b6('0x1d')]?_['map'](_0x2f75ec[_0x84b6('0x1d')],function(_0x35c9f5){return{'model':db[_0x35c9f5['model']],'as':_0x35c9f5['as'],'attributes':_0x35c9f5['attributes']};}):[]};}):[]};}):[]:[]})[_0x84b6('0xc')](function(_0x207bd3){logger['info'](_0x84b6('0x1f'),_0x5310a6);logger[_0x84b6('0xf')](_0x84b6('0x1f'),_0x5310a6,JSON[_0x84b6('0x20')](_0x207bd3));_0x3b8af5(_0x207bd3);})[_0x84b6('0x15')](function(_0x37e83e){logger[_0x84b6('0x11')](_0x84b6('0x1f'),_0x37e83e['message'],_0x5310a6);_0x369842(_0x24fb95[_0x84b6('0x11')](0x1f4,_0x37e83e[_0x84b6('0x13')]));});});};exports[_0x84b6('0x21')]=function(_0x2b3a36){var _0x15d2c2=this;return new Promise(function(_0xa1bf02,_0x5365dc){return db['FreshdeskAccount'][_0x84b6('0x22')]({'raw':_0x2b3a36[_0x84b6('0x17')]?_0x2b3a36[_0x84b6('0x17')][_0x84b6('0x18')]===undefined?!![]:![]:!![],'where':_0x2b3a36[_0x84b6('0x17')]?_0x2b3a36[_0x84b6('0x17')][_0x84b6('0x19')]||null:null,'attributes':_0x2b3a36['options']?_0x2b3a36[_0x84b6('0x17')][_0x84b6('0x1a')]||null:null,'include':_0x2b3a36[_0x84b6('0x17')]?_0x2b3a36[_0x84b6('0x17')][_0x84b6('0x1d')]?_['map'](_0x2b3a36[_0x84b6('0x17')]['include'],function(_0x4d0444){return{'model':db[_0x4d0444[_0x84b6('0x1e')]],'as':_0x4d0444['as'],'attributes':_0x4d0444['attributes'],'include':_0x4d0444[_0x84b6('0x1d')]?_[_0x84b6('0x1c')](_0x4d0444[_0x84b6('0x1d')],function(_0x125de0){return{'model':db[_0x125de0[_0x84b6('0x1e')]],'as':_0x125de0['as'],'attributes':_0x125de0[_0x84b6('0x1a')],'include':_0x125de0[_0x84b6('0x1d')]?_['map'](_0x125de0[_0x84b6('0x1d')],function(_0x57bd6f){return{'model':db[_0x57bd6f[_0x84b6('0x1e')]],'as':_0x57bd6f['as'],'attributes':_0x57bd6f[_0x84b6('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x84b6('0xc')](function(_0x23a6a5){logger['info']('ShowFreshdeskAccount',_0x2b3a36);logger[_0x84b6('0xf')](_0x84b6('0x21'),_0x2b3a36,JSON[_0x84b6('0x20')](_0x23a6a5));_0xa1bf02(_0x23a6a5);})[_0x84b6('0x15')](function(_0x482d06){logger[_0x84b6('0x11')]('ShowFreshdeskAccount',_0x482d06['message'],_0x2b3a36);_0x5365dc(_0x15d2c2[_0x84b6('0x11')](0x1f4,_0x482d06[_0x84b6('0x13')]));});});};