Built motion from commit (unavailable).|2.5.3
[motion2.git] / server / api / intZohoAccount / intZohoAccount.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 _0xaf6b=['ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','GetZohoAccount','ZohoAccount','findAll','options','raw','where','limit','include','map','model','attributes','catch','ShowZohoAccount','lodash','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','ZohoAccount,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xaf6b,0x19e));var _0xbaf6=function(_0xc2676a,_0x1de08e){_0xc2676a=_0xc2676a-0x0;var _0x10e5df=_0xaf6b[_0xc2676a];return _0x10e5df;};'use strict';var _=require(_0xbaf6('0x0'));var util=require('util');var moment=require(_0xbaf6('0x1'));var BPromise=require(_0xbaf6('0x2'));var rs=require(_0xbaf6('0x3'));var fs=require('fs');var Redis=require(_0xbaf6('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xbaf6('0x5'));var logger=require(_0xbaf6('0x6'))(_0xbaf6('0x7'));var config=require(_0xbaf6('0x8'));var jayson=require(_0xbaf6('0x9'));var client=jayson[_0xbaf6('0xa')][_0xbaf6('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x25bbb6,_0x50437e,_0x14187e){return new BPromise(function(_0x248780,_0x4efcd2){return client[_0xbaf6('0xc')](_0x25bbb6,_0x14187e)[_0xbaf6('0xd')](function(_0x43b917){logger[_0xbaf6('0xe')](_0xbaf6('0xf'),_0x50437e,_0xbaf6('0x10'));logger[_0xbaf6('0x11')](_0xbaf6('0x12'),_0x50437e,_0xbaf6('0x10'),JSON[_0xbaf6('0x13')](_0x43b917));if(_0x43b917[_0xbaf6('0x14')]){if(_0x43b917['error'][_0xbaf6('0x15')]===0x1f4){logger['error']('ZohoAccount,\x20%s,\x20%s',_0x50437e,_0x43b917[_0xbaf6('0x14')][_0xbaf6('0x16')]);return _0x4efcd2(_0x43b917[_0xbaf6('0x14')][_0xbaf6('0x16')]);}logger[_0xbaf6('0x14')](_0xbaf6('0xf'),_0x50437e,_0x43b917[_0xbaf6('0x14')][_0xbaf6('0x16')]);return _0x248780(_0x43b917[_0xbaf6('0x14')][_0xbaf6('0x16')]);}else{logger['info'](_0xbaf6('0xf'),_0x50437e,_0xbaf6('0x10'));_0x248780(_0x43b917['result']['message']);}})['catch'](function(_0x11f278){logger[_0xbaf6('0x14')](_0xbaf6('0xf'),_0x50437e,_0x11f278);_0x4efcd2(_0x11f278);});});}exports[_0xbaf6('0x17')]=function(_0x2e1392){var _0x93d9d8=this;return new Promise(function(_0xabcf67,_0x1d3b9e){return db[_0xbaf6('0x18')][_0xbaf6('0x19')]({'raw':_0x2e1392[_0xbaf6('0x1a')]?_0x2e1392[_0xbaf6('0x1a')][_0xbaf6('0x1b')]===undefined?!![]:![]:!![],'where':_0x2e1392[_0xbaf6('0x1a')]?_0x2e1392['options'][_0xbaf6('0x1c')]||null:null,'attributes':_0x2e1392[_0xbaf6('0x1a')]?_0x2e1392[_0xbaf6('0x1a')]['attributes']||null:null,'limit':_0x2e1392[_0xbaf6('0x1a')]?_0x2e1392['options'][_0xbaf6('0x1d')]||null:null,'include':_0x2e1392['options']?_0x2e1392[_0xbaf6('0x1a')][_0xbaf6('0x1e')]?_[_0xbaf6('0x1f')](_0x2e1392[_0xbaf6('0x1a')][_0xbaf6('0x1e')],function(_0x170263){return{'model':db[_0x170263[_0xbaf6('0x20')]],'as':_0x170263['as'],'attributes':_0x170263[_0xbaf6('0x21')],'include':_0x170263[_0xbaf6('0x1e')]?_['map'](_0x170263[_0xbaf6('0x1e')],function(_0x2b9368){return{'model':db[_0x2b9368[_0xbaf6('0x20')]],'as':_0x2b9368['as'],'attributes':_0x2b9368[_0xbaf6('0x21')],'include':_0x2b9368[_0xbaf6('0x1e')]?_[_0xbaf6('0x1f')](_0x2b9368[_0xbaf6('0x1e')],function(_0x5a60b0){return{'model':db[_0x5a60b0[_0xbaf6('0x20')]],'as':_0x5a60b0['as'],'attributes':_0x5a60b0['attributes']};}):[]};}):[]};}):[]:[]})[_0xbaf6('0xd')](function(_0x297c17){logger[_0xbaf6('0xe')](_0xbaf6('0x17'),_0x2e1392);logger[_0xbaf6('0x11')]('GetZohoAccount',_0x2e1392,JSON['stringify'](_0x297c17));_0xabcf67(_0x297c17);})[_0xbaf6('0x22')](function(_0x3709bd){logger[_0xbaf6('0x14')](_0xbaf6('0x17'),_0x3709bd['message'],_0x2e1392);_0x1d3b9e(_0x93d9d8[_0xbaf6('0x14')](0x1f4,_0x3709bd['message']));});});};exports['ShowZohoAccount']=function(_0x5eeecc){var _0x50d447=this;return new Promise(function(_0x1af3e1,_0x196841){return db[_0xbaf6('0x18')]['find']({'raw':_0x5eeecc[_0xbaf6('0x1a')]?_0x5eeecc['options'][_0xbaf6('0x1b')]===undefined?!![]:![]:!![],'where':_0x5eeecc['options']?_0x5eeecc[_0xbaf6('0x1a')]['where']||null:null,'attributes':_0x5eeecc['options']?_0x5eeecc[_0xbaf6('0x1a')]['attributes']||null:null,'include':_0x5eeecc[_0xbaf6('0x1a')]?_0x5eeecc[_0xbaf6('0x1a')]['include']?_[_0xbaf6('0x1f')](_0x5eeecc['options'][_0xbaf6('0x1e')],function(_0x4a3452){return{'model':db[_0x4a3452[_0xbaf6('0x20')]],'as':_0x4a3452['as'],'attributes':_0x4a3452[_0xbaf6('0x21')],'include':_0x4a3452['include']?_['map'](_0x4a3452[_0xbaf6('0x1e')],function(_0xc768fb){return{'model':db[_0xc768fb[_0xbaf6('0x20')]],'as':_0xc768fb['as'],'attributes':_0xc768fb[_0xbaf6('0x21')],'include':_0xc768fb[_0xbaf6('0x1e')]?_[_0xbaf6('0x1f')](_0xc768fb[_0xbaf6('0x1e')],function(_0x41a08f){return{'model':db[_0x41a08f['model']],'as':_0x41a08f['as'],'attributes':_0x41a08f[_0xbaf6('0x21')]};}):[]};}):[]};}):[]:[]})[_0xbaf6('0xd')](function(_0x240b94){logger['info']('ShowZohoAccount',_0x5eeecc);logger['debug']('ShowZohoAccount',_0x5eeecc,JSON[_0xbaf6('0x13')](_0x240b94));_0x1af3e1(_0x240b94);})[_0xbaf6('0x22')](function(_0x26e535){logger['error'](_0xbaf6('0x23'),_0x26e535[_0xbaf6('0x16')],_0x5eeecc);_0x196841(_0x50d447[_0xbaf6('0x14')](0x1f4,_0x26e535['message']));});});};