Built motion from commit 9d0783e6.|2.6.13
[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 _0x5a93=['limit','include','model','stringify','ShowZendeskAccount','find','raw','map','util','bluebird','randomstring','../../config/utils','../../config/logger','rpc','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','catch','GetZendeskAccount','ZendeskAccount','findAll','options','where','attributes'];(function(_0x16771d,_0x224c60){var _0x386f11=function(_0x3d7a87){while(--_0x3d7a87){_0x16771d['push'](_0x16771d['shift']());}};_0x386f11(++_0x224c60);}(_0x5a93,0xf6));var _0x35a9=function(_0x357b0d,_0x10aeaa){_0x357b0d=_0x357b0d-0x0;var _0x3c48e9=_0x5a93[_0x357b0d];return _0x3c48e9;};'use strict';var _=require('lodash');var util=require(_0x35a9('0x0'));var moment=require('moment');var BPromise=require(_0x35a9('0x1'));var rs=require(_0x35a9('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x35a9('0x3'));var logger=require(_0x35a9('0x4'))(_0x35a9('0x5'));var config=require('../../config/environment');var jayson=require(_0x35a9('0x6'));var client=jayson[_0x35a9('0x7')][_0x35a9('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x354490,_0x271228,_0x45e6f7){return new BPromise(function(_0x71d143,_0x22d770){return client[_0x35a9('0x9')](_0x354490,_0x45e6f7)[_0x35a9('0xa')](function(_0x5b4f25){logger[_0x35a9('0xb')](_0x35a9('0xc'),_0x271228,_0x35a9('0xd'));logger[_0x35a9('0xe')](_0x35a9('0xf'),_0x271228,_0x35a9('0xd'),JSON['stringify'](_0x5b4f25));if(_0x5b4f25[_0x35a9('0x10')]){if(_0x5b4f25[_0x35a9('0x10')][_0x35a9('0x11')]===0x1f4){logger[_0x35a9('0x10')]('ZendeskAccount,\x20%s,\x20%s',_0x271228,_0x5b4f25[_0x35a9('0x10')][_0x35a9('0x12')]);return _0x22d770(_0x5b4f25[_0x35a9('0x10')][_0x35a9('0x12')]);}logger['error'](_0x35a9('0xc'),_0x271228,_0x5b4f25[_0x35a9('0x10')][_0x35a9('0x12')]);return _0x71d143(_0x5b4f25[_0x35a9('0x10')]['message']);}else{logger[_0x35a9('0xb')](_0x35a9('0xc'),_0x271228,_0x35a9('0xd'));_0x71d143(_0x5b4f25['result'][_0x35a9('0x12')]);}})[_0x35a9('0x13')](function(_0x14eeb5){logger[_0x35a9('0x10')](_0x35a9('0xc'),_0x271228,_0x14eeb5);_0x22d770(_0x14eeb5);});});}exports[_0x35a9('0x14')]=function(_0x56f31f){var _0x152086=this;return new Promise(function(_0x4490d5,_0x36f0fe){return db[_0x35a9('0x15')][_0x35a9('0x16')]({'raw':_0x56f31f['options']?_0x56f31f[_0x35a9('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x56f31f[_0x35a9('0x17')]?_0x56f31f[_0x35a9('0x17')][_0x35a9('0x18')]||null:null,'attributes':_0x56f31f[_0x35a9('0x17')]?_0x56f31f[_0x35a9('0x17')][_0x35a9('0x19')]||null:null,'limit':_0x56f31f[_0x35a9('0x17')]?_0x56f31f[_0x35a9('0x17')][_0x35a9('0x1a')]||null:null,'include':_0x56f31f['options']?_0x56f31f[_0x35a9('0x17')][_0x35a9('0x1b')]?_['map'](_0x56f31f['options'][_0x35a9('0x1b')],function(_0x1dd1ab){return{'model':db[_0x1dd1ab[_0x35a9('0x1c')]],'as':_0x1dd1ab['as'],'attributes':_0x1dd1ab[_0x35a9('0x19')],'include':_0x1dd1ab[_0x35a9('0x1b')]?_['map'](_0x1dd1ab[_0x35a9('0x1b')],function(_0xc31cd1){return{'model':db[_0xc31cd1[_0x35a9('0x1c')]],'as':_0xc31cd1['as'],'attributes':_0xc31cd1[_0x35a9('0x19')],'include':_0xc31cd1[_0x35a9('0x1b')]?_['map'](_0xc31cd1['include'],function(_0x5dfc9f){return{'model':db[_0x5dfc9f[_0x35a9('0x1c')]],'as':_0x5dfc9f['as'],'attributes':_0x5dfc9f['attributes']};}):[]};}):[]};}):[]:[]})[_0x35a9('0xa')](function(_0x15eada){logger['info'](_0x35a9('0x14'),_0x56f31f);logger['debug'](_0x35a9('0x14'),_0x56f31f,JSON[_0x35a9('0x1d')](_0x15eada));_0x4490d5(_0x15eada);})['catch'](function(_0x534455){logger[_0x35a9('0x10')](_0x35a9('0x14'),_0x534455[_0x35a9('0x12')],_0x56f31f);_0x36f0fe(_0x152086[_0x35a9('0x10')](0x1f4,_0x534455[_0x35a9('0x12')]));});});};exports[_0x35a9('0x1e')]=function(_0x145cc6){var _0x246316=this;return new Promise(function(_0x52c9c9,_0x39fa5a){return db[_0x35a9('0x15')][_0x35a9('0x1f')]({'raw':_0x145cc6[_0x35a9('0x17')]?_0x145cc6[_0x35a9('0x17')][_0x35a9('0x20')]===undefined?!![]:![]:!![],'where':_0x145cc6['options']?_0x145cc6[_0x35a9('0x17')][_0x35a9('0x18')]||null:null,'attributes':_0x145cc6[_0x35a9('0x17')]?_0x145cc6['options'][_0x35a9('0x19')]||null:null,'include':_0x145cc6['options']?_0x145cc6[_0x35a9('0x17')][_0x35a9('0x1b')]?_[_0x35a9('0x21')](_0x145cc6[_0x35a9('0x17')][_0x35a9('0x1b')],function(_0x28e8c8){return{'model':db[_0x28e8c8['model']],'as':_0x28e8c8['as'],'attributes':_0x28e8c8['attributes'],'include':_0x28e8c8[_0x35a9('0x1b')]?_[_0x35a9('0x21')](_0x28e8c8['include'],function(_0x5771ed){return{'model':db[_0x5771ed[_0x35a9('0x1c')]],'as':_0x5771ed['as'],'attributes':_0x5771ed['attributes'],'include':_0x5771ed['include']?_['map'](_0x5771ed[_0x35a9('0x1b')],function(_0x37f2fb){return{'model':db[_0x37f2fb['model']],'as':_0x37f2fb['as'],'attributes':_0x37f2fb[_0x35a9('0x19')]};}):[]};}):[]};}):[]:[]})[_0x35a9('0xa')](function(_0x3695f1){logger[_0x35a9('0xb')]('ShowZendeskAccount',_0x145cc6);logger[_0x35a9('0xe')](_0x35a9('0x1e'),_0x145cc6,JSON[_0x35a9('0x1d')](_0x3695f1));_0x52c9c9(_0x3695f1);})[_0x35a9('0x13')](function(_0x4710ac){logger['error']('ShowZendeskAccount',_0x4710ac[_0x35a9('0x12')],_0x145cc6);_0x39fa5a(_0x246316['error'](0x1f4,_0x4710ac[_0x35a9('0x12')]));});});};