Built motion from commit 9d1906d1.|2.5.40
[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 _0xe635=['catch','GetZohoAccount','findAll','raw','options','where','attributes','limit','include','model','map','ShowZohoAccount','ZohoAccount','find','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise','client','http','then','info','ZohoAccount,\x20%s,\x20%s','debug','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result'];(function(_0x1e5773,_0x4c1398){var _0x480099=function(_0x26bf2f){while(--_0x26bf2f){_0x1e5773['push'](_0x1e5773['shift']());}};_0x480099(++_0x4c1398);}(_0xe635,0x1be));var _0x5e63=function(_0x416bc5,_0x471249){_0x416bc5=_0x416bc5-0x0;var _0x1546d2=_0xe635[_0x416bc5];return _0x1546d2;};'use strict';var _=require(_0x5e63('0x0'));var util=require(_0x5e63('0x1'));var moment=require(_0x5e63('0x2'));var BPromise=require(_0x5e63('0x3'));var rs=require(_0x5e63('0x4'));var fs=require('fs');var Redis=require(_0x5e63('0x5'));var db=require(_0x5e63('0x6'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x5e63('0x7'));var config=require(_0x5e63('0x8'));var jayson=require(_0x5e63('0x9'));var client=jayson[_0x5e63('0xa')][_0x5e63('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x2d15fb,_0x1ba31c,_0xa99472){return new BPromise(function(_0xaac91f,_0x3d444e){return client['request'](_0x2d15fb,_0xa99472)[_0x5e63('0xc')](function(_0x13501d){logger[_0x5e63('0xd')](_0x5e63('0xe'),_0x1ba31c,'request\x20sent');logger[_0x5e63('0xf')](_0x5e63('0x10'),_0x1ba31c,'request\x20sent',JSON[_0x5e63('0x11')](_0x13501d));if(_0x13501d[_0x5e63('0x12')]){if(_0x13501d['error'][_0x5e63('0x13')]===0x1f4){logger['error'](_0x5e63('0xe'),_0x1ba31c,_0x13501d[_0x5e63('0x12')][_0x5e63('0x14')]);return _0x3d444e(_0x13501d[_0x5e63('0x12')]['message']);}logger['error']('ZohoAccount,\x20%s,\x20%s',_0x1ba31c,_0x13501d[_0x5e63('0x12')][_0x5e63('0x14')]);return _0xaac91f(_0x13501d['error'][_0x5e63('0x14')]);}else{logger[_0x5e63('0xd')](_0x5e63('0xe'),_0x1ba31c,'request\x20sent');_0xaac91f(_0x13501d[_0x5e63('0x15')][_0x5e63('0x14')]);}})[_0x5e63('0x16')](function(_0x357f40){logger[_0x5e63('0x12')]('ZohoAccount,\x20%s,\x20%s',_0x1ba31c,_0x357f40);_0x3d444e(_0x357f40);});});}exports[_0x5e63('0x17')]=function(_0x42b370){var _0x264aca=this;return new Promise(function(_0xbdcef0,_0xdf5019){return db['ZohoAccount'][_0x5e63('0x18')]({'raw':_0x42b370['options']?_0x42b370['options'][_0x5e63('0x19')]===undefined?!![]:![]:!![],'where':_0x42b370[_0x5e63('0x1a')]?_0x42b370[_0x5e63('0x1a')][_0x5e63('0x1b')]||null:null,'attributes':_0x42b370[_0x5e63('0x1a')]?_0x42b370[_0x5e63('0x1a')][_0x5e63('0x1c')]||null:null,'limit':_0x42b370[_0x5e63('0x1a')]?_0x42b370[_0x5e63('0x1a')][_0x5e63('0x1d')]||null:null,'include':_0x42b370['options']?_0x42b370[_0x5e63('0x1a')]['include']?_['map'](_0x42b370[_0x5e63('0x1a')][_0x5e63('0x1e')],function(_0x2d9387){return{'model':db[_0x2d9387[_0x5e63('0x1f')]],'as':_0x2d9387['as'],'attributes':_0x2d9387[_0x5e63('0x1c')],'include':_0x2d9387[_0x5e63('0x1e')]?_[_0x5e63('0x20')](_0x2d9387['include'],function(_0x275715){return{'model':db[_0x275715['model']],'as':_0x275715['as'],'attributes':_0x275715[_0x5e63('0x1c')],'include':_0x275715[_0x5e63('0x1e')]?_['map'](_0x275715[_0x5e63('0x1e')],function(_0x4fe1b3){return{'model':db[_0x4fe1b3[_0x5e63('0x1f')]],'as':_0x4fe1b3['as'],'attributes':_0x4fe1b3[_0x5e63('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x4e0a86){logger[_0x5e63('0xd')](_0x5e63('0x17'),_0x42b370);logger[_0x5e63('0xf')](_0x5e63('0x17'),_0x42b370,JSON[_0x5e63('0x11')](_0x4e0a86));_0xbdcef0(_0x4e0a86);})[_0x5e63('0x16')](function(_0x4b3e42){logger[_0x5e63('0x12')]('GetZohoAccount',_0x4b3e42[_0x5e63('0x14')],_0x42b370);_0xdf5019(_0x264aca[_0x5e63('0x12')](0x1f4,_0x4b3e42[_0x5e63('0x14')]));});});};exports[_0x5e63('0x21')]=function(_0xfc4a65){var _0x12c804=this;return new Promise(function(_0x5db415,_0x672239){return db[_0x5e63('0x22')][_0x5e63('0x23')]({'raw':_0xfc4a65['options']?_0xfc4a65[_0x5e63('0x1a')][_0x5e63('0x19')]===undefined?!![]:![]:!![],'where':_0xfc4a65[_0x5e63('0x1a')]?_0xfc4a65[_0x5e63('0x1a')]['where']||null:null,'attributes':_0xfc4a65['options']?_0xfc4a65['options']['attributes']||null:null,'include':_0xfc4a65[_0x5e63('0x1a')]?_0xfc4a65[_0x5e63('0x1a')][_0x5e63('0x1e')]?_['map'](_0xfc4a65[_0x5e63('0x1a')][_0x5e63('0x1e')],function(_0x4a264f){return{'model':db[_0x4a264f[_0x5e63('0x1f')]],'as':_0x4a264f['as'],'attributes':_0x4a264f[_0x5e63('0x1c')],'include':_0x4a264f[_0x5e63('0x1e')]?_[_0x5e63('0x20')](_0x4a264f['include'],function(_0x265565){return{'model':db[_0x265565['model']],'as':_0x265565['as'],'attributes':_0x265565['attributes'],'include':_0x265565[_0x5e63('0x1e')]?_[_0x5e63('0x20')](_0x265565[_0x5e63('0x1e')],function(_0x2f5664){return{'model':db[_0x2f5664['model']],'as':_0x2f5664['as'],'attributes':_0x2f5664[_0x5e63('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x5e63('0xc')](function(_0x54b7c0){logger[_0x5e63('0xd')](_0x5e63('0x21'),_0xfc4a65);logger[_0x5e63('0xf')](_0x5e63('0x21'),_0xfc4a65,JSON[_0x5e63('0x11')](_0x54b7c0));_0x5db415(_0x54b7c0);})['catch'](function(_0x1929d5){logger['error'](_0x5e63('0x21'),_0x1929d5['message'],_0xfc4a65);_0x672239(_0x12c804[_0x5e63('0x12')](0x1f4,_0x1929d5[_0x5e63('0x14')]));});});};