b96d7968df64c4fd69dee8e833d04b405dbc3b7c
[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 _0x1fcf=['ShowZendeskAccount','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','then','info','ZendeskAccount,\x20%s,\x20%s','request\x20sent','debug','ZendeskAccount,\x20%s,\x20%s,\x20%s','error','message','result','ZendeskAccount','findAll','options','raw','where','attributes','limit','include','map','model','GetZendeskAccount','stringify','catch'];(function(_0x11a220,_0x4e470a){var _0x20d8fe=function(_0xbedfd){while(--_0xbedfd){_0x11a220['push'](_0x11a220['shift']());}};_0x20d8fe(++_0x4e470a);}(_0x1fcf,0x145));var _0xf1fc=function(_0x5730ee,_0x3c82f3){_0x5730ee=_0x5730ee-0x0;var _0x43aa14=_0x1fcf[_0x5730ee];return _0x43aa14;};'use strict';var _=require(_0xf1fc('0x0'));var util=require(_0xf1fc('0x1'));var moment=require(_0xf1fc('0x2'));var BPromise=require(_0xf1fc('0x3'));var rs=require(_0xf1fc('0x4'));var fs=require('fs');var Redis=require(_0xf1fc('0x5'));var db=require(_0xf1fc('0x6'))['db'];var utils=require(_0xf1fc('0x7'));var logger=require(_0xf1fc('0x8'))(_0xf1fc('0x9'));var config=require(_0xf1fc('0xa'));var jayson=require(_0xf1fc('0xb'));var client=jayson['client'][_0xf1fc('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x39f36d,_0x12bf41,_0x58fe38){return new BPromise(function(_0x59d862,_0x1448b8){return client['request'](_0x39f36d,_0x58fe38)[_0xf1fc('0xd')](function(_0x140096){logger[_0xf1fc('0xe')](_0xf1fc('0xf'),_0x12bf41,_0xf1fc('0x10'));logger[_0xf1fc('0x11')](_0xf1fc('0x12'),_0x12bf41,'request\x20sent',JSON['stringify'](_0x140096));if(_0x140096[_0xf1fc('0x13')]){if(_0x140096['error']['code']===0x1f4){logger[_0xf1fc('0x13')](_0xf1fc('0xf'),_0x12bf41,_0x140096['error'][_0xf1fc('0x14')]);return _0x1448b8(_0x140096['error'][_0xf1fc('0x14')]);}logger[_0xf1fc('0x13')](_0xf1fc('0xf'),_0x12bf41,_0x140096['error'][_0xf1fc('0x14')]);return _0x59d862(_0x140096[_0xf1fc('0x13')]['message']);}else{logger[_0xf1fc('0xe')]('ZendeskAccount,\x20%s,\x20%s',_0x12bf41,_0xf1fc('0x10'));_0x59d862(_0x140096[_0xf1fc('0x15')][_0xf1fc('0x14')]);}})['catch'](function(_0x5c8cf2){logger[_0xf1fc('0x13')](_0xf1fc('0xf'),_0x12bf41,_0x5c8cf2);_0x1448b8(_0x5c8cf2);});});}exports['GetZendeskAccount']=function(_0x3e51d2){var _0x4bc4b5=this;return new Promise(function(_0x4e6d69,_0x31748c){return db[_0xf1fc('0x16')][_0xf1fc('0x17')]({'raw':_0x3e51d2[_0xf1fc('0x18')]?_0x3e51d2[_0xf1fc('0x18')][_0xf1fc('0x19')]===undefined?!![]:![]:!![],'where':_0x3e51d2[_0xf1fc('0x18')]?_0x3e51d2[_0xf1fc('0x18')][_0xf1fc('0x1a')]||null:null,'attributes':_0x3e51d2['options']?_0x3e51d2[_0xf1fc('0x18')][_0xf1fc('0x1b')]||null:null,'limit':_0x3e51d2[_0xf1fc('0x18')]?_0x3e51d2['options'][_0xf1fc('0x1c')]||null:null,'include':_0x3e51d2['options']?_0x3e51d2[_0xf1fc('0x18')][_0xf1fc('0x1d')]?_[_0xf1fc('0x1e')](_0x3e51d2[_0xf1fc('0x18')][_0xf1fc('0x1d')],function(_0x313cd0){return{'model':db[_0x313cd0['model']],'as':_0x313cd0['as'],'attributes':_0x313cd0[_0xf1fc('0x1b')],'include':_0x313cd0['include']?_[_0xf1fc('0x1e')](_0x313cd0[_0xf1fc('0x1d')],function(_0x8e9e48){return{'model':db[_0x8e9e48[_0xf1fc('0x1f')]],'as':_0x8e9e48['as'],'attributes':_0x8e9e48[_0xf1fc('0x1b')],'include':_0x8e9e48[_0xf1fc('0x1d')]?_[_0xf1fc('0x1e')](_0x8e9e48[_0xf1fc('0x1d')],function(_0x372212){return{'model':db[_0x372212[_0xf1fc('0x1f')]],'as':_0x372212['as'],'attributes':_0x372212[_0xf1fc('0x1b')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x41d2d4){logger[_0xf1fc('0xe')](_0xf1fc('0x20'),_0x3e51d2);logger[_0xf1fc('0x11')](_0xf1fc('0x20'),_0x3e51d2,JSON[_0xf1fc('0x21')](_0x41d2d4));_0x4e6d69(_0x41d2d4);})[_0xf1fc('0x22')](function(_0x582f07){logger['error']('GetZendeskAccount',_0x582f07[_0xf1fc('0x14')],_0x3e51d2);_0x31748c(_0x4bc4b5[_0xf1fc('0x13')](0x1f4,_0x582f07[_0xf1fc('0x14')]));});});};exports[_0xf1fc('0x23')]=function(_0x52afcc){var _0x2db20a=this;return new Promise(function(_0x109452,_0x53977f){return db[_0xf1fc('0x16')]['find']({'raw':_0x52afcc['options']?_0x52afcc[_0xf1fc('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x52afcc[_0xf1fc('0x18')]?_0x52afcc[_0xf1fc('0x18')][_0xf1fc('0x1a')]||null:null,'attributes':_0x52afcc[_0xf1fc('0x18')]?_0x52afcc['options']['attributes']||null:null,'include':_0x52afcc['options']?_0x52afcc[_0xf1fc('0x18')]['include']?_['map'](_0x52afcc[_0xf1fc('0x18')]['include'],function(_0x41314d){return{'model':db[_0x41314d[_0xf1fc('0x1f')]],'as':_0x41314d['as'],'attributes':_0x41314d['attributes'],'include':_0x41314d[_0xf1fc('0x1d')]?_['map'](_0x41314d[_0xf1fc('0x1d')],function(_0x365e69){return{'model':db[_0x365e69[_0xf1fc('0x1f')]],'as':_0x365e69['as'],'attributes':_0x365e69[_0xf1fc('0x1b')],'include':_0x365e69['include']?_[_0xf1fc('0x1e')](_0x365e69[_0xf1fc('0x1d')],function(_0x1c60a0){return{'model':db[_0x1c60a0['model']],'as':_0x1c60a0['as'],'attributes':_0x1c60a0[_0xf1fc('0x1b')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x109c6f){logger[_0xf1fc('0xe')](_0xf1fc('0x23'),_0x52afcc);logger[_0xf1fc('0x11')](_0xf1fc('0x23'),_0x52afcc,JSON[_0xf1fc('0x21')](_0x109c6f));_0x109452(_0x109c6f);})['catch'](function(_0x4685ca){logger[_0xf1fc('0x13')](_0xf1fc('0x23'),_0x4685ca['message'],_0x52afcc);_0x53977f(_0x2db20a['error'](0x1f4,_0x4685ca['message']));});});};