0b9817dbeff6237c52aaa8a4489053fb328077b5
[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 _0x6ac2=['find','raw','ShowZohoAccount','debug','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','jayson/promise','client','http','info','ZohoAccount,\x20%s,\x20%s','request\x20sent','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','GetZohoAccount','ZohoAccount','options','attributes','limit','include','model','map','then'];(function(_0x2bf141,_0x31eac7){var _0x48277b=function(_0x9fe560){while(--_0x9fe560){_0x2bf141['push'](_0x2bf141['shift']());}};_0x48277b(++_0x31eac7);}(_0x6ac2,0x184));var _0x26ac=function(_0x3974f1,_0x1e3709){_0x3974f1=_0x3974f1-0x0;var _0x2b9f50=_0x6ac2[_0x3974f1];return _0x2b9f50;};'use strict';var _=require(_0x26ac('0x0'));var util=require('util');var moment=require(_0x26ac('0x1'));var BPromise=require(_0x26ac('0x2'));var rs=require(_0x26ac('0x3'));var fs=require('fs');var Redis=require(_0x26ac('0x4'));var db=require(_0x26ac('0x5'))['db'];var utils=require(_0x26ac('0x6'));var logger=require('../../config/logger')(_0x26ac('0x7'));var config=require('../../config/environment');var jayson=require(_0x26ac('0x8'));var client=jayson[_0x26ac('0x9')][_0x26ac('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x159ba6,_0x36389c,_0x444ca1){return new BPromise(function(_0x1906d0,_0xd8b1e5){return client['request'](_0x159ba6,_0x444ca1)['then'](function(_0x27ff15){logger[_0x26ac('0xb')](_0x26ac('0xc'),_0x36389c,_0x26ac('0xd'));logger['debug'](_0x26ac('0xe'),_0x36389c,_0x26ac('0xd'),JSON[_0x26ac('0xf')](_0x27ff15));if(_0x27ff15[_0x26ac('0x10')]){if(_0x27ff15['error']['code']===0x1f4){logger[_0x26ac('0x10')](_0x26ac('0xc'),_0x36389c,_0x27ff15[_0x26ac('0x10')][_0x26ac('0x11')]);return _0xd8b1e5(_0x27ff15[_0x26ac('0x10')][_0x26ac('0x11')]);}logger[_0x26ac('0x10')]('ZohoAccount,\x20%s,\x20%s',_0x36389c,_0x27ff15[_0x26ac('0x10')][_0x26ac('0x11')]);return _0x1906d0(_0x27ff15[_0x26ac('0x10')][_0x26ac('0x11')]);}else{logger['info'](_0x26ac('0xc'),_0x36389c,_0x26ac('0xd'));_0x1906d0(_0x27ff15['result'][_0x26ac('0x11')]);}})[_0x26ac('0x12')](function(_0x3b7c5d){logger[_0x26ac('0x10')]('ZohoAccount,\x20%s,\x20%s',_0x36389c,_0x3b7c5d);_0xd8b1e5(_0x3b7c5d);});});}exports[_0x26ac('0x13')]=function(_0xb03bbc){var _0x5cd737=this;return new Promise(function(_0x539eda,_0x111613){return db[_0x26ac('0x14')]['findAll']({'raw':_0xb03bbc[_0x26ac('0x15')]?_0xb03bbc['options']['raw']===undefined?!![]:![]:!![],'where':_0xb03bbc['options']?_0xb03bbc[_0x26ac('0x15')]['where']||null:null,'attributes':_0xb03bbc[_0x26ac('0x15')]?_0xb03bbc[_0x26ac('0x15')][_0x26ac('0x16')]||null:null,'limit':_0xb03bbc[_0x26ac('0x15')]?_0xb03bbc[_0x26ac('0x15')][_0x26ac('0x17')]||null:null,'include':_0xb03bbc[_0x26ac('0x15')]?_0xb03bbc[_0x26ac('0x15')][_0x26ac('0x18')]?_['map'](_0xb03bbc[_0x26ac('0x15')][_0x26ac('0x18')],function(_0x2b8299){return{'model':db[_0x2b8299[_0x26ac('0x19')]],'as':_0x2b8299['as'],'attributes':_0x2b8299[_0x26ac('0x16')],'include':_0x2b8299[_0x26ac('0x18')]?_[_0x26ac('0x1a')](_0x2b8299[_0x26ac('0x18')],function(_0x4172c2){return{'model':db[_0x4172c2[_0x26ac('0x19')]],'as':_0x4172c2['as'],'attributes':_0x4172c2['attributes'],'include':_0x4172c2['include']?_[_0x26ac('0x1a')](_0x4172c2['include'],function(_0x185296){return{'model':db[_0x185296[_0x26ac('0x19')]],'as':_0x185296['as'],'attributes':_0x185296[_0x26ac('0x16')]};}):[]};}):[]};}):[]:[]})[_0x26ac('0x1b')](function(_0x31cb17){logger[_0x26ac('0xb')]('GetZohoAccount',_0xb03bbc);logger['debug'](_0x26ac('0x13'),_0xb03bbc,JSON[_0x26ac('0xf')](_0x31cb17));_0x539eda(_0x31cb17);})[_0x26ac('0x12')](function(_0x4d873e){logger['error'](_0x26ac('0x13'),_0x4d873e[_0x26ac('0x11')],_0xb03bbc);_0x111613(_0x5cd737[_0x26ac('0x10')](0x1f4,_0x4d873e[_0x26ac('0x11')]));});});};exports['ShowZohoAccount']=function(_0x5e1cbc){var _0x3ea2f0=this;return new Promise(function(_0x3e2148,_0x17691a){return db[_0x26ac('0x14')][_0x26ac('0x1c')]({'raw':_0x5e1cbc[_0x26ac('0x15')]?_0x5e1cbc[_0x26ac('0x15')][_0x26ac('0x1d')]===undefined?!![]:![]:!![],'where':_0x5e1cbc[_0x26ac('0x15')]?_0x5e1cbc[_0x26ac('0x15')]['where']||null:null,'attributes':_0x5e1cbc[_0x26ac('0x15')]?_0x5e1cbc[_0x26ac('0x15')]['attributes']||null:null,'include':_0x5e1cbc[_0x26ac('0x15')]?_0x5e1cbc[_0x26ac('0x15')][_0x26ac('0x18')]?_[_0x26ac('0x1a')](_0x5e1cbc[_0x26ac('0x15')][_0x26ac('0x18')],function(_0x375f83){return{'model':db[_0x375f83[_0x26ac('0x19')]],'as':_0x375f83['as'],'attributes':_0x375f83[_0x26ac('0x16')],'include':_0x375f83[_0x26ac('0x18')]?_[_0x26ac('0x1a')](_0x375f83[_0x26ac('0x18')],function(_0x583109){return{'model':db[_0x583109[_0x26ac('0x19')]],'as':_0x583109['as'],'attributes':_0x583109[_0x26ac('0x16')],'include':_0x583109[_0x26ac('0x18')]?_['map'](_0x583109[_0x26ac('0x18')],function(_0x4a842a){return{'model':db[_0x4a842a[_0x26ac('0x19')]],'as':_0x4a842a['as'],'attributes':_0x4a842a[_0x26ac('0x16')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x66dc0c){logger[_0x26ac('0xb')](_0x26ac('0x1e'),_0x5e1cbc);logger[_0x26ac('0x1f')](_0x26ac('0x1e'),_0x5e1cbc,JSON[_0x26ac('0xf')](_0x66dc0c));_0x3e2148(_0x66dc0c);})['catch'](function(_0x76f6c4){logger['error'](_0x26ac('0x1e'),_0x76f6c4['message'],_0x5e1cbc);_0x17691a(_0x3ea2f0[_0x26ac('0x10')](0x1f4,_0x76f6c4['message']));});});};