Built motion from commit 775e2a94.|2.6.3
[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 _0x60f0=['lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','ZendeskAccount,\x20%s,\x20%s','request\x20sent','debug','ZendeskAccount,\x20%s,\x20%s,\x20%s','error','code','message','GetZendeskAccount','options','raw','where','attributes','limit','map','include','model','ShowZendeskAccount','ZendeskAccount','stringify','catch'];(function(_0x40220a,_0x22feb1){var _0x3903cc=function(_0x33a296){while(--_0x33a296){_0x40220a['push'](_0x40220a['shift']());}};_0x3903cc(++_0x22feb1);}(_0x60f0,0x128));var _0x060f=function(_0x36f80b,_0xf0af3d){_0x36f80b=_0x36f80b-0x0;var _0x297f03=_0x60f0[_0x36f80b];return _0x297f03;};'use strict';var _=require(_0x060f('0x0'));var util=require(_0x060f('0x1'));var moment=require(_0x060f('0x2'));var BPromise=require(_0x060f('0x3'));var rs=require(_0x060f('0x4'));var fs=require('fs');var Redis=require(_0x060f('0x5'));var db=require(_0x060f('0x6'))['db'];var utils=require(_0x060f('0x7'));var logger=require(_0x060f('0x8'))(_0x060f('0x9'));var config=require(_0x060f('0xa'));var jayson=require(_0x060f('0xb'));var client=jayson[_0x060f('0xc')][_0x060f('0xd')]({'port':0x232a});function respondWithRpcPromise(_0x3b9185,_0x42ce50,_0x1c183b){return new BPromise(function(_0x1c7c06,_0x252b93){return client[_0x060f('0xe')](_0x3b9185,_0x1c183b)[_0x060f('0xf')](function(_0x206489){logger[_0x060f('0x10')](_0x060f('0x11'),_0x42ce50,_0x060f('0x12'));logger[_0x060f('0x13')](_0x060f('0x14'),_0x42ce50,_0x060f('0x12'),JSON['stringify'](_0x206489));if(_0x206489[_0x060f('0x15')]){if(_0x206489[_0x060f('0x15')][_0x060f('0x16')]===0x1f4){logger[_0x060f('0x15')](_0x060f('0x11'),_0x42ce50,_0x206489[_0x060f('0x15')][_0x060f('0x17')]);return _0x252b93(_0x206489[_0x060f('0x15')][_0x060f('0x17')]);}logger[_0x060f('0x15')]('ZendeskAccount,\x20%s,\x20%s',_0x42ce50,_0x206489[_0x060f('0x15')]['message']);return _0x1c7c06(_0x206489[_0x060f('0x15')]['message']);}else{logger['info'](_0x060f('0x11'),_0x42ce50,_0x060f('0x12'));_0x1c7c06(_0x206489['result']['message']);}})['catch'](function(_0x838d7b){logger[_0x060f('0x15')](_0x060f('0x11'),_0x42ce50,_0x838d7b);_0x252b93(_0x838d7b);});});}exports[_0x060f('0x18')]=function(_0x293a06){var _0x2c65d7=this;return new Promise(function(_0x26c658,_0x22bc73){return db['ZendeskAccount']['findAll']({'raw':_0x293a06[_0x060f('0x19')]?_0x293a06[_0x060f('0x19')][_0x060f('0x1a')]===undefined?!![]:![]:!![],'where':_0x293a06[_0x060f('0x19')]?_0x293a06[_0x060f('0x19')][_0x060f('0x1b')]||null:null,'attributes':_0x293a06[_0x060f('0x19')]?_0x293a06[_0x060f('0x19')][_0x060f('0x1c')]||null:null,'limit':_0x293a06['options']?_0x293a06[_0x060f('0x19')][_0x060f('0x1d')]||null:null,'include':_0x293a06[_0x060f('0x19')]?_0x293a06[_0x060f('0x19')]['include']?_[_0x060f('0x1e')](_0x293a06['options'][_0x060f('0x1f')],function(_0x1986c7){return{'model':db[_0x1986c7['model']],'as':_0x1986c7['as'],'attributes':_0x1986c7[_0x060f('0x1c')],'include':_0x1986c7[_0x060f('0x1f')]?_[_0x060f('0x1e')](_0x1986c7[_0x060f('0x1f')],function(_0x5873de){return{'model':db[_0x5873de[_0x060f('0x20')]],'as':_0x5873de['as'],'attributes':_0x5873de[_0x060f('0x1c')],'include':_0x5873de[_0x060f('0x1f')]?_['map'](_0x5873de['include'],function(_0x2cdbf4){return{'model':db[_0x2cdbf4[_0x060f('0x20')]],'as':_0x2cdbf4['as'],'attributes':_0x2cdbf4[_0x060f('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x177d63){logger[_0x060f('0x10')](_0x060f('0x18'),_0x293a06);logger[_0x060f('0x13')](_0x060f('0x18'),_0x293a06,JSON['stringify'](_0x177d63));_0x26c658(_0x177d63);})['catch'](function(_0x4fc638){logger[_0x060f('0x15')](_0x060f('0x18'),_0x4fc638[_0x060f('0x17')],_0x293a06);_0x22bc73(_0x2c65d7[_0x060f('0x15')](0x1f4,_0x4fc638[_0x060f('0x17')]));});});};exports[_0x060f('0x21')]=function(_0x37f3ea){var _0x227de8=this;return new Promise(function(_0x31375d,_0x178943){return db[_0x060f('0x22')]['find']({'raw':_0x37f3ea[_0x060f('0x19')]?_0x37f3ea[_0x060f('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x37f3ea[_0x060f('0x19')]?_0x37f3ea['options'][_0x060f('0x1b')]||null:null,'attributes':_0x37f3ea['options']?_0x37f3ea[_0x060f('0x19')]['attributes']||null:null,'include':_0x37f3ea[_0x060f('0x19')]?_0x37f3ea[_0x060f('0x19')][_0x060f('0x1f')]?_[_0x060f('0x1e')](_0x37f3ea[_0x060f('0x19')]['include'],function(_0x342a9d){return{'model':db[_0x342a9d[_0x060f('0x20')]],'as':_0x342a9d['as'],'attributes':_0x342a9d[_0x060f('0x1c')],'include':_0x342a9d[_0x060f('0x1f')]?_['map'](_0x342a9d[_0x060f('0x1f')],function(_0x2ded74){return{'model':db[_0x2ded74[_0x060f('0x20')]],'as':_0x2ded74['as'],'attributes':_0x2ded74[_0x060f('0x1c')],'include':_0x2ded74[_0x060f('0x1f')]?_[_0x060f('0x1e')](_0x2ded74[_0x060f('0x1f')],function(_0x3caf05){return{'model':db[_0x3caf05[_0x060f('0x20')]],'as':_0x3caf05['as'],'attributes':_0x3caf05[_0x060f('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x060f('0xf')](function(_0x24df36){logger[_0x060f('0x10')](_0x060f('0x21'),_0x37f3ea);logger[_0x060f('0x13')](_0x060f('0x21'),_0x37f3ea,JSON[_0x060f('0x23')](_0x24df36));_0x31375d(_0x24df36);})[_0x060f('0x24')](function(_0x58ad44){logger['error'](_0x060f('0x21'),_0x58ad44[_0x060f('0x17')],_0x37f3ea);_0x178943(_0x227de8[_0x060f('0x15')](0x1f4,_0x58ad44['message']));});});};