Built motion from commit 00bf23f6.|2.6.16
[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 _0xc818=['http','request','then','info','FreshdeskAccount,\x20%s,\x20%s','request\x20sent','FreshdeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetFreshdeskAccount','findAll','options','where','attributes','limit','include','map','model','debug','ShowFreshdeskAccount','FreshdeskAccount','find','raw','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise'];(function(_0x397a02,_0x4accff){var _0x28dd05=function(_0xee9680){while(--_0xee9680){_0x397a02['push'](_0x397a02['shift']());}};_0x28dd05(++_0x4accff);}(_0xc818,0x1e3));var _0x8c81=function(_0x3531c7,_0x3140d9){_0x3531c7=_0x3531c7-0x0;var _0x167195=_0xc818[_0x3531c7];return _0x167195;};'use strict';var _=require(_0x8c81('0x0'));var util=require(_0x8c81('0x1'));var moment=require(_0x8c81('0x2'));var BPromise=require(_0x8c81('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x8c81('0x4'));var db=require(_0x8c81('0x5'))['db'];var utils=require(_0x8c81('0x6'));var logger=require(_0x8c81('0x7'))(_0x8c81('0x8'));var config=require(_0x8c81('0x9'));var jayson=require(_0x8c81('0xa'));var client=jayson['client'][_0x8c81('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x3d663e,_0x32cf31,_0x43d142){return new BPromise(function(_0x501240,_0x1173cf){return client[_0x8c81('0xc')](_0x3d663e,_0x43d142)[_0x8c81('0xd')](function(_0x15ebff){logger[_0x8c81('0xe')](_0x8c81('0xf'),_0x32cf31,_0x8c81('0x10'));logger['debug'](_0x8c81('0x11'),_0x32cf31,_0x8c81('0x10'),JSON[_0x8c81('0x12')](_0x15ebff));if(_0x15ebff[_0x8c81('0x13')]){if(_0x15ebff['error'][_0x8c81('0x14')]===0x1f4){logger[_0x8c81('0x13')](_0x8c81('0xf'),_0x32cf31,_0x15ebff[_0x8c81('0x13')][_0x8c81('0x15')]);return _0x1173cf(_0x15ebff[_0x8c81('0x13')][_0x8c81('0x15')]);}logger[_0x8c81('0x13')](_0x8c81('0xf'),_0x32cf31,_0x15ebff['error']['message']);return _0x501240(_0x15ebff[_0x8c81('0x13')][_0x8c81('0x15')]);}else{logger[_0x8c81('0xe')](_0x8c81('0xf'),_0x32cf31,_0x8c81('0x10'));_0x501240(_0x15ebff[_0x8c81('0x16')]['message']);}})[_0x8c81('0x17')](function(_0x29ccb0){logger[_0x8c81('0x13')](_0x8c81('0xf'),_0x32cf31,_0x29ccb0);_0x1173cf(_0x29ccb0);});});}exports[_0x8c81('0x18')]=function(_0x5c09f3){var _0x31069a=this;return new Promise(function(_0x4d0b75,_0x492d24){return db['FreshdeskAccount'][_0x8c81('0x19')]({'raw':_0x5c09f3[_0x8c81('0x1a')]?_0x5c09f3[_0x8c81('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x5c09f3[_0x8c81('0x1a')]?_0x5c09f3[_0x8c81('0x1a')][_0x8c81('0x1b')]||null:null,'attributes':_0x5c09f3['options']?_0x5c09f3[_0x8c81('0x1a')][_0x8c81('0x1c')]||null:null,'limit':_0x5c09f3['options']?_0x5c09f3[_0x8c81('0x1a')][_0x8c81('0x1d')]||null:null,'include':_0x5c09f3['options']?_0x5c09f3['options'][_0x8c81('0x1e')]?_[_0x8c81('0x1f')](_0x5c09f3[_0x8c81('0x1a')]['include'],function(_0x8c399c){return{'model':db[_0x8c399c[_0x8c81('0x20')]],'as':_0x8c399c['as'],'attributes':_0x8c399c[_0x8c81('0x1c')],'include':_0x8c399c[_0x8c81('0x1e')]?_[_0x8c81('0x1f')](_0x8c399c[_0x8c81('0x1e')],function(_0x2fcf75){return{'model':db[_0x2fcf75[_0x8c81('0x20')]],'as':_0x2fcf75['as'],'attributes':_0x2fcf75['attributes'],'include':_0x2fcf75['include']?_[_0x8c81('0x1f')](_0x2fcf75[_0x8c81('0x1e')],function(_0x2b9df6){return{'model':db[_0x2b9df6[_0x8c81('0x20')]],'as':_0x2b9df6['as'],'attributes':_0x2b9df6[_0x8c81('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x8c81('0xd')](function(_0x2e7ba2){logger[_0x8c81('0xe')](_0x8c81('0x18'),_0x5c09f3);logger[_0x8c81('0x21')](_0x8c81('0x18'),_0x5c09f3,JSON[_0x8c81('0x12')](_0x2e7ba2));_0x4d0b75(_0x2e7ba2);})[_0x8c81('0x17')](function(_0x59c7e8){logger[_0x8c81('0x13')](_0x8c81('0x18'),_0x59c7e8[_0x8c81('0x15')],_0x5c09f3);_0x492d24(_0x31069a[_0x8c81('0x13')](0x1f4,_0x59c7e8[_0x8c81('0x15')]));});});};exports[_0x8c81('0x22')]=function(_0xdf2029){var _0x2266fd=this;return new Promise(function(_0x2f419f,_0x54ca62){return db[_0x8c81('0x23')][_0x8c81('0x24')]({'raw':_0xdf2029[_0x8c81('0x1a')]?_0xdf2029[_0x8c81('0x1a')][_0x8c81('0x25')]===undefined?!![]:![]:!![],'where':_0xdf2029['options']?_0xdf2029[_0x8c81('0x1a')][_0x8c81('0x1b')]||null:null,'attributes':_0xdf2029[_0x8c81('0x1a')]?_0xdf2029[_0x8c81('0x1a')][_0x8c81('0x1c')]||null:null,'include':_0xdf2029['options']?_0xdf2029['options'][_0x8c81('0x1e')]?_[_0x8c81('0x1f')](_0xdf2029[_0x8c81('0x1a')]['include'],function(_0x3c8a5d){return{'model':db[_0x3c8a5d[_0x8c81('0x20')]],'as':_0x3c8a5d['as'],'attributes':_0x3c8a5d[_0x8c81('0x1c')],'include':_0x3c8a5d[_0x8c81('0x1e')]?_['map'](_0x3c8a5d[_0x8c81('0x1e')],function(_0x32dfaa){return{'model':db[_0x32dfaa['model']],'as':_0x32dfaa['as'],'attributes':_0x32dfaa[_0x8c81('0x1c')],'include':_0x32dfaa['include']?_['map'](_0x32dfaa[_0x8c81('0x1e')],function(_0x3f8dde){return{'model':db[_0x3f8dde[_0x8c81('0x20')]],'as':_0x3f8dde['as'],'attributes':_0x3f8dde[_0x8c81('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x30fa19){logger[_0x8c81('0xe')](_0x8c81('0x22'),_0xdf2029);logger['debug']('ShowFreshdeskAccount',_0xdf2029,JSON[_0x8c81('0x12')](_0x30fa19));_0x2f419f(_0x30fa19);})[_0x8c81('0x17')](function(_0x4373ce){logger['error'](_0x8c81('0x22'),_0x4373ce['message'],_0xdf2029);_0x54ca62(_0x2266fd['error'](0x1f4,_0x4373ce['message']));});});};