b84a88125fc9bbcd83a3a977625086ac35bcb005
[motion2.git] / server / api / intZendeskAccount / intZendeskAccount.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 _0x1bf3=['error','code','ZendeskAccount,\x20%s,\x20%s','message','GetZendeskAccount','ZendeskAccount','findAll','options','raw','where','attributes','include','map','model','catch','ShowZendeskAccount','find','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','http','request','then','info','request\x20sent','debug','ZendeskAccount,\x20%s,\x20%s,\x20%s','stringify'];(function(_0x515262,_0x5efdd3){var _0x403c6f=function(_0x3bfc37){while(--_0x3bfc37){_0x515262['push'](_0x515262['shift']());}};_0x403c6f(++_0x5efdd3);}(_0x1bf3,0x16f));var _0x31bf=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0x1bf3[_0x20a584];return _0x4b41a8;};'use strict';var _=require(_0x31bf('0x0'));var util=require(_0x31bf('0x1'));var moment=require('moment');var BPromise=require(_0x31bf('0x2'));var rs=require(_0x31bf('0x3'));var fs=require('fs');var Redis=require(_0x31bf('0x4'));var db=require(_0x31bf('0x5'))['db'];var utils=require(_0x31bf('0x6'));var logger=require(_0x31bf('0x7'))(_0x31bf('0x8'));var config=require(_0x31bf('0x9'));var jayson=require('jayson/promise');var client=jayson['client'][_0x31bf('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x18ffd9,_0x92366b,_0x84e6ee){return new BPromise(function(_0x1998b5,_0x3f9dfc){return client[_0x31bf('0xb')](_0x18ffd9,_0x84e6ee)[_0x31bf('0xc')](function(_0x1c2a0e){logger[_0x31bf('0xd')]('ZendeskAccount,\x20%s,\x20%s',_0x92366b,_0x31bf('0xe'));logger[_0x31bf('0xf')](_0x31bf('0x10'),_0x92366b,'request\x20sent',JSON[_0x31bf('0x11')](_0x1c2a0e));if(_0x1c2a0e[_0x31bf('0x12')]){if(_0x1c2a0e[_0x31bf('0x12')][_0x31bf('0x13')]===0x1f4){logger['error'](_0x31bf('0x14'),_0x92366b,_0x1c2a0e['error'][_0x31bf('0x15')]);return _0x3f9dfc(_0x1c2a0e[_0x31bf('0x12')][_0x31bf('0x15')]);}logger['error'](_0x31bf('0x14'),_0x92366b,_0x1c2a0e[_0x31bf('0x12')][_0x31bf('0x15')]);return _0x1998b5(_0x1c2a0e[_0x31bf('0x12')][_0x31bf('0x15')]);}else{logger[_0x31bf('0xd')](_0x31bf('0x14'),_0x92366b,_0x31bf('0xe'));_0x1998b5(_0x1c2a0e['result'][_0x31bf('0x15')]);}})['catch'](function(_0x462056){logger[_0x31bf('0x12')]('ZendeskAccount,\x20%s,\x20%s',_0x92366b,_0x462056);_0x3f9dfc(_0x462056);});});}exports[_0x31bf('0x16')]=function(_0x4e0f61){var _0x4b0313=this;return new Promise(function(_0x2fa8ef,_0x1a40f9){return db[_0x31bf('0x17')][_0x31bf('0x18')]({'raw':_0x4e0f61[_0x31bf('0x19')]?_0x4e0f61[_0x31bf('0x19')][_0x31bf('0x1a')]===undefined?!![]:![]:!![],'where':_0x4e0f61[_0x31bf('0x19')]?_0x4e0f61[_0x31bf('0x19')][_0x31bf('0x1b')]||null:null,'attributes':_0x4e0f61[_0x31bf('0x19')]?_0x4e0f61['options'][_0x31bf('0x1c')]||null:null,'limit':_0x4e0f61['options']?_0x4e0f61[_0x31bf('0x19')]['limit']||null:null,'include':_0x4e0f61[_0x31bf('0x19')]?_0x4e0f61['options'][_0x31bf('0x1d')]?_[_0x31bf('0x1e')](_0x4e0f61['options']['include'],function(_0x3a140a){return{'model':db[_0x3a140a[_0x31bf('0x1f')]],'as':_0x3a140a['as'],'attributes':_0x3a140a[_0x31bf('0x1c')],'include':_0x3a140a['include']?_[_0x31bf('0x1e')](_0x3a140a[_0x31bf('0x1d')],function(_0x2139f0){return{'model':db[_0x2139f0[_0x31bf('0x1f')]],'as':_0x2139f0['as'],'attributes':_0x2139f0['attributes'],'include':_0x2139f0['include']?_[_0x31bf('0x1e')](_0x2139f0[_0x31bf('0x1d')],function(_0x3a26cf){return{'model':db[_0x3a26cf[_0x31bf('0x1f')]],'as':_0x3a26cf['as'],'attributes':_0x3a26cf['attributes']};}):[]};}):[]};}):[]:[]})[_0x31bf('0xc')](function(_0x2d82e4){logger['info']('GetZendeskAccount',_0x4e0f61);logger['debug']('GetZendeskAccount',_0x4e0f61,JSON[_0x31bf('0x11')](_0x2d82e4));_0x2fa8ef(_0x2d82e4);})[_0x31bf('0x20')](function(_0x1c2450){logger['error'](_0x31bf('0x16'),_0x1c2450['message'],_0x4e0f61);_0x1a40f9(_0x4b0313[_0x31bf('0x12')](0x1f4,_0x1c2450[_0x31bf('0x15')]));});});};exports[_0x31bf('0x21')]=function(_0x55c786){var _0x2f2db8=this;return new Promise(function(_0x1b105b,_0x5a063c){return db[_0x31bf('0x17')][_0x31bf('0x22')]({'raw':_0x55c786[_0x31bf('0x19')]?_0x55c786[_0x31bf('0x19')][_0x31bf('0x1a')]===undefined?!![]:![]:!![],'where':_0x55c786[_0x31bf('0x19')]?_0x55c786[_0x31bf('0x19')][_0x31bf('0x1b')]||null:null,'attributes':_0x55c786[_0x31bf('0x19')]?_0x55c786[_0x31bf('0x19')][_0x31bf('0x1c')]||null:null,'include':_0x55c786['options']?_0x55c786['options'][_0x31bf('0x1d')]?_[_0x31bf('0x1e')](_0x55c786[_0x31bf('0x19')][_0x31bf('0x1d')],function(_0x528cf4){return{'model':db[_0x528cf4['model']],'as':_0x528cf4['as'],'attributes':_0x528cf4[_0x31bf('0x1c')],'include':_0x528cf4['include']?_[_0x31bf('0x1e')](_0x528cf4[_0x31bf('0x1d')],function(_0x5ce289){return{'model':db[_0x5ce289['model']],'as':_0x5ce289['as'],'attributes':_0x5ce289[_0x31bf('0x1c')],'include':_0x5ce289['include']?_[_0x31bf('0x1e')](_0x5ce289['include'],function(_0x485255){return{'model':db[_0x485255[_0x31bf('0x1f')]],'as':_0x485255['as'],'attributes':_0x485255[_0x31bf('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x31bf('0xc')](function(_0x1f3417){logger[_0x31bf('0xd')](_0x31bf('0x21'),_0x55c786);logger[_0x31bf('0xf')](_0x31bf('0x21'),_0x55c786,JSON['stringify'](_0x1f3417));_0x1b105b(_0x1f3417);})[_0x31bf('0x20')](function(_0x8398fb){logger[_0x31bf('0x12')](_0x31bf('0x21'),_0x8398fb[_0x31bf('0x15')],_0x55c786);_0x5a063c(_0x2f2db8[_0x31bf('0x12')](0x1f4,_0x8398fb[_0x31bf('0x15')]));});});};