144cda606bc7884e647910d590605791f680fae4
[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 _0x508a=['stringify','error','code','message','result','catch','GetZohoAccount','ZohoAccount','findAll','options','raw','where','attributes','limit','include','model','map','ShowZohoAccount','find','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','client','http','request','then','info','ZohoAccount,\x20%s,\x20%s','request\x20sent','debug','ZohoAccount,\x20%s,\x20%s,\x20%s'];(function(_0x138adb,_0x193fee){var _0x1b27f2=function(_0x5e97a2){while(--_0x5e97a2){_0x138adb['push'](_0x138adb['shift']());}};_0x1b27f2(++_0x193fee);}(_0x508a,0x1aa));var _0xa508=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x508a[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0xa508('0x0'));var util=require('util');var moment=require(_0xa508('0x1'));var BPromise=require(_0xa508('0x2'));var rs=require(_0xa508('0x3'));var fs=require('fs');var Redis=require(_0xa508('0x4'));var db=require(_0xa508('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xa508('0x6'))(_0xa508('0x7'));var config=require(_0xa508('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xa508('0x9')][_0xa508('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x406df0,_0x4ddfec,_0x284fb1){return new BPromise(function(_0x6f201c,_0x4f6c23){return client[_0xa508('0xb')](_0x406df0,_0x284fb1)[_0xa508('0xc')](function(_0x577617){logger[_0xa508('0xd')](_0xa508('0xe'),_0x4ddfec,_0xa508('0xf'));logger[_0xa508('0x10')](_0xa508('0x11'),_0x4ddfec,'request\x20sent',JSON[_0xa508('0x12')](_0x577617));if(_0x577617[_0xa508('0x13')]){if(_0x577617['error'][_0xa508('0x14')]===0x1f4){logger[_0xa508('0x13')](_0xa508('0xe'),_0x4ddfec,_0x577617['error'][_0xa508('0x15')]);return _0x4f6c23(_0x577617['error'][_0xa508('0x15')]);}logger[_0xa508('0x13')](_0xa508('0xe'),_0x4ddfec,_0x577617[_0xa508('0x13')]['message']);return _0x6f201c(_0x577617[_0xa508('0x13')][_0xa508('0x15')]);}else{logger[_0xa508('0xd')](_0xa508('0xe'),_0x4ddfec,'request\x20sent');_0x6f201c(_0x577617[_0xa508('0x16')][_0xa508('0x15')]);}})[_0xa508('0x17')](function(_0xb76bf){logger['error'](_0xa508('0xe'),_0x4ddfec,_0xb76bf);_0x4f6c23(_0xb76bf);});});}exports[_0xa508('0x18')]=function(_0x5e29a8){var _0x5d345d=this;return new Promise(function(_0x1984ae,_0x226024){return db[_0xa508('0x19')][_0xa508('0x1a')]({'raw':_0x5e29a8[_0xa508('0x1b')]?_0x5e29a8[_0xa508('0x1b')][_0xa508('0x1c')]===undefined?!![]:![]:!![],'where':_0x5e29a8[_0xa508('0x1b')]?_0x5e29a8['options'][_0xa508('0x1d')]||null:null,'attributes':_0x5e29a8[_0xa508('0x1b')]?_0x5e29a8[_0xa508('0x1b')][_0xa508('0x1e')]||null:null,'limit':_0x5e29a8[_0xa508('0x1b')]?_0x5e29a8['options'][_0xa508('0x1f')]||null:null,'include':_0x5e29a8['options']?_0x5e29a8[_0xa508('0x1b')][_0xa508('0x20')]?_['map'](_0x5e29a8[_0xa508('0x1b')][_0xa508('0x20')],function(_0x14ca1c){return{'model':db[_0x14ca1c[_0xa508('0x21')]],'as':_0x14ca1c['as'],'attributes':_0x14ca1c['attributes'],'include':_0x14ca1c['include']?_['map'](_0x14ca1c[_0xa508('0x20')],function(_0x2cda06){return{'model':db[_0x2cda06[_0xa508('0x21')]],'as':_0x2cda06['as'],'attributes':_0x2cda06[_0xa508('0x1e')],'include':_0x2cda06[_0xa508('0x20')]?_[_0xa508('0x22')](_0x2cda06[_0xa508('0x20')],function(_0x4be5bf){return{'model':db[_0x4be5bf['model']],'as':_0x4be5bf['as'],'attributes':_0x4be5bf[_0xa508('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xa508('0xc')](function(_0x47d93b){logger[_0xa508('0xd')]('GetZohoAccount',_0x5e29a8);logger[_0xa508('0x10')](_0xa508('0x18'),_0x5e29a8,JSON['stringify'](_0x47d93b));_0x1984ae(_0x47d93b);})[_0xa508('0x17')](function(_0x2ca53f){logger[_0xa508('0x13')](_0xa508('0x18'),_0x2ca53f['message'],_0x5e29a8);_0x226024(_0x5d345d[_0xa508('0x13')](0x1f4,_0x2ca53f[_0xa508('0x15')]));});});};exports[_0xa508('0x23')]=function(_0x5d971d){var _0x2affae=this;return new Promise(function(_0x391ba7,_0x4a7161){return db['ZohoAccount'][_0xa508('0x24')]({'raw':_0x5d971d['options']?_0x5d971d['options'][_0xa508('0x1c')]===undefined?!![]:![]:!![],'where':_0x5d971d['options']?_0x5d971d['options'][_0xa508('0x1d')]||null:null,'attributes':_0x5d971d[_0xa508('0x1b')]?_0x5d971d['options'][_0xa508('0x1e')]||null:null,'include':_0x5d971d[_0xa508('0x1b')]?_0x5d971d[_0xa508('0x1b')]['include']?_['map'](_0x5d971d[_0xa508('0x1b')][_0xa508('0x20')],function(_0x2a74dc){return{'model':db[_0x2a74dc[_0xa508('0x21')]],'as':_0x2a74dc['as'],'attributes':_0x2a74dc[_0xa508('0x1e')],'include':_0x2a74dc[_0xa508('0x20')]?_[_0xa508('0x22')](_0x2a74dc[_0xa508('0x20')],function(_0x374293){return{'model':db[_0x374293[_0xa508('0x21')]],'as':_0x374293['as'],'attributes':_0x374293[_0xa508('0x1e')],'include':_0x374293['include']?_[_0xa508('0x22')](_0x374293[_0xa508('0x20')],function(_0x453e4e){return{'model':db[_0x453e4e[_0xa508('0x21')]],'as':_0x453e4e['as'],'attributes':_0x453e4e['attributes']};}):[]};}):[]};}):[]:[]})[_0xa508('0xc')](function(_0x3de64d){logger[_0xa508('0xd')]('ShowZohoAccount',_0x5d971d);logger[_0xa508('0x10')](_0xa508('0x23'),_0x5d971d,JSON[_0xa508('0x12')](_0x3de64d));_0x391ba7(_0x3de64d);})['catch'](function(_0x4cc50e){logger[_0xa508('0x13')](_0xa508('0x23'),_0x4cc50e[_0xa508('0x15')],_0x5d971d);_0x4a7161(_0x2affae[_0xa508('0x13')](0x1f4,_0x4cc50e['message']));});});};