Built motion from commit 19a84241.|2.5.34
[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 _0x2d4d=['code','message','info','request\x20sent','result','catch','GetZendeskAccount','ZendeskAccount','options','raw','where','attributes','limit','include','map','model','ShowZendeskAccount','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','ZendeskAccount,\x20%s,\x20%s','debug','ZendeskAccount,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x402765,_0x1c2849){var _0x59561b=function(_0x5580db){while(--_0x5580db){_0x402765['push'](_0x402765['shift']());}};_0x59561b(++_0x1c2849);}(_0x2d4d,0x1cd));var _0xd2d4=function(_0x3356ce,_0x2cdc6c){_0x3356ce=_0x3356ce-0x0;var _0x316295=_0x2d4d[_0x3356ce];return _0x316295;};'use strict';var _=require(_0xd2d4('0x0'));var util=require(_0xd2d4('0x1'));var moment=require(_0xd2d4('0x2'));var BPromise=require(_0xd2d4('0x3'));var rs=require(_0xd2d4('0x4'));var fs=require('fs');var Redis=require(_0xd2d4('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xd2d4('0x6'));var logger=require(_0xd2d4('0x7'))(_0xd2d4('0x8'));var config=require(_0xd2d4('0x9'));var jayson=require(_0xd2d4('0xa'));var client=jayson[_0xd2d4('0xb')][_0xd2d4('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x680d5f,_0x5a929c,_0x1b0715){return new BPromise(function(_0x109f13,_0xb05205){return client[_0xd2d4('0xd')](_0x680d5f,_0x1b0715)[_0xd2d4('0xe')](function(_0x1a85ed){logger['info'](_0xd2d4('0xf'),_0x5a929c,'request\x20sent');logger[_0xd2d4('0x10')](_0xd2d4('0x11'),_0x5a929c,'request\x20sent',JSON[_0xd2d4('0x12')](_0x1a85ed));if(_0x1a85ed[_0xd2d4('0x13')]){if(_0x1a85ed['error'][_0xd2d4('0x14')]===0x1f4){logger[_0xd2d4('0x13')](_0xd2d4('0xf'),_0x5a929c,_0x1a85ed[_0xd2d4('0x13')][_0xd2d4('0x15')]);return _0xb05205(_0x1a85ed[_0xd2d4('0x13')][_0xd2d4('0x15')]);}logger['error']('ZendeskAccount,\x20%s,\x20%s',_0x5a929c,_0x1a85ed[_0xd2d4('0x13')][_0xd2d4('0x15')]);return _0x109f13(_0x1a85ed[_0xd2d4('0x13')]['message']);}else{logger[_0xd2d4('0x16')](_0xd2d4('0xf'),_0x5a929c,_0xd2d4('0x17'));_0x109f13(_0x1a85ed[_0xd2d4('0x18')]['message']);}})[_0xd2d4('0x19')](function(_0x5413bc){logger[_0xd2d4('0x13')](_0xd2d4('0xf'),_0x5a929c,_0x5413bc);_0xb05205(_0x5413bc);});});}exports[_0xd2d4('0x1a')]=function(_0x252b88){var _0x16d3d6=this;return new Promise(function(_0x4232d2,_0x8a2a3a){return db[_0xd2d4('0x1b')]['findAll']({'raw':_0x252b88[_0xd2d4('0x1c')]?_0x252b88[_0xd2d4('0x1c')][_0xd2d4('0x1d')]===undefined?!![]:![]:!![],'where':_0x252b88[_0xd2d4('0x1c')]?_0x252b88[_0xd2d4('0x1c')][_0xd2d4('0x1e')]||null:null,'attributes':_0x252b88[_0xd2d4('0x1c')]?_0x252b88['options'][_0xd2d4('0x1f')]||null:null,'limit':_0x252b88[_0xd2d4('0x1c')]?_0x252b88[_0xd2d4('0x1c')][_0xd2d4('0x20')]||null:null,'include':_0x252b88[_0xd2d4('0x1c')]?_0x252b88['options'][_0xd2d4('0x21')]?_[_0xd2d4('0x22')](_0x252b88[_0xd2d4('0x1c')][_0xd2d4('0x21')],function(_0xd5247){return{'model':db[_0xd5247['model']],'as':_0xd5247['as'],'attributes':_0xd5247[_0xd2d4('0x1f')],'include':_0xd5247[_0xd2d4('0x21')]?_[_0xd2d4('0x22')](_0xd5247[_0xd2d4('0x21')],function(_0x2dff07){return{'model':db[_0x2dff07[_0xd2d4('0x23')]],'as':_0x2dff07['as'],'attributes':_0x2dff07[_0xd2d4('0x1f')],'include':_0x2dff07[_0xd2d4('0x21')]?_[_0xd2d4('0x22')](_0x2dff07['include'],function(_0x1cec8d){return{'model':db[_0x1cec8d['model']],'as':_0x1cec8d['as'],'attributes':_0x1cec8d[_0xd2d4('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xd2d4('0xe')](function(_0x145fcb){logger[_0xd2d4('0x16')](_0xd2d4('0x1a'),_0x252b88);logger[_0xd2d4('0x10')](_0xd2d4('0x1a'),_0x252b88,JSON['stringify'](_0x145fcb));_0x4232d2(_0x145fcb);})['catch'](function(_0x25974e){logger['error'](_0xd2d4('0x1a'),_0x25974e[_0xd2d4('0x15')],_0x252b88);_0x8a2a3a(_0x16d3d6[_0xd2d4('0x13')](0x1f4,_0x25974e[_0xd2d4('0x15')]));});});};exports[_0xd2d4('0x24')]=function(_0x33cb0b){var _0x11c442=this;return new Promise(function(_0x515012,_0x408823){return db[_0xd2d4('0x1b')]['find']({'raw':_0x33cb0b[_0xd2d4('0x1c')]?_0x33cb0b[_0xd2d4('0x1c')][_0xd2d4('0x1d')]===undefined?!![]:![]:!![],'where':_0x33cb0b[_0xd2d4('0x1c')]?_0x33cb0b[_0xd2d4('0x1c')][_0xd2d4('0x1e')]||null:null,'attributes':_0x33cb0b[_0xd2d4('0x1c')]?_0x33cb0b[_0xd2d4('0x1c')][_0xd2d4('0x1f')]||null:null,'include':_0x33cb0b[_0xd2d4('0x1c')]?_0x33cb0b[_0xd2d4('0x1c')][_0xd2d4('0x21')]?_['map'](_0x33cb0b[_0xd2d4('0x1c')][_0xd2d4('0x21')],function(_0x6ad7dd){return{'model':db[_0x6ad7dd[_0xd2d4('0x23')]],'as':_0x6ad7dd['as'],'attributes':_0x6ad7dd[_0xd2d4('0x1f')],'include':_0x6ad7dd[_0xd2d4('0x21')]?_['map'](_0x6ad7dd[_0xd2d4('0x21')],function(_0x255dcc){return{'model':db[_0x255dcc[_0xd2d4('0x23')]],'as':_0x255dcc['as'],'attributes':_0x255dcc['attributes'],'include':_0x255dcc['include']?_[_0xd2d4('0x22')](_0x255dcc['include'],function(_0x321ba5){return{'model':db[_0x321ba5[_0xd2d4('0x23')]],'as':_0x321ba5['as'],'attributes':_0x321ba5[_0xd2d4('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xd2d4('0xe')](function(_0x145a5d){logger[_0xd2d4('0x16')](_0xd2d4('0x24'),_0x33cb0b);logger[_0xd2d4('0x10')](_0xd2d4('0x24'),_0x33cb0b,JSON[_0xd2d4('0x12')](_0x145a5d));_0x515012(_0x145a5d);})[_0xd2d4('0x19')](function(_0x3c4ea3){logger[_0xd2d4('0x13')](_0xd2d4('0x24'),_0x3c4ea3[_0xd2d4('0x15')],_0x33cb0b);_0x408823(_0x11c442[_0xd2d4('0x13')](0x1f4,_0x3c4ea3[_0xd2d4('0x15')]));});});};