e8ffb91e4c448cbf060812d1a9c25b894a9a78ea
[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 _0x2ea0=['ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','then','ZendeskAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','GetZendeskAccount','ZendeskAccount','findAll','options','raw','attributes','map','model','include','info','catch','ShowZendeskAccount','where','lodash','util','moment','bluebird'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x2ea0,0x80));var _0x02ea=function(_0x1e99d1,_0x38250c){_0x1e99d1=_0x1e99d1-0x0;var _0x3ae329=_0x2ea0[_0x1e99d1];return _0x3ae329;};'use strict';var _=require(_0x02ea('0x0'));var util=require(_0x02ea('0x1'));var moment=require(_0x02ea('0x2'));var BPromise=require(_0x02ea('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x02ea('0x4'));var db=require(_0x02ea('0x5'))['db'];var utils=require(_0x02ea('0x6'));var logger=require(_0x02ea('0x7'))(_0x02ea('0x8'));var config=require(_0x02ea('0x9'));var jayson=require(_0x02ea('0xa'));var client=jayson[_0x02ea('0xb')]['http']({'port':0x232a});function respondWithRpcPromise(_0x307b63,_0x380fde,_0x3b6b37){return new BPromise(function(_0x2cf414,_0x2fc188){return client[_0x02ea('0xc')](_0x307b63,_0x3b6b37)[_0x02ea('0xd')](function(_0x33e85c){logger['info'](_0x02ea('0xe'),_0x380fde,_0x02ea('0xf'));logger[_0x02ea('0x10')]('ZendeskAccount,\x20%s,\x20%s,\x20%s',_0x380fde,_0x02ea('0xf'),JSON[_0x02ea('0x11')](_0x33e85c));if(_0x33e85c[_0x02ea('0x12')]){if(_0x33e85c['error']['code']===0x1f4){logger[_0x02ea('0x12')](_0x02ea('0xe'),_0x380fde,_0x33e85c[_0x02ea('0x12')][_0x02ea('0x13')]);return _0x2fc188(_0x33e85c[_0x02ea('0x12')][_0x02ea('0x13')]);}logger[_0x02ea('0x12')](_0x02ea('0xe'),_0x380fde,_0x33e85c[_0x02ea('0x12')][_0x02ea('0x13')]);return _0x2cf414(_0x33e85c[_0x02ea('0x12')][_0x02ea('0x13')]);}else{logger['info'](_0x02ea('0xe'),_0x380fde,'request\x20sent');_0x2cf414(_0x33e85c['result']['message']);}})['catch'](function(_0x22735a){logger[_0x02ea('0x12')](_0x02ea('0xe'),_0x380fde,_0x22735a);_0x2fc188(_0x22735a);});});}exports[_0x02ea('0x14')]=function(_0xffda84){var _0xf5475f=this;return new Promise(function(_0x227197,_0x11f715){return db[_0x02ea('0x15')][_0x02ea('0x16')]({'raw':_0xffda84[_0x02ea('0x17')]?_0xffda84['options'][_0x02ea('0x18')]===undefined?!![]:![]:!![],'where':_0xffda84['options']?_0xffda84['options']['where']||null:null,'attributes':_0xffda84[_0x02ea('0x17')]?_0xffda84[_0x02ea('0x17')][_0x02ea('0x19')]||null:null,'limit':_0xffda84[_0x02ea('0x17')]?_0xffda84['options']['limit']||null:null,'include':_0xffda84[_0x02ea('0x17')]?_0xffda84['options']['include']?_[_0x02ea('0x1a')](_0xffda84[_0x02ea('0x17')]['include'],function(_0x48f65a){return{'model':db[_0x48f65a[_0x02ea('0x1b')]],'as':_0x48f65a['as'],'attributes':_0x48f65a['attributes'],'include':_0x48f65a[_0x02ea('0x1c')]?_[_0x02ea('0x1a')](_0x48f65a[_0x02ea('0x1c')],function(_0x31454f){return{'model':db[_0x31454f[_0x02ea('0x1b')]],'as':_0x31454f['as'],'attributes':_0x31454f[_0x02ea('0x19')],'include':_0x31454f[_0x02ea('0x1c')]?_[_0x02ea('0x1a')](_0x31454f[_0x02ea('0x1c')],function(_0x375303){return{'model':db[_0x375303[_0x02ea('0x1b')]],'as':_0x375303['as'],'attributes':_0x375303[_0x02ea('0x19')]};}):[]};}):[]};}):[]:[]})[_0x02ea('0xd')](function(_0x328018){logger[_0x02ea('0x1d')](_0x02ea('0x14'),_0xffda84);logger[_0x02ea('0x10')](_0x02ea('0x14'),_0xffda84,JSON[_0x02ea('0x11')](_0x328018));_0x227197(_0x328018);})[_0x02ea('0x1e')](function(_0x2360be){logger[_0x02ea('0x12')](_0x02ea('0x14'),_0x2360be[_0x02ea('0x13')],_0xffda84);_0x11f715(_0xf5475f[_0x02ea('0x12')](0x1f4,_0x2360be[_0x02ea('0x13')]));});});};exports[_0x02ea('0x1f')]=function(_0x30bd33){var _0x97e968=this;return new Promise(function(_0x3a413f,_0x4eef55){return db['ZendeskAccount']['find']({'raw':_0x30bd33['options']?_0x30bd33[_0x02ea('0x17')][_0x02ea('0x18')]===undefined?!![]:![]:!![],'where':_0x30bd33[_0x02ea('0x17')]?_0x30bd33[_0x02ea('0x17')][_0x02ea('0x20')]||null:null,'attributes':_0x30bd33[_0x02ea('0x17')]?_0x30bd33[_0x02ea('0x17')]['attributes']||null:null,'include':_0x30bd33[_0x02ea('0x17')]?_0x30bd33[_0x02ea('0x17')][_0x02ea('0x1c')]?_[_0x02ea('0x1a')](_0x30bd33[_0x02ea('0x17')][_0x02ea('0x1c')],function(_0x443d16){return{'model':db[_0x443d16[_0x02ea('0x1b')]],'as':_0x443d16['as'],'attributes':_0x443d16[_0x02ea('0x19')],'include':_0x443d16[_0x02ea('0x1c')]?_[_0x02ea('0x1a')](_0x443d16['include'],function(_0x405c1e){return{'model':db[_0x405c1e[_0x02ea('0x1b')]],'as':_0x405c1e['as'],'attributes':_0x405c1e[_0x02ea('0x19')],'include':_0x405c1e[_0x02ea('0x1c')]?_[_0x02ea('0x1a')](_0x405c1e[_0x02ea('0x1c')],function(_0x2023af){return{'model':db[_0x2023af[_0x02ea('0x1b')]],'as':_0x2023af['as'],'attributes':_0x2023af[_0x02ea('0x19')]};}):[]};}):[]};}):[]:[]})[_0x02ea('0xd')](function(_0x495fea){logger['info'](_0x02ea('0x1f'),_0x30bd33);logger[_0x02ea('0x10')](_0x02ea('0x1f'),_0x30bd33,JSON['stringify'](_0x495fea));_0x3a413f(_0x495fea);})[_0x02ea('0x1e')](function(_0x2f82f2){logger['error'](_0x02ea('0x1f'),_0x2f82f2[_0x02ea('0x13')],_0x30bd33);_0x4eef55(_0x97e968['error'](0x1f4,_0x2f82f2[_0x02ea('0x13')]));});});};