Built motion from commit (unavailable).|2.2.0
[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 _0x9ff0=['../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','ZendeskAccount,\x20%s,\x20%s','request\x20sent','debug','error','code','result','message','catch','GetZendeskAccount','ZendeskAccount','findAll','options','raw','where','limit','include','map','model','attributes','stringify','ShowZendeskAccount','find','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils'];(function(_0x26da5d,_0x506f9d){var _0x405935=function(_0x592f19){while(--_0x592f19){_0x26da5d['push'](_0x26da5d['shift']());}};_0x405935(++_0x506f9d);}(_0x9ff0,0x1c1));var _0x09ff=function(_0x22ed22,_0x2bd517){_0x22ed22=_0x22ed22-0x0;var _0x1448b=_0x9ff0[_0x22ed22];return _0x1448b;};'use strict';var _=require('lodash');var util=require(_0x09ff('0x0'));var moment=require(_0x09ff('0x1'));var BPromise=require(_0x09ff('0x2'));var rs=require(_0x09ff('0x3'));var fs=require('fs');var Redis=require(_0x09ff('0x4'));var db=require(_0x09ff('0x5'))['db'];var utils=require(_0x09ff('0x6'));var logger=require(_0x09ff('0x7'))(_0x09ff('0x8'));var config=require(_0x09ff('0x9'));var jayson=require(_0x09ff('0xa'));var client=jayson[_0x09ff('0xb')][_0x09ff('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x1a01c4,_0xbda2f0,_0x5d0997){return new BPromise(function(_0x14e3eb,_0x4e09c2){return client[_0x09ff('0xd')](_0x1a01c4,_0x5d0997)[_0x09ff('0xe')](function(_0x4ff719){logger[_0x09ff('0xf')](_0x09ff('0x10'),_0xbda2f0,_0x09ff('0x11'));logger[_0x09ff('0x12')]('ZendeskAccount,\x20%s,\x20%s,\x20%s',_0xbda2f0,_0x09ff('0x11'),JSON['stringify'](_0x4ff719));if(_0x4ff719[_0x09ff('0x13')]){if(_0x4ff719[_0x09ff('0x13')][_0x09ff('0x14')]===0x1f4){logger[_0x09ff('0x13')](_0x09ff('0x10'),_0xbda2f0,_0x4ff719['error']['message']);return _0x4e09c2(_0x4ff719[_0x09ff('0x13')]['message']);}logger[_0x09ff('0x13')]('ZendeskAccount,\x20%s,\x20%s',_0xbda2f0,_0x4ff719[_0x09ff('0x13')]['message']);return _0x14e3eb(_0x4ff719[_0x09ff('0x13')]['message']);}else{logger[_0x09ff('0xf')](_0x09ff('0x10'),_0xbda2f0,_0x09ff('0x11'));_0x14e3eb(_0x4ff719[_0x09ff('0x15')][_0x09ff('0x16')]);}})[_0x09ff('0x17')](function(_0x28772b){logger[_0x09ff('0x13')](_0x09ff('0x10'),_0xbda2f0,_0x28772b);_0x4e09c2(_0x28772b);});});}exports[_0x09ff('0x18')]=function(_0x3e63c3){var _0x526816=this;return new Promise(function(_0x2c21c7,_0x47475f){return db[_0x09ff('0x19')][_0x09ff('0x1a')]({'raw':_0x3e63c3[_0x09ff('0x1b')]?_0x3e63c3[_0x09ff('0x1b')][_0x09ff('0x1c')]===undefined?!![]:![]:!![],'where':_0x3e63c3[_0x09ff('0x1b')]?_0x3e63c3[_0x09ff('0x1b')][_0x09ff('0x1d')]||null:null,'attributes':_0x3e63c3[_0x09ff('0x1b')]?_0x3e63c3['options']['attributes']||null:null,'limit':_0x3e63c3[_0x09ff('0x1b')]?_0x3e63c3[_0x09ff('0x1b')][_0x09ff('0x1e')]||null:null,'include':_0x3e63c3['options']?_0x3e63c3[_0x09ff('0x1b')][_0x09ff('0x1f')]?_[_0x09ff('0x20')](_0x3e63c3[_0x09ff('0x1b')][_0x09ff('0x1f')],function(_0x9b5064){return{'model':db[_0x9b5064[_0x09ff('0x21')]],'as':_0x9b5064['as'],'attributes':_0x9b5064[_0x09ff('0x22')],'include':_0x9b5064['include']?_[_0x09ff('0x20')](_0x9b5064['include'],function(_0x2a5de6){return{'model':db[_0x2a5de6[_0x09ff('0x21')]],'as':_0x2a5de6['as'],'attributes':_0x2a5de6['attributes'],'include':_0x2a5de6[_0x09ff('0x1f')]?_[_0x09ff('0x20')](_0x2a5de6[_0x09ff('0x1f')],function(_0x32792b){return{'model':db[_0x32792b['model']],'as':_0x32792b['as'],'attributes':_0x32792b['attributes']};}):[]};}):[]};}):[]:[]})[_0x09ff('0xe')](function(_0x2500a3){logger[_0x09ff('0xf')](_0x09ff('0x18'),_0x3e63c3);logger['debug'](_0x09ff('0x18'),_0x3e63c3,JSON[_0x09ff('0x23')](_0x2500a3));_0x2c21c7(_0x2500a3);})[_0x09ff('0x17')](function(_0x3e0df2){logger[_0x09ff('0x13')](_0x09ff('0x18'),_0x3e0df2[_0x09ff('0x16')],_0x3e63c3);_0x47475f(_0x526816[_0x09ff('0x13')](0x1f4,_0x3e0df2[_0x09ff('0x16')]));});});};exports[_0x09ff('0x24')]=function(_0x49d2ed){var _0x37bd38=this;return new Promise(function(_0x2277ab,_0x2f5395){return db[_0x09ff('0x19')][_0x09ff('0x25')]({'raw':_0x49d2ed['options']?_0x49d2ed[_0x09ff('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x49d2ed[_0x09ff('0x1b')]?_0x49d2ed['options'][_0x09ff('0x1d')]||null:null,'attributes':_0x49d2ed[_0x09ff('0x1b')]?_0x49d2ed[_0x09ff('0x1b')][_0x09ff('0x22')]||null:null,'include':_0x49d2ed[_0x09ff('0x1b')]?_0x49d2ed['options'][_0x09ff('0x1f')]?_[_0x09ff('0x20')](_0x49d2ed['options'][_0x09ff('0x1f')],function(_0x284dcb){return{'model':db[_0x284dcb[_0x09ff('0x21')]],'as':_0x284dcb['as'],'attributes':_0x284dcb[_0x09ff('0x22')],'include':_0x284dcb[_0x09ff('0x1f')]?_[_0x09ff('0x20')](_0x284dcb['include'],function(_0x42c104){return{'model':db[_0x42c104[_0x09ff('0x21')]],'as':_0x42c104['as'],'attributes':_0x42c104[_0x09ff('0x22')],'include':_0x42c104[_0x09ff('0x1f')]?_['map'](_0x42c104[_0x09ff('0x1f')],function(_0x3625c7){return{'model':db[_0x3625c7[_0x09ff('0x21')]],'as':_0x3625c7['as'],'attributes':_0x3625c7['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x344f1c){logger['info'](_0x09ff('0x24'),_0x49d2ed);logger[_0x09ff('0x12')](_0x09ff('0x24'),_0x49d2ed,JSON[_0x09ff('0x23')](_0x344f1c));_0x2277ab(_0x344f1c);})[_0x09ff('0x17')](function(_0x47d2e7){logger[_0x09ff('0x13')](_0x09ff('0x24'),_0x47d2e7['message'],_0x49d2ed);_0x2f5395(_0x37bd38['error'](0x1f4,_0x47d2e7[_0x09ff('0x16')]));});});};