Built motion from commit (unavailable).|2.2.3
[motion2.git] / server / api / intFreshdeskAccount / intFreshdeskAccount.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 _0x42c5=['moment','bluebird','randomstring','ioredis','rpc','../../config/environment','jayson/promise','client','http','request','then','info','FreshdeskAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','GetFreshdeskAccount','FreshdeskAccount','findAll','options','where','attributes','limit','include','map','model','catch','ShowFreshdeskAccount','find','raw','util'];(function(_0x19b358,_0x563684){var _0x24cf91=function(_0x291c1d){while(--_0x291c1d){_0x19b358['push'](_0x19b358['shift']());}};_0x24cf91(++_0x563684);}(_0x42c5,0x117));var _0x542c=function(_0x4a7f39,_0x2153bc){_0x4a7f39=_0x4a7f39-0x0;var _0x3a708e=_0x42c5[_0x4a7f39];return _0x3a708e;};'use strict';var _=require('lodash');var util=require(_0x542c('0x0'));var moment=require(_0x542c('0x1'));var BPromise=require(_0x542c('0x2'));var rs=require(_0x542c('0x3'));var fs=require('fs');var Redis=require(_0x542c('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x542c('0x5'));var config=require(_0x542c('0x6'));var jayson=require(_0x542c('0x7'));var client=jayson[_0x542c('0x8')][_0x542c('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x5dddf8,_0x2a648c,_0x4d2427){return new BPromise(function(_0x30cf4f,_0x4636aa){return client[_0x542c('0xa')](_0x5dddf8,_0x4d2427)[_0x542c('0xb')](function(_0x5ab0b1){logger[_0x542c('0xc')](_0x542c('0xd'),_0x2a648c,_0x542c('0xe'));logger[_0x542c('0xf')]('FreshdeskAccount,\x20%s,\x20%s,\x20%s',_0x2a648c,_0x542c('0xe'),JSON[_0x542c('0x10')](_0x5ab0b1));if(_0x5ab0b1[_0x542c('0x11')]){if(_0x5ab0b1['error'][_0x542c('0x12')]===0x1f4){logger[_0x542c('0x11')](_0x542c('0xd'),_0x2a648c,_0x5ab0b1[_0x542c('0x11')][_0x542c('0x13')]);return _0x4636aa(_0x5ab0b1[_0x542c('0x11')]['message']);}logger['error']('FreshdeskAccount,\x20%s,\x20%s',_0x2a648c,_0x5ab0b1[_0x542c('0x11')]['message']);return _0x30cf4f(_0x5ab0b1[_0x542c('0x11')][_0x542c('0x13')]);}else{logger['info'](_0x542c('0xd'),_0x2a648c,_0x542c('0xe'));_0x30cf4f(_0x5ab0b1[_0x542c('0x14')]['message']);}})['catch'](function(_0x53e437){logger[_0x542c('0x11')](_0x542c('0xd'),_0x2a648c,_0x53e437);_0x4636aa(_0x53e437);});});}exports[_0x542c('0x15')]=function(_0x232b2c){var _0x3dc6a0=this;return new Promise(function(_0x55567a,_0x23cffb){return db[_0x542c('0x16')][_0x542c('0x17')]({'raw':_0x232b2c[_0x542c('0x18')]?_0x232b2c['options']['raw']===undefined?!![]:![]:!![],'where':_0x232b2c[_0x542c('0x18')]?_0x232b2c[_0x542c('0x18')][_0x542c('0x19')]||null:null,'attributes':_0x232b2c[_0x542c('0x18')]?_0x232b2c['options'][_0x542c('0x1a')]||null:null,'limit':_0x232b2c[_0x542c('0x18')]?_0x232b2c[_0x542c('0x18')][_0x542c('0x1b')]||null:null,'include':_0x232b2c['options']?_0x232b2c[_0x542c('0x18')][_0x542c('0x1c')]?_['map'](_0x232b2c[_0x542c('0x18')][_0x542c('0x1c')],function(_0x274fdb){return{'model':db[_0x274fdb['model']],'as':_0x274fdb['as'],'attributes':_0x274fdb[_0x542c('0x1a')],'include':_0x274fdb[_0x542c('0x1c')]?_[_0x542c('0x1d')](_0x274fdb[_0x542c('0x1c')],function(_0x230ff0){return{'model':db[_0x230ff0[_0x542c('0x1e')]],'as':_0x230ff0['as'],'attributes':_0x230ff0[_0x542c('0x1a')],'include':_0x230ff0['include']?_[_0x542c('0x1d')](_0x230ff0[_0x542c('0x1c')],function(_0x47a368){return{'model':db[_0x47a368[_0x542c('0x1e')]],'as':_0x47a368['as'],'attributes':_0x47a368[_0x542c('0x1a')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x27f55b){logger[_0x542c('0xc')](_0x542c('0x15'),_0x232b2c);logger[_0x542c('0xf')](_0x542c('0x15'),_0x232b2c,JSON[_0x542c('0x10')](_0x27f55b));_0x55567a(_0x27f55b);})[_0x542c('0x1f')](function(_0x6263e1){logger['error'](_0x542c('0x15'),_0x6263e1[_0x542c('0x13')],_0x232b2c);_0x23cffb(_0x3dc6a0[_0x542c('0x11')](0x1f4,_0x6263e1[_0x542c('0x13')]));});});};exports[_0x542c('0x20')]=function(_0x393841){var _0xb88025=this;return new Promise(function(_0x36fd0f,_0x22002b){return db[_0x542c('0x16')][_0x542c('0x21')]({'raw':_0x393841[_0x542c('0x18')]?_0x393841[_0x542c('0x18')][_0x542c('0x22')]===undefined?!![]:![]:!![],'where':_0x393841['options']?_0x393841['options'][_0x542c('0x19')]||null:null,'attributes':_0x393841[_0x542c('0x18')]?_0x393841[_0x542c('0x18')][_0x542c('0x1a')]||null:null,'include':_0x393841[_0x542c('0x18')]?_0x393841[_0x542c('0x18')][_0x542c('0x1c')]?_[_0x542c('0x1d')](_0x393841[_0x542c('0x18')][_0x542c('0x1c')],function(_0xe3f1cd){return{'model':db[_0xe3f1cd[_0x542c('0x1e')]],'as':_0xe3f1cd['as'],'attributes':_0xe3f1cd['attributes'],'include':_0xe3f1cd[_0x542c('0x1c')]?_[_0x542c('0x1d')](_0xe3f1cd[_0x542c('0x1c')],function(_0x5ee5c5){return{'model':db[_0x5ee5c5[_0x542c('0x1e')]],'as':_0x5ee5c5['as'],'attributes':_0x5ee5c5[_0x542c('0x1a')],'include':_0x5ee5c5[_0x542c('0x1c')]?_[_0x542c('0x1d')](_0x5ee5c5[_0x542c('0x1c')],function(_0xbce31a){return{'model':db[_0xbce31a[_0x542c('0x1e')]],'as':_0xbce31a['as'],'attributes':_0xbce31a[_0x542c('0x1a')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1b45ca){logger[_0x542c('0xc')](_0x542c('0x20'),_0x393841);logger['debug'](_0x542c('0x20'),_0x393841,JSON['stringify'](_0x1b45ca));_0x36fd0f(_0x1b45ca);})[_0x542c('0x1f')](function(_0x4a1a08){logger[_0x542c('0x11')]('ShowFreshdeskAccount',_0x4a1a08[_0x542c('0x13')],_0x393841);_0x22002b(_0xb88025[_0x542c('0x11')](0x1f4,_0x4a1a08['message']));});});};