Built motion from commit c116dc8b.|2.6.30
[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 _0xbede=['raw','where','limit','include','model','map','attributes','then','ShowFreshdeskAccount','catch','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','info','FreshdeskAccount,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','result','GetFreshdeskAccount','FreshdeskAccount','options'];(function(_0x290d28,_0x459110){var _0x52f9df=function(_0x2665c5){while(--_0x2665c5){_0x290d28['push'](_0x290d28['shift']());}};_0x52f9df(++_0x459110);}(_0xbede,0xe2));var _0xebed=function(_0x9813e5,_0xaf50bf){_0x9813e5=_0x9813e5-0x0;var _0xde5a28=_0xbede[_0x9813e5];return _0xde5a28;};'use strict';var _=require(_0xebed('0x0'));var util=require(_0xebed('0x1'));var moment=require(_0xebed('0x2'));var BPromise=require(_0xebed('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xebed('0x4'));var db=require(_0xebed('0x5'))['db'];var utils=require(_0xebed('0x6'));var logger=require(_0xebed('0x7'))(_0xebed('0x8'));var config=require(_0xebed('0x9'));var jayson=require(_0xebed('0xa'));var client=jayson[_0xebed('0xb')][_0xebed('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x50e029,_0x28e6ad,_0x5a16a0){return new BPromise(function(_0x17a745,_0x4cca88){return client[_0xebed('0xd')](_0x50e029,_0x5a16a0)['then'](function(_0x4a7c71){logger[_0xebed('0xe')](_0xebed('0xf'),_0x28e6ad,'request\x20sent');logger[_0xebed('0x10')]('FreshdeskAccount,\x20%s,\x20%s,\x20%s',_0x28e6ad,_0xebed('0x11'),JSON[_0xebed('0x12')](_0x4a7c71));if(_0x4a7c71[_0xebed('0x13')]){if(_0x4a7c71['error'][_0xebed('0x14')]===0x1f4){logger['error']('FreshdeskAccount,\x20%s,\x20%s',_0x28e6ad,_0x4a7c71[_0xebed('0x13')]['message']);return _0x4cca88(_0x4a7c71[_0xebed('0x13')][_0xebed('0x15')]);}logger[_0xebed('0x13')](_0xebed('0xf'),_0x28e6ad,_0x4a7c71[_0xebed('0x13')][_0xebed('0x15')]);return _0x17a745(_0x4a7c71['error'][_0xebed('0x15')]);}else{logger[_0xebed('0xe')](_0xebed('0xf'),_0x28e6ad,_0xebed('0x11'));_0x17a745(_0x4a7c71[_0xebed('0x16')][_0xebed('0x15')]);}})['catch'](function(_0x39ff30){logger[_0xebed('0x13')](_0xebed('0xf'),_0x28e6ad,_0x39ff30);_0x4cca88(_0x39ff30);});});}exports[_0xebed('0x17')]=function(_0x44c30e){var _0x1d254a=this;return new Promise(function(_0x125db8,_0x2b2fdb){return db[_0xebed('0x18')]['findAll']({'raw':_0x44c30e['options']?_0x44c30e[_0xebed('0x19')][_0xebed('0x1a')]===undefined?!![]:![]:!![],'where':_0x44c30e[_0xebed('0x19')]?_0x44c30e[_0xebed('0x19')][_0xebed('0x1b')]||null:null,'attributes':_0x44c30e['options']?_0x44c30e[_0xebed('0x19')]['attributes']||null:null,'limit':_0x44c30e[_0xebed('0x19')]?_0x44c30e[_0xebed('0x19')][_0xebed('0x1c')]||null:null,'include':_0x44c30e['options']?_0x44c30e['options'][_0xebed('0x1d')]?_['map'](_0x44c30e[_0xebed('0x19')][_0xebed('0x1d')],function(_0x4907f2){return{'model':db[_0x4907f2[_0xebed('0x1e')]],'as':_0x4907f2['as'],'attributes':_0x4907f2['attributes'],'include':_0x4907f2['include']?_[_0xebed('0x1f')](_0x4907f2[_0xebed('0x1d')],function(_0x407553){return{'model':db[_0x407553['model']],'as':_0x407553['as'],'attributes':_0x407553[_0xebed('0x20')],'include':_0x407553[_0xebed('0x1d')]?_[_0xebed('0x1f')](_0x407553[_0xebed('0x1d')],function(_0x5ea0dd){return{'model':db[_0x5ea0dd['model']],'as':_0x5ea0dd['as'],'attributes':_0x5ea0dd['attributes']};}):[]};}):[]};}):[]:[]})[_0xebed('0x21')](function(_0x37763e){logger['info'](_0xebed('0x17'),_0x44c30e);logger['debug'](_0xebed('0x17'),_0x44c30e,JSON[_0xebed('0x12')](_0x37763e));_0x125db8(_0x37763e);})['catch'](function(_0x39672d){logger[_0xebed('0x13')](_0xebed('0x17'),_0x39672d[_0xebed('0x15')],_0x44c30e);_0x2b2fdb(_0x1d254a[_0xebed('0x13')](0x1f4,_0x39672d[_0xebed('0x15')]));});});};exports['ShowFreshdeskAccount']=function(_0x222e11){var _0x301e29=this;return new Promise(function(_0xab9d2f,_0x46bb69){return db[_0xebed('0x18')]['find']({'raw':_0x222e11[_0xebed('0x19')]?_0x222e11[_0xebed('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x222e11[_0xebed('0x19')]?_0x222e11[_0xebed('0x19')][_0xebed('0x1b')]||null:null,'attributes':_0x222e11[_0xebed('0x19')]?_0x222e11[_0xebed('0x19')]['attributes']||null:null,'include':_0x222e11[_0xebed('0x19')]?_0x222e11[_0xebed('0x19')]['include']?_[_0xebed('0x1f')](_0x222e11[_0xebed('0x19')][_0xebed('0x1d')],function(_0x1fc220){return{'model':db[_0x1fc220[_0xebed('0x1e')]],'as':_0x1fc220['as'],'attributes':_0x1fc220[_0xebed('0x20')],'include':_0x1fc220[_0xebed('0x1d')]?_[_0xebed('0x1f')](_0x1fc220[_0xebed('0x1d')],function(_0x90751){return{'model':db[_0x90751['model']],'as':_0x90751['as'],'attributes':_0x90751[_0xebed('0x20')],'include':_0x90751[_0xebed('0x1d')]?_[_0xebed('0x1f')](_0x90751[_0xebed('0x1d')],function(_0x2bb4dc){return{'model':db[_0x2bb4dc[_0xebed('0x1e')]],'as':_0x2bb4dc['as'],'attributes':_0x2bb4dc[_0xebed('0x20')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x25de48){logger[_0xebed('0xe')](_0xebed('0x22'),_0x222e11);logger[_0xebed('0x10')](_0xebed('0x22'),_0x222e11,JSON[_0xebed('0x12')](_0x25de48));_0xab9d2f(_0x25de48);})[_0xebed('0x23')](function(_0x49f17a){logger[_0xebed('0x13')](_0xebed('0x22'),_0x49f17a[_0xebed('0x15')],_0x222e11);_0x46bb69(_0x301e29[_0xebed('0x13')](0x1f4,_0x49f17a[_0xebed('0x15')]));});});};