Built motion from commit (unavailable).|2.5.22
[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 _0x2895=['jayson/promise','client','http','then','info','FreshdeskAccount,\x20%s,\x20%s','request\x20sent','debug','FreshdeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','FreshdeskAccount','findAll','options','raw','where','attributes','limit','include','map','model','GetFreshdeskAccount','catch','find','ShowFreshdeskAccount','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc'];(function(_0x695685,_0x2067b2){var _0x1b2090=function(_0x1325ba){while(--_0x1325ba){_0x695685['push'](_0x695685['shift']());}};_0x1b2090(++_0x2067b2);}(_0x2895,0x1a7));var _0x5289=function(_0x3f46aa,_0x25d595){_0x3f46aa=_0x3f46aa-0x0;var _0x4811e5=_0x2895[_0x3f46aa];return _0x4811e5;};'use strict';var _=require(_0x5289('0x0'));var util=require(_0x5289('0x1'));var moment=require(_0x5289('0x2'));var BPromise=require(_0x5289('0x3'));var rs=require(_0x5289('0x4'));var fs=require('fs');var Redis=require(_0x5289('0x5'));var db=require(_0x5289('0x6'))['db'];var utils=require(_0x5289('0x7'));var logger=require('../../config/logger')(_0x5289('0x8'));var config=require('../../config/environment');var jayson=require(_0x5289('0x9'));var client=jayson[_0x5289('0xa')][_0x5289('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x102b85,_0x51fa76,_0xc8aca2){return new BPromise(function(_0x39ddb9,_0x121c04){return client['request'](_0x102b85,_0xc8aca2)[_0x5289('0xc')](function(_0x3b2749){logger[_0x5289('0xd')](_0x5289('0xe'),_0x51fa76,_0x5289('0xf'));logger[_0x5289('0x10')](_0x5289('0x11'),_0x51fa76,_0x5289('0xf'),JSON[_0x5289('0x12')](_0x3b2749));if(_0x3b2749[_0x5289('0x13')]){if(_0x3b2749[_0x5289('0x13')][_0x5289('0x14')]===0x1f4){logger[_0x5289('0x13')](_0x5289('0xe'),_0x51fa76,_0x3b2749[_0x5289('0x13')]['message']);return _0x121c04(_0x3b2749['error']['message']);}logger[_0x5289('0x13')]('FreshdeskAccount,\x20%s,\x20%s',_0x51fa76,_0x3b2749['error'][_0x5289('0x15')]);return _0x39ddb9(_0x3b2749[_0x5289('0x13')][_0x5289('0x15')]);}else{logger['info'](_0x5289('0xe'),_0x51fa76,_0x5289('0xf'));_0x39ddb9(_0x3b2749['result']['message']);}})['catch'](function(_0x57a412){logger['error'](_0x5289('0xe'),_0x51fa76,_0x57a412);_0x121c04(_0x57a412);});});}exports['GetFreshdeskAccount']=function(_0x3adde9){var _0x108380=this;return new Promise(function(_0x12eb6c,_0x532f99){return db[_0x5289('0x16')][_0x5289('0x17')]({'raw':_0x3adde9[_0x5289('0x18')]?_0x3adde9[_0x5289('0x18')][_0x5289('0x19')]===undefined?!![]:![]:!![],'where':_0x3adde9[_0x5289('0x18')]?_0x3adde9[_0x5289('0x18')][_0x5289('0x1a')]||null:null,'attributes':_0x3adde9['options']?_0x3adde9[_0x5289('0x18')][_0x5289('0x1b')]||null:null,'limit':_0x3adde9[_0x5289('0x18')]?_0x3adde9['options'][_0x5289('0x1c')]||null:null,'include':_0x3adde9[_0x5289('0x18')]?_0x3adde9[_0x5289('0x18')][_0x5289('0x1d')]?_[_0x5289('0x1e')](_0x3adde9[_0x5289('0x18')][_0x5289('0x1d')],function(_0x3a6103){return{'model':db[_0x3a6103['model']],'as':_0x3a6103['as'],'attributes':_0x3a6103[_0x5289('0x1b')],'include':_0x3a6103[_0x5289('0x1d')]?_['map'](_0x3a6103['include'],function(_0x1aa423){return{'model':db[_0x1aa423['model']],'as':_0x1aa423['as'],'attributes':_0x1aa423[_0x5289('0x1b')],'include':_0x1aa423['include']?_[_0x5289('0x1e')](_0x1aa423['include'],function(_0x11ea35){return{'model':db[_0x11ea35[_0x5289('0x1f')]],'as':_0x11ea35['as'],'attributes':_0x11ea35[_0x5289('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x5289('0xc')](function(_0x500401){logger[_0x5289('0xd')]('GetFreshdeskAccount',_0x3adde9);logger['debug'](_0x5289('0x20'),_0x3adde9,JSON['stringify'](_0x500401));_0x12eb6c(_0x500401);})[_0x5289('0x21')](function(_0x2d1a68){logger['error']('GetFreshdeskAccount',_0x2d1a68[_0x5289('0x15')],_0x3adde9);_0x532f99(_0x108380[_0x5289('0x13')](0x1f4,_0x2d1a68['message']));});});};exports['ShowFreshdeskAccount']=function(_0x2e7c28){var _0x572fc8=this;return new Promise(function(_0x312173,_0x2249d5){return db[_0x5289('0x16')][_0x5289('0x22')]({'raw':_0x2e7c28[_0x5289('0x18')]?_0x2e7c28[_0x5289('0x18')][_0x5289('0x19')]===undefined?!![]:![]:!![],'where':_0x2e7c28['options']?_0x2e7c28['options'][_0x5289('0x1a')]||null:null,'attributes':_0x2e7c28[_0x5289('0x18')]?_0x2e7c28[_0x5289('0x18')][_0x5289('0x1b')]||null:null,'include':_0x2e7c28[_0x5289('0x18')]?_0x2e7c28[_0x5289('0x18')][_0x5289('0x1d')]?_[_0x5289('0x1e')](_0x2e7c28[_0x5289('0x18')][_0x5289('0x1d')],function(_0x57071d){return{'model':db[_0x57071d[_0x5289('0x1f')]],'as':_0x57071d['as'],'attributes':_0x57071d[_0x5289('0x1b')],'include':_0x57071d['include']?_[_0x5289('0x1e')](_0x57071d[_0x5289('0x1d')],function(_0x138106){return{'model':db[_0x138106[_0x5289('0x1f')]],'as':_0x138106['as'],'attributes':_0x138106[_0x5289('0x1b')],'include':_0x138106['include']?_[_0x5289('0x1e')](_0x138106[_0x5289('0x1d')],function(_0x125e3d){return{'model':db[_0x125e3d[_0x5289('0x1f')]],'as':_0x125e3d['as'],'attributes':_0x125e3d[_0x5289('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x5289('0xc')](function(_0x29ddda){logger[_0x5289('0xd')](_0x5289('0x23'),_0x2e7c28);logger[_0x5289('0x10')](_0x5289('0x23'),_0x2e7c28,JSON[_0x5289('0x12')](_0x29ddda));_0x312173(_0x29ddda);})['catch'](function(_0x1ff975){logger[_0x5289('0x13')](_0x5289('0x23'),_0x1ff975[_0x5289('0x15')],_0x2e7c28);_0x2249d5(_0x572fc8[_0x5289('0x13')](0x1f4,_0x1ff975['message']));});});};