938bb4dd7a8e161e4446724360992477ab9a05a1
[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 _0x2aa3=['jayson/promise','http','request','then','info','request\x20sent','debug','ZohoAccount,\x20%s,\x20%s,\x20%s','error','code','ZohoAccount,\x20%s,\x20%s','message','catch','options','raw','where','attributes','limit','include','map','model','GetZohoAccount','stringify','ShowZohoAccount','ZohoAccount','find','lodash','util','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment'];(function(_0x139e39,_0x1b3f77){var _0x8e1bd7=function(_0x26a921){while(--_0x26a921){_0x139e39['push'](_0x139e39['shift']());}};_0x8e1bd7(++_0x1b3f77);}(_0x2aa3,0x83));var _0x32aa=function(_0x3ad8d7,_0x225758){_0x3ad8d7=_0x3ad8d7-0x0;var _0xa4047c=_0x2aa3[_0x3ad8d7];return _0xa4047c;};'use strict';var _=require(_0x32aa('0x0'));var util=require(_0x32aa('0x1'));var moment=require(_0x32aa('0x2'));var BPromise=require(_0x32aa('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x32aa('0x4'))['db'];var utils=require(_0x32aa('0x5'));var logger=require(_0x32aa('0x6'))(_0x32aa('0x7'));var config=require(_0x32aa('0x8'));var jayson=require(_0x32aa('0x9'));var client=jayson['client'][_0x32aa('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x112396,_0x3ee18a,_0x20efbe){return new BPromise(function(_0x18ded0,_0x40c96a){return client[_0x32aa('0xb')](_0x112396,_0x20efbe)[_0x32aa('0xc')](function(_0x5d280e){logger[_0x32aa('0xd')]('ZohoAccount,\x20%s,\x20%s',_0x3ee18a,_0x32aa('0xe'));logger[_0x32aa('0xf')](_0x32aa('0x10'),_0x3ee18a,_0x32aa('0xe'),JSON['stringify'](_0x5d280e));if(_0x5d280e[_0x32aa('0x11')]){if(_0x5d280e[_0x32aa('0x11')][_0x32aa('0x12')]===0x1f4){logger['error'](_0x32aa('0x13'),_0x3ee18a,_0x5d280e[_0x32aa('0x11')][_0x32aa('0x14')]);return _0x40c96a(_0x5d280e[_0x32aa('0x11')][_0x32aa('0x14')]);}logger[_0x32aa('0x11')](_0x32aa('0x13'),_0x3ee18a,_0x5d280e[_0x32aa('0x11')]['message']);return _0x18ded0(_0x5d280e[_0x32aa('0x11')][_0x32aa('0x14')]);}else{logger[_0x32aa('0xd')](_0x32aa('0x13'),_0x3ee18a,_0x32aa('0xe'));_0x18ded0(_0x5d280e['result'][_0x32aa('0x14')]);}})[_0x32aa('0x15')](function(_0x463b91){logger[_0x32aa('0x11')](_0x32aa('0x13'),_0x3ee18a,_0x463b91);_0x40c96a(_0x463b91);});});}exports['GetZohoAccount']=function(_0x5196c0){var _0x3e0a23=this;return new Promise(function(_0x34dcaf,_0x257be0){return db['ZohoAccount']['findAll']({'raw':_0x5196c0[_0x32aa('0x16')]?_0x5196c0[_0x32aa('0x16')][_0x32aa('0x17')]===undefined?!![]:![]:!![],'where':_0x5196c0[_0x32aa('0x16')]?_0x5196c0[_0x32aa('0x16')][_0x32aa('0x18')]||null:null,'attributes':_0x5196c0['options']?_0x5196c0[_0x32aa('0x16')][_0x32aa('0x19')]||null:null,'limit':_0x5196c0[_0x32aa('0x16')]?_0x5196c0[_0x32aa('0x16')][_0x32aa('0x1a')]||null:null,'include':_0x5196c0[_0x32aa('0x16')]?_0x5196c0[_0x32aa('0x16')][_0x32aa('0x1b')]?_[_0x32aa('0x1c')](_0x5196c0['options'][_0x32aa('0x1b')],function(_0x5c82d2){return{'model':db[_0x5c82d2[_0x32aa('0x1d')]],'as':_0x5c82d2['as'],'attributes':_0x5c82d2[_0x32aa('0x19')],'include':_0x5c82d2['include']?_['map'](_0x5c82d2[_0x32aa('0x1b')],function(_0x313930){return{'model':db[_0x313930[_0x32aa('0x1d')]],'as':_0x313930['as'],'attributes':_0x313930[_0x32aa('0x19')],'include':_0x313930[_0x32aa('0x1b')]?_[_0x32aa('0x1c')](_0x313930[_0x32aa('0x1b')],function(_0x405b03){return{'model':db[_0x405b03[_0x32aa('0x1d')]],'as':_0x405b03['as'],'attributes':_0x405b03['attributes']};}):[]};}):[]};}):[]:[]})[_0x32aa('0xc')](function(_0x2e3a5d){logger['info'](_0x32aa('0x1e'),_0x5196c0);logger['debug']('GetZohoAccount',_0x5196c0,JSON[_0x32aa('0x1f')](_0x2e3a5d));_0x34dcaf(_0x2e3a5d);})[_0x32aa('0x15')](function(_0x1d1c80){logger[_0x32aa('0x11')]('GetZohoAccount',_0x1d1c80[_0x32aa('0x14')],_0x5196c0);_0x257be0(_0x3e0a23[_0x32aa('0x11')](0x1f4,_0x1d1c80[_0x32aa('0x14')]));});});};exports[_0x32aa('0x20')]=function(_0x19efc6){var _0x44887c=this;return new Promise(function(_0x4b0d5a,_0x5b410f){return db[_0x32aa('0x21')][_0x32aa('0x22')]({'raw':_0x19efc6[_0x32aa('0x16')]?_0x19efc6[_0x32aa('0x16')]['raw']===undefined?!![]:![]:!![],'where':_0x19efc6['options']?_0x19efc6[_0x32aa('0x16')]['where']||null:null,'attributes':_0x19efc6[_0x32aa('0x16')]?_0x19efc6[_0x32aa('0x16')]['attributes']||null:null,'include':_0x19efc6[_0x32aa('0x16')]?_0x19efc6[_0x32aa('0x16')]['include']?_[_0x32aa('0x1c')](_0x19efc6[_0x32aa('0x16')][_0x32aa('0x1b')],function(_0xd23473){return{'model':db[_0xd23473[_0x32aa('0x1d')]],'as':_0xd23473['as'],'attributes':_0xd23473[_0x32aa('0x19')],'include':_0xd23473[_0x32aa('0x1b')]?_[_0x32aa('0x1c')](_0xd23473[_0x32aa('0x1b')],function(_0x2a2f9d){return{'model':db[_0x2a2f9d[_0x32aa('0x1d')]],'as':_0x2a2f9d['as'],'attributes':_0x2a2f9d[_0x32aa('0x19')],'include':_0x2a2f9d[_0x32aa('0x1b')]?_[_0x32aa('0x1c')](_0x2a2f9d['include'],function(_0x5b0fe2){return{'model':db[_0x5b0fe2[_0x32aa('0x1d')]],'as':_0x5b0fe2['as'],'attributes':_0x5b0fe2[_0x32aa('0x19')]};}):[]};}):[]};}):[]:[]})[_0x32aa('0xc')](function(_0x193d10){logger['info'](_0x32aa('0x20'),_0x19efc6);logger[_0x32aa('0xf')](_0x32aa('0x20'),_0x19efc6,JSON[_0x32aa('0x1f')](_0x193d10));_0x4b0d5a(_0x193d10);})[_0x32aa('0x15')](function(_0xa48198){logger[_0x32aa('0x11')](_0x32aa('0x20'),_0xa48198[_0x32aa('0x14')],_0x19efc6);_0x5b410f(_0x44887c[_0x32aa('0x11')](0x1f4,_0xa48198[_0x32aa('0x14')]));});});};