cdb924990677e2ceb5e007fcb904e0d38e3204e9
[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 _0x7bc0=['include','map','model','then','ShowZendeskAccount','find','util','moment','bluebird','ioredis','../../config/utils','rpc','../../config/environment','jayson/promise','info','ZendeskAccount,\x20%s,\x20%s','request\x20sent','debug','ZendeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','ZendeskAccount','findAll','raw','options','where','attributes','limit'];(function(_0xe2c50e,_0x32d774){var _0x1b3233=function(_0x2cb0ef){while(--_0x2cb0ef){_0xe2c50e['push'](_0xe2c50e['shift']());}};_0x1b3233(++_0x32d774);}(_0x7bc0,0xa1));var _0x07bc=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x7bc0[_0x3dd15e];return _0x231fd0;};'use strict';var _=require('lodash');var util=require(_0x07bc('0x0'));var moment=require(_0x07bc('0x1'));var BPromise=require(_0x07bc('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x07bc('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x07bc('0x4'));var logger=require('../../config/logger')(_0x07bc('0x5'));var config=require(_0x07bc('0x6'));var jayson=require(_0x07bc('0x7'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x46b719,_0x50373c,_0x4c0460){return new BPromise(function(_0x57708e,_0x451cee){return client['request'](_0x46b719,_0x4c0460)['then'](function(_0x3f2276){logger[_0x07bc('0x8')](_0x07bc('0x9'),_0x50373c,_0x07bc('0xa'));logger[_0x07bc('0xb')](_0x07bc('0xc'),_0x50373c,_0x07bc('0xa'),JSON[_0x07bc('0xd')](_0x3f2276));if(_0x3f2276[_0x07bc('0xe')]){if(_0x3f2276[_0x07bc('0xe')]['code']===0x1f4){logger[_0x07bc('0xe')](_0x07bc('0x9'),_0x50373c,_0x3f2276[_0x07bc('0xe')][_0x07bc('0xf')]);return _0x451cee(_0x3f2276[_0x07bc('0xe')]['message']);}logger[_0x07bc('0xe')]('ZendeskAccount,\x20%s,\x20%s',_0x50373c,_0x3f2276['error'][_0x07bc('0xf')]);return _0x57708e(_0x3f2276['error'][_0x07bc('0xf')]);}else{logger[_0x07bc('0x8')](_0x07bc('0x9'),_0x50373c,_0x07bc('0xa'));_0x57708e(_0x3f2276[_0x07bc('0x10')][_0x07bc('0xf')]);}})[_0x07bc('0x11')](function(_0x139227){logger[_0x07bc('0xe')](_0x07bc('0x9'),_0x50373c,_0x139227);_0x451cee(_0x139227);});});}exports['GetZendeskAccount']=function(_0x37c2f3){var _0x186999=this;return new Promise(function(_0x1c9dcf,_0x27ba64){return db[_0x07bc('0x12')][_0x07bc('0x13')]({'raw':_0x37c2f3['options']?_0x37c2f3['options'][_0x07bc('0x14')]===undefined?!![]:![]:!![],'where':_0x37c2f3[_0x07bc('0x15')]?_0x37c2f3[_0x07bc('0x15')][_0x07bc('0x16')]||null:null,'attributes':_0x37c2f3['options']?_0x37c2f3['options'][_0x07bc('0x17')]||null:null,'limit':_0x37c2f3[_0x07bc('0x15')]?_0x37c2f3[_0x07bc('0x15')][_0x07bc('0x18')]||null:null,'include':_0x37c2f3['options']?_0x37c2f3[_0x07bc('0x15')][_0x07bc('0x19')]?_[_0x07bc('0x1a')](_0x37c2f3[_0x07bc('0x15')][_0x07bc('0x19')],function(_0x9bc960){return{'model':db[_0x9bc960['model']],'as':_0x9bc960['as'],'attributes':_0x9bc960[_0x07bc('0x17')],'include':_0x9bc960[_0x07bc('0x19')]?_[_0x07bc('0x1a')](_0x9bc960['include'],function(_0x350ff1){return{'model':db[_0x350ff1[_0x07bc('0x1b')]],'as':_0x350ff1['as'],'attributes':_0x350ff1[_0x07bc('0x17')],'include':_0x350ff1['include']?_['map'](_0x350ff1[_0x07bc('0x19')],function(_0x159559){return{'model':db[_0x159559['model']],'as':_0x159559['as'],'attributes':_0x159559[_0x07bc('0x17')]};}):[]};}):[]};}):[]:[]})[_0x07bc('0x1c')](function(_0x1651c6){logger[_0x07bc('0x8')]('GetZendeskAccount',_0x37c2f3);logger[_0x07bc('0xb')]('GetZendeskAccount',_0x37c2f3,JSON[_0x07bc('0xd')](_0x1651c6));_0x1c9dcf(_0x1651c6);})[_0x07bc('0x11')](function(_0x1a8a4c){logger['error']('GetZendeskAccount',_0x1a8a4c[_0x07bc('0xf')],_0x37c2f3);_0x27ba64(_0x186999['error'](0x1f4,_0x1a8a4c[_0x07bc('0xf')]));});});};exports[_0x07bc('0x1d')]=function(_0x87c68f){var _0x255cc6=this;return new Promise(function(_0x1b7440,_0x357a52){return db[_0x07bc('0x12')][_0x07bc('0x1e')]({'raw':_0x87c68f[_0x07bc('0x15')]?_0x87c68f[_0x07bc('0x15')]['raw']===undefined?!![]:![]:!![],'where':_0x87c68f[_0x07bc('0x15')]?_0x87c68f[_0x07bc('0x15')]['where']||null:null,'attributes':_0x87c68f[_0x07bc('0x15')]?_0x87c68f['options']['attributes']||null:null,'include':_0x87c68f['options']?_0x87c68f[_0x07bc('0x15')][_0x07bc('0x19')]?_['map'](_0x87c68f[_0x07bc('0x15')][_0x07bc('0x19')],function(_0x170f25){return{'model':db[_0x170f25['model']],'as':_0x170f25['as'],'attributes':_0x170f25[_0x07bc('0x17')],'include':_0x170f25['include']?_[_0x07bc('0x1a')](_0x170f25[_0x07bc('0x19')],function(_0x57acb3){return{'model':db[_0x57acb3[_0x07bc('0x1b')]],'as':_0x57acb3['as'],'attributes':_0x57acb3[_0x07bc('0x17')],'include':_0x57acb3[_0x07bc('0x19')]?_[_0x07bc('0x1a')](_0x57acb3[_0x07bc('0x19')],function(_0x130cfc){return{'model':db[_0x130cfc[_0x07bc('0x1b')]],'as':_0x130cfc['as'],'attributes':_0x130cfc[_0x07bc('0x17')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x41bcab){logger[_0x07bc('0x8')](_0x07bc('0x1d'),_0x87c68f);logger['debug'](_0x07bc('0x1d'),_0x87c68f,JSON[_0x07bc('0xd')](_0x41bcab));_0x1b7440(_0x41bcab);})[_0x07bc('0x11')](function(_0x4e0b7f){logger[_0x07bc('0xe')](_0x07bc('0x1d'),_0x4e0b7f[_0x07bc('0xf')],_0x87c68f);_0x357a52(_0x255cc6[_0x07bc('0xe')](0x1f4,_0x4e0b7f[_0x07bc('0xf')]));});});};