Built motion from commit (unavailable).|2.5.1
[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 _0x3f74=['ShowZohoAccount','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','http','request','then','ZohoAccount,\x20%s,\x20%s','debug','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','info','request\x20sent','result','catch','ZohoAccount','findAll','options','raw','where','attributes','limit','include','map','model','GetZohoAccount','find'];(function(_0x3947c9,_0x4d6c97){var _0x2e7871=function(_0x1236cc){while(--_0x1236cc){_0x3947c9['push'](_0x3947c9['shift']());}};_0x2e7871(++_0x4d6c97);}(_0x3f74,0x121));var _0x43f7=function(_0x268882,_0xc8f590){_0x268882=_0x268882-0x0;var _0x2548d8=_0x3f74[_0x268882];return _0x2548d8;};'use strict';var _=require(_0x43f7('0x0'));var util=require(_0x43f7('0x1'));var moment=require(_0x43f7('0x2'));var BPromise=require(_0x43f7('0x3'));var rs=require(_0x43f7('0x4'));var fs=require('fs');var Redis=require(_0x43f7('0x5'));var db=require(_0x43f7('0x6'))['db'];var utils=require(_0x43f7('0x7'));var logger=require('../../config/logger')(_0x43f7('0x8'));var config=require(_0x43f7('0x9'));var jayson=require('jayson/promise');var client=jayson['client'][_0x43f7('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x4f64a6,_0x1998e3,_0x574b8a){return new BPromise(function(_0x115f89,_0x65bccb){return client[_0x43f7('0xb')](_0x4f64a6,_0x574b8a)[_0x43f7('0xc')](function(_0x452e91){logger['info'](_0x43f7('0xd'),_0x1998e3,'request\x20sent');logger[_0x43f7('0xe')](_0x43f7('0xf'),_0x1998e3,'request\x20sent',JSON[_0x43f7('0x10')](_0x452e91));if(_0x452e91[_0x43f7('0x11')]){if(_0x452e91[_0x43f7('0x11')]['code']===0x1f4){logger[_0x43f7('0x11')](_0x43f7('0xd'),_0x1998e3,_0x452e91[_0x43f7('0x11')][_0x43f7('0x12')]);return _0x65bccb(_0x452e91[_0x43f7('0x11')][_0x43f7('0x12')]);}logger[_0x43f7('0x11')](_0x43f7('0xd'),_0x1998e3,_0x452e91[_0x43f7('0x11')][_0x43f7('0x12')]);return _0x115f89(_0x452e91[_0x43f7('0x11')][_0x43f7('0x12')]);}else{logger[_0x43f7('0x13')](_0x43f7('0xd'),_0x1998e3,_0x43f7('0x14'));_0x115f89(_0x452e91[_0x43f7('0x15')][_0x43f7('0x12')]);}})[_0x43f7('0x16')](function(_0x5ba55e){logger[_0x43f7('0x11')]('ZohoAccount,\x20%s,\x20%s',_0x1998e3,_0x5ba55e);_0x65bccb(_0x5ba55e);});});}exports['GetZohoAccount']=function(_0x3d8571){var _0x5ce4ed=this;return new Promise(function(_0x44380f,_0x8c976a){return db[_0x43f7('0x17')][_0x43f7('0x18')]({'raw':_0x3d8571[_0x43f7('0x19')]?_0x3d8571['options'][_0x43f7('0x1a')]===undefined?!![]:![]:!![],'where':_0x3d8571[_0x43f7('0x19')]?_0x3d8571['options'][_0x43f7('0x1b')]||null:null,'attributes':_0x3d8571['options']?_0x3d8571[_0x43f7('0x19')][_0x43f7('0x1c')]||null:null,'limit':_0x3d8571[_0x43f7('0x19')]?_0x3d8571[_0x43f7('0x19')][_0x43f7('0x1d')]||null:null,'include':_0x3d8571[_0x43f7('0x19')]?_0x3d8571[_0x43f7('0x19')][_0x43f7('0x1e')]?_[_0x43f7('0x1f')](_0x3d8571[_0x43f7('0x19')][_0x43f7('0x1e')],function(_0x4e6e98){return{'model':db[_0x4e6e98[_0x43f7('0x20')]],'as':_0x4e6e98['as'],'attributes':_0x4e6e98[_0x43f7('0x1c')],'include':_0x4e6e98[_0x43f7('0x1e')]?_[_0x43f7('0x1f')](_0x4e6e98['include'],function(_0x2d7b3a){return{'model':db[_0x2d7b3a['model']],'as':_0x2d7b3a['as'],'attributes':_0x2d7b3a[_0x43f7('0x1c')],'include':_0x2d7b3a[_0x43f7('0x1e')]?_[_0x43f7('0x1f')](_0x2d7b3a[_0x43f7('0x1e')],function(_0x339775){return{'model':db[_0x339775[_0x43f7('0x20')]],'as':_0x339775['as'],'attributes':_0x339775[_0x43f7('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x43f7('0xc')](function(_0x1d3ee5){logger[_0x43f7('0x13')](_0x43f7('0x21'),_0x3d8571);logger[_0x43f7('0xe')]('GetZohoAccount',_0x3d8571,JSON[_0x43f7('0x10')](_0x1d3ee5));_0x44380f(_0x1d3ee5);})[_0x43f7('0x16')](function(_0x16f48c){logger[_0x43f7('0x11')](_0x43f7('0x21'),_0x16f48c['message'],_0x3d8571);_0x8c976a(_0x5ce4ed[_0x43f7('0x11')](0x1f4,_0x16f48c['message']));});});};exports['ShowZohoAccount']=function(_0xb0f888){var _0x1b9ca5=this;return new Promise(function(_0x5dd95a,_0x490561){return db[_0x43f7('0x17')][_0x43f7('0x22')]({'raw':_0xb0f888[_0x43f7('0x19')]?_0xb0f888[_0x43f7('0x19')][_0x43f7('0x1a')]===undefined?!![]:![]:!![],'where':_0xb0f888[_0x43f7('0x19')]?_0xb0f888[_0x43f7('0x19')]['where']||null:null,'attributes':_0xb0f888[_0x43f7('0x19')]?_0xb0f888[_0x43f7('0x19')][_0x43f7('0x1c')]||null:null,'include':_0xb0f888[_0x43f7('0x19')]?_0xb0f888[_0x43f7('0x19')][_0x43f7('0x1e')]?_['map'](_0xb0f888[_0x43f7('0x19')][_0x43f7('0x1e')],function(_0x3fab91){return{'model':db[_0x3fab91[_0x43f7('0x20')]],'as':_0x3fab91['as'],'attributes':_0x3fab91[_0x43f7('0x1c')],'include':_0x3fab91[_0x43f7('0x1e')]?_[_0x43f7('0x1f')](_0x3fab91['include'],function(_0x25c521){return{'model':db[_0x25c521[_0x43f7('0x20')]],'as':_0x25c521['as'],'attributes':_0x25c521['attributes'],'include':_0x25c521['include']?_['map'](_0x25c521[_0x43f7('0x1e')],function(_0x4c48ad){return{'model':db[_0x4c48ad[_0x43f7('0x20')]],'as':_0x4c48ad['as'],'attributes':_0x4c48ad[_0x43f7('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x43f7('0xc')](function(_0x38e52a){logger['info'](_0x43f7('0x23'),_0xb0f888);logger[_0x43f7('0xe')](_0x43f7('0x23'),_0xb0f888,JSON[_0x43f7('0x10')](_0x38e52a));_0x5dd95a(_0x38e52a);})[_0x43f7('0x16')](function(_0x3fe7b9){logger[_0x43f7('0x11')](_0x43f7('0x23'),_0x3fe7b9[_0x43f7('0x12')],_0xb0f888);_0x490561(_0x1b9ca5[_0x43f7('0x11')](0x1f4,_0x3fe7b9[_0x43f7('0x12')]));});});};