509d321d987f293db017bba2b99d40ba5ec41e66
[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 _0x5232=['find','ShowZohoAccount','lodash','util','moment','bluebird','randomstring','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','request','then','ZohoAccount,\x20%s,\x20%s','request\x20sent','debug','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','GetZohoAccount','ZohoAccount','options','raw','attributes','limit','include','map','model','info','catch'];(function(_0x364b79,_0x432485){var _0x51155c=function(_0x2e0b2a){while(--_0x2e0b2a){_0x364b79['push'](_0x364b79['shift']());}};_0x51155c(++_0x432485);}(_0x5232,0x1c9));var _0x2523=function(_0x237da8,_0x37b77a){_0x237da8=_0x237da8-0x0;var _0x558825=_0x5232[_0x237da8];return _0x558825;};'use strict';var _=require(_0x2523('0x0'));var util=require(_0x2523('0x1'));var moment=require(_0x2523('0x2'));var BPromise=require(_0x2523('0x3'));var rs=require(_0x2523('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x2523('0x5'));var logger=require(_0x2523('0x6'))('rpc');var config=require(_0x2523('0x7'));var jayson=require(_0x2523('0x8'));var client=jayson[_0x2523('0x9')][_0x2523('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x3ab139,_0x36f3d5,_0x3d8e51){return new BPromise(function(_0x22440b,_0x251973){return client[_0x2523('0xb')](_0x3ab139,_0x3d8e51)[_0x2523('0xc')](function(_0x30f2cd){logger['info'](_0x2523('0xd'),_0x36f3d5,_0x2523('0xe'));logger[_0x2523('0xf')](_0x2523('0x10'),_0x36f3d5,_0x2523('0xe'),JSON[_0x2523('0x11')](_0x30f2cd));if(_0x30f2cd['error']){if(_0x30f2cd[_0x2523('0x12')][_0x2523('0x13')]===0x1f4){logger[_0x2523('0x12')](_0x2523('0xd'),_0x36f3d5,_0x30f2cd['error'][_0x2523('0x14')]);return _0x251973(_0x30f2cd[_0x2523('0x12')]['message']);}logger[_0x2523('0x12')](_0x2523('0xd'),_0x36f3d5,_0x30f2cd[_0x2523('0x12')][_0x2523('0x14')]);return _0x22440b(_0x30f2cd['error'][_0x2523('0x14')]);}else{logger['info'](_0x2523('0xd'),_0x36f3d5,_0x2523('0xe'));_0x22440b(_0x30f2cd[_0x2523('0x15')][_0x2523('0x14')]);}})['catch'](function(_0x1b4584){logger[_0x2523('0x12')](_0x2523('0xd'),_0x36f3d5,_0x1b4584);_0x251973(_0x1b4584);});});}exports[_0x2523('0x16')]=function(_0x1ce828){var _0x2f3a96=this;return new Promise(function(_0x4f2a85,_0x24705a){return db[_0x2523('0x17')]['findAll']({'raw':_0x1ce828[_0x2523('0x18')]?_0x1ce828[_0x2523('0x18')][_0x2523('0x19')]===undefined?!![]:![]:!![],'where':_0x1ce828[_0x2523('0x18')]?_0x1ce828['options']['where']||null:null,'attributes':_0x1ce828['options']?_0x1ce828['options'][_0x2523('0x1a')]||null:null,'limit':_0x1ce828[_0x2523('0x18')]?_0x1ce828[_0x2523('0x18')][_0x2523('0x1b')]||null:null,'include':_0x1ce828[_0x2523('0x18')]?_0x1ce828['options']['include']?_['map'](_0x1ce828[_0x2523('0x18')][_0x2523('0x1c')],function(_0x4847c1){return{'model':db[_0x4847c1['model']],'as':_0x4847c1['as'],'attributes':_0x4847c1['attributes'],'include':_0x4847c1[_0x2523('0x1c')]?_[_0x2523('0x1d')](_0x4847c1[_0x2523('0x1c')],function(_0x393956){return{'model':db[_0x393956[_0x2523('0x1e')]],'as':_0x393956['as'],'attributes':_0x393956['attributes'],'include':_0x393956[_0x2523('0x1c')]?_[_0x2523('0x1d')](_0x393956[_0x2523('0x1c')],function(_0x1a8b0c){return{'model':db[_0x1a8b0c[_0x2523('0x1e')]],'as':_0x1a8b0c['as'],'attributes':_0x1a8b0c[_0x2523('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x2523('0xc')](function(_0x3af962){logger[_0x2523('0x1f')]('GetZohoAccount',_0x1ce828);logger[_0x2523('0xf')](_0x2523('0x16'),_0x1ce828,JSON['stringify'](_0x3af962));_0x4f2a85(_0x3af962);})[_0x2523('0x20')](function(_0x52b25d){logger['error']('GetZohoAccount',_0x52b25d[_0x2523('0x14')],_0x1ce828);_0x24705a(_0x2f3a96['error'](0x1f4,_0x52b25d[_0x2523('0x14')]));});});};exports['ShowZohoAccount']=function(_0x42ea60){var _0xb9cba8=this;return new Promise(function(_0x5ba27c,_0xe78975){return db['ZohoAccount'][_0x2523('0x21')]({'raw':_0x42ea60[_0x2523('0x18')]?_0x42ea60[_0x2523('0x18')][_0x2523('0x19')]===undefined?!![]:![]:!![],'where':_0x42ea60[_0x2523('0x18')]?_0x42ea60[_0x2523('0x18')]['where']||null:null,'attributes':_0x42ea60[_0x2523('0x18')]?_0x42ea60[_0x2523('0x18')][_0x2523('0x1a')]||null:null,'include':_0x42ea60['options']?_0x42ea60[_0x2523('0x18')]['include']?_[_0x2523('0x1d')](_0x42ea60[_0x2523('0x18')][_0x2523('0x1c')],function(_0x41ab54){return{'model':db[_0x41ab54[_0x2523('0x1e')]],'as':_0x41ab54['as'],'attributes':_0x41ab54[_0x2523('0x1a')],'include':_0x41ab54[_0x2523('0x1c')]?_['map'](_0x41ab54[_0x2523('0x1c')],function(_0x40b84f){return{'model':db[_0x40b84f[_0x2523('0x1e')]],'as':_0x40b84f['as'],'attributes':_0x40b84f[_0x2523('0x1a')],'include':_0x40b84f[_0x2523('0x1c')]?_['map'](_0x40b84f[_0x2523('0x1c')],function(_0xedc105){return{'model':db[_0xedc105[_0x2523('0x1e')]],'as':_0xedc105['as'],'attributes':_0xedc105[_0x2523('0x1a')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x79c2b2){logger['info'](_0x2523('0x22'),_0x42ea60);logger['debug'](_0x2523('0x22'),_0x42ea60,JSON[_0x2523('0x11')](_0x79c2b2));_0x5ba27c(_0x79c2b2);})[_0x2523('0x20')](function(_0x51a6ab){logger[_0x2523('0x12')](_0x2523('0x22'),_0x51a6ab[_0x2523('0x14')],_0x42ea60);_0xe78975(_0xb9cba8[_0x2523('0x12')](0x1f4,_0x51a6ab['message']));});});};