Built motion from commit e6806ed6.|2.6.0
[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 _0xb366=['GetZohoAccount','ShowZohoAccount','ZohoAccount','find','lodash','moment','bluebird','ioredis','../../mysqldb','../../config/utils','jayson/promise','client','request','then','info','ZohoAccount,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','result','catch','findAll','options','where','attributes','limit','include','model','map'];(function(_0x30e66e,_0x423563){var _0x5babc0=function(_0x9da3c3){while(--_0x9da3c3){_0x30e66e['push'](_0x30e66e['shift']());}};_0x5babc0(++_0x423563);}(_0xb366,0xa4));var _0x6b36=function(_0x124aef,_0x205cd8){_0x124aef=_0x124aef-0x0;var _0x5799d9=_0xb366[_0x124aef];return _0x5799d9;};'use strict';var _=require(_0x6b36('0x0'));var util=require('util');var moment=require(_0x6b36('0x1'));var BPromise=require(_0x6b36('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x6b36('0x3'));var db=require(_0x6b36('0x4'))['db'];var utils=require(_0x6b36('0x5'));var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0x6b36('0x6'));var client=jayson[_0x6b36('0x7')]['http']({'port':0x232a});function respondWithRpcPromise(_0x3997c0,_0x4fe38c,_0x4c6f4c){return new BPromise(function(_0x301a30,_0xee898a){return client[_0x6b36('0x8')](_0x3997c0,_0x4c6f4c)[_0x6b36('0x9')](function(_0x49c125){logger[_0x6b36('0xa')](_0x6b36('0xb'),_0x4fe38c,'request\x20sent');logger[_0x6b36('0xc')]('ZohoAccount,\x20%s,\x20%s,\x20%s',_0x4fe38c,_0x6b36('0xd'),JSON[_0x6b36('0xe')](_0x49c125));if(_0x49c125[_0x6b36('0xf')]){if(_0x49c125[_0x6b36('0xf')][_0x6b36('0x10')]===0x1f4){logger[_0x6b36('0xf')]('ZohoAccount,\x20%s,\x20%s',_0x4fe38c,_0x49c125[_0x6b36('0xf')][_0x6b36('0x11')]);return _0xee898a(_0x49c125['error'][_0x6b36('0x11')]);}logger['error'](_0x6b36('0xb'),_0x4fe38c,_0x49c125['error']['message']);return _0x301a30(_0x49c125['error'][_0x6b36('0x11')]);}else{logger[_0x6b36('0xa')](_0x6b36('0xb'),_0x4fe38c,'request\x20sent');_0x301a30(_0x49c125[_0x6b36('0x12')]['message']);}})[_0x6b36('0x13')](function(_0xf7b45a){logger[_0x6b36('0xf')]('ZohoAccount,\x20%s,\x20%s',_0x4fe38c,_0xf7b45a);_0xee898a(_0xf7b45a);});});}exports['GetZohoAccount']=function(_0x17c969){var _0x51e103=this;return new Promise(function(_0x41334a,_0x2864bb){return db['ZohoAccount'][_0x6b36('0x14')]({'raw':_0x17c969['options']?_0x17c969[_0x6b36('0x15')]['raw']===undefined?!![]:![]:!![],'where':_0x17c969[_0x6b36('0x15')]?_0x17c969[_0x6b36('0x15')][_0x6b36('0x16')]||null:null,'attributes':_0x17c969[_0x6b36('0x15')]?_0x17c969[_0x6b36('0x15')][_0x6b36('0x17')]||null:null,'limit':_0x17c969[_0x6b36('0x15')]?_0x17c969[_0x6b36('0x15')][_0x6b36('0x18')]||null:null,'include':_0x17c969[_0x6b36('0x15')]?_0x17c969[_0x6b36('0x15')][_0x6b36('0x19')]?_['map'](_0x17c969[_0x6b36('0x15')][_0x6b36('0x19')],function(_0x514c0d){return{'model':db[_0x514c0d[_0x6b36('0x1a')]],'as':_0x514c0d['as'],'attributes':_0x514c0d['attributes'],'include':_0x514c0d[_0x6b36('0x19')]?_['map'](_0x514c0d['include'],function(_0x5b00d1){return{'model':db[_0x5b00d1[_0x6b36('0x1a')]],'as':_0x5b00d1['as'],'attributes':_0x5b00d1[_0x6b36('0x17')],'include':_0x5b00d1[_0x6b36('0x19')]?_[_0x6b36('0x1b')](_0x5b00d1[_0x6b36('0x19')],function(_0x33d343){return{'model':db[_0x33d343[_0x6b36('0x1a')]],'as':_0x33d343['as'],'attributes':_0x33d343[_0x6b36('0x17')]};}):[]};}):[]};}):[]:[]})['then'](function(_0xaa79dc){logger[_0x6b36('0xa')]('GetZohoAccount',_0x17c969);logger[_0x6b36('0xc')](_0x6b36('0x1c'),_0x17c969,JSON['stringify'](_0xaa79dc));_0x41334a(_0xaa79dc);})[_0x6b36('0x13')](function(_0x111655){logger[_0x6b36('0xf')](_0x6b36('0x1c'),_0x111655[_0x6b36('0x11')],_0x17c969);_0x2864bb(_0x51e103[_0x6b36('0xf')](0x1f4,_0x111655[_0x6b36('0x11')]));});});};exports[_0x6b36('0x1d')]=function(_0x2ec52a){var _0x4470f4=this;return new Promise(function(_0x4bac74,_0x2ef2ae){return db[_0x6b36('0x1e')][_0x6b36('0x1f')]({'raw':_0x2ec52a[_0x6b36('0x15')]?_0x2ec52a['options']['raw']===undefined?!![]:![]:!![],'where':_0x2ec52a[_0x6b36('0x15')]?_0x2ec52a['options'][_0x6b36('0x16')]||null:null,'attributes':_0x2ec52a[_0x6b36('0x15')]?_0x2ec52a[_0x6b36('0x15')][_0x6b36('0x17')]||null:null,'include':_0x2ec52a[_0x6b36('0x15')]?_0x2ec52a[_0x6b36('0x15')][_0x6b36('0x19')]?_[_0x6b36('0x1b')](_0x2ec52a[_0x6b36('0x15')][_0x6b36('0x19')],function(_0xe4c6b5){return{'model':db[_0xe4c6b5['model']],'as':_0xe4c6b5['as'],'attributes':_0xe4c6b5['attributes'],'include':_0xe4c6b5[_0x6b36('0x19')]?_[_0x6b36('0x1b')](_0xe4c6b5[_0x6b36('0x19')],function(_0x1f87cf){return{'model':db[_0x1f87cf[_0x6b36('0x1a')]],'as':_0x1f87cf['as'],'attributes':_0x1f87cf['attributes'],'include':_0x1f87cf['include']?_[_0x6b36('0x1b')](_0x1f87cf[_0x6b36('0x19')],function(_0x198ce0){return{'model':db[_0x198ce0['model']],'as':_0x198ce0['as'],'attributes':_0x198ce0[_0x6b36('0x17')]};}):[]};}):[]};}):[]:[]})[_0x6b36('0x9')](function(_0x5258e0){logger[_0x6b36('0xa')](_0x6b36('0x1d'),_0x2ec52a);logger['debug'](_0x6b36('0x1d'),_0x2ec52a,JSON[_0x6b36('0xe')](_0x5258e0));_0x4bac74(_0x5258e0);})[_0x6b36('0x13')](function(_0x203d63){logger['error'](_0x6b36('0x1d'),_0x203d63[_0x6b36('0x11')],_0x2ec52a);_0x2ef2ae(_0x4470f4[_0x6b36('0xf')](0x1f4,_0x203d63[_0x6b36('0x11')]));});});};