Built motion from commit (unavailable).|2.2.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 _0xb7dc=['ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','GetZohoAccount','ZohoAccount','options','raw','where','attributes','map','include','model','ShowZohoAccount','find','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/environment','client','http','request','then','ZohoAccount,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x40b003,_0x3ae3aa){var _0x3d0edc=function(_0x1f048e){while(--_0x1f048e){_0x40b003['push'](_0x40b003['shift']());}};_0x3d0edc(++_0x3ae3aa);}(_0xb7dc,0x9b));var _0xcb7d=function(_0x4f2ba4,_0x4cb6c6){_0x4f2ba4=_0x4f2ba4-0x0;var _0x33282b=_0xb7dc[_0x4f2ba4];return _0x33282b;};'use strict';var _=require(_0xcb7d('0x0'));var util=require(_0xcb7d('0x1'));var moment=require(_0xcb7d('0x2'));var BPromise=require(_0xcb7d('0x3'));var rs=require(_0xcb7d('0x4'));var fs=require('fs');var Redis=require(_0xcb7d('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xcb7d('0x6'));var logger=require('../../config/logger')('rpc');var config=require(_0xcb7d('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xcb7d('0x8')][_0xcb7d('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x32bb18,_0x3eb3cb,_0x26cdc2){return new BPromise(function(_0x16cf33,_0x2855f0){return client[_0xcb7d('0xa')](_0x32bb18,_0x26cdc2)[_0xcb7d('0xb')](function(_0x5e465a){logger['info'](_0xcb7d('0xc'),_0x3eb3cb,_0xcb7d('0xd'));logger[_0xcb7d('0xe')](_0xcb7d('0xf'),_0x3eb3cb,'request\x20sent',JSON[_0xcb7d('0x10')](_0x5e465a));if(_0x5e465a[_0xcb7d('0x11')]){if(_0x5e465a['error'][_0xcb7d('0x12')]===0x1f4){logger[_0xcb7d('0x11')](_0xcb7d('0xc'),_0x3eb3cb,_0x5e465a[_0xcb7d('0x11')][_0xcb7d('0x13')]);return _0x2855f0(_0x5e465a[_0xcb7d('0x11')][_0xcb7d('0x13')]);}logger[_0xcb7d('0x11')](_0xcb7d('0xc'),_0x3eb3cb,_0x5e465a[_0xcb7d('0x11')][_0xcb7d('0x13')]);return _0x16cf33(_0x5e465a[_0xcb7d('0x11')][_0xcb7d('0x13')]);}else{logger[_0xcb7d('0x14')](_0xcb7d('0xc'),_0x3eb3cb,_0xcb7d('0xd'));_0x16cf33(_0x5e465a[_0xcb7d('0x15')]['message']);}})[_0xcb7d('0x16')](function(_0x3aa36c){logger[_0xcb7d('0x11')](_0xcb7d('0xc'),_0x3eb3cb,_0x3aa36c);_0x2855f0(_0x3aa36c);});});}exports[_0xcb7d('0x17')]=function(_0x49ac57){var _0x5eae9c=this;return new Promise(function(_0x4aba01,_0x148e29){return db[_0xcb7d('0x18')]['findAll']({'raw':_0x49ac57[_0xcb7d('0x19')]?_0x49ac57[_0xcb7d('0x19')][_0xcb7d('0x1a')]===undefined?!![]:![]:!![],'where':_0x49ac57[_0xcb7d('0x19')]?_0x49ac57[_0xcb7d('0x19')][_0xcb7d('0x1b')]||null:null,'attributes':_0x49ac57['options']?_0x49ac57[_0xcb7d('0x19')][_0xcb7d('0x1c')]||null:null,'limit':_0x49ac57[_0xcb7d('0x19')]?_0x49ac57[_0xcb7d('0x19')]['limit']||null:null,'include':_0x49ac57[_0xcb7d('0x19')]?_0x49ac57[_0xcb7d('0x19')]['include']?_[_0xcb7d('0x1d')](_0x49ac57[_0xcb7d('0x19')][_0xcb7d('0x1e')],function(_0x585763){return{'model':db[_0x585763[_0xcb7d('0x1f')]],'as':_0x585763['as'],'attributes':_0x585763['attributes'],'include':_0x585763['include']?_['map'](_0x585763['include'],function(_0x50309b){return{'model':db[_0x50309b[_0xcb7d('0x1f')]],'as':_0x50309b['as'],'attributes':_0x50309b[_0xcb7d('0x1c')],'include':_0x50309b[_0xcb7d('0x1e')]?_[_0xcb7d('0x1d')](_0x50309b[_0xcb7d('0x1e')],function(_0x35f835){return{'model':db[_0x35f835[_0xcb7d('0x1f')]],'as':_0x35f835['as'],'attributes':_0x35f835['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x342ffe){logger[_0xcb7d('0x14')](_0xcb7d('0x17'),_0x49ac57);logger[_0xcb7d('0xe')](_0xcb7d('0x17'),_0x49ac57,JSON[_0xcb7d('0x10')](_0x342ffe));_0x4aba01(_0x342ffe);})[_0xcb7d('0x16')](function(_0x8badc8){logger[_0xcb7d('0x11')](_0xcb7d('0x17'),_0x8badc8[_0xcb7d('0x13')],_0x49ac57);_0x148e29(_0x5eae9c[_0xcb7d('0x11')](0x1f4,_0x8badc8[_0xcb7d('0x13')]));});});};exports[_0xcb7d('0x20')]=function(_0x67db8b){var _0x4dca72=this;return new Promise(function(_0x3a0ee1,_0x65ebf8){return db['ZohoAccount'][_0xcb7d('0x21')]({'raw':_0x67db8b[_0xcb7d('0x19')]?_0x67db8b[_0xcb7d('0x19')][_0xcb7d('0x1a')]===undefined?!![]:![]:!![],'where':_0x67db8b[_0xcb7d('0x19')]?_0x67db8b['options']['where']||null:null,'attributes':_0x67db8b['options']?_0x67db8b[_0xcb7d('0x19')][_0xcb7d('0x1c')]||null:null,'include':_0x67db8b[_0xcb7d('0x19')]?_0x67db8b[_0xcb7d('0x19')][_0xcb7d('0x1e')]?_[_0xcb7d('0x1d')](_0x67db8b['options'][_0xcb7d('0x1e')],function(_0x5d6100){return{'model':db[_0x5d6100[_0xcb7d('0x1f')]],'as':_0x5d6100['as'],'attributes':_0x5d6100[_0xcb7d('0x1c')],'include':_0x5d6100[_0xcb7d('0x1e')]?_[_0xcb7d('0x1d')](_0x5d6100[_0xcb7d('0x1e')],function(_0x40b863){return{'model':db[_0x40b863[_0xcb7d('0x1f')]],'as':_0x40b863['as'],'attributes':_0x40b863[_0xcb7d('0x1c')],'include':_0x40b863['include']?_['map'](_0x40b863['include'],function(_0x34fb13){return{'model':db[_0x34fb13[_0xcb7d('0x1f')]],'as':_0x34fb13['as'],'attributes':_0x34fb13[_0xcb7d('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x108bd1){logger[_0xcb7d('0x14')]('ShowZohoAccount',_0x67db8b);logger[_0xcb7d('0xe')](_0xcb7d('0x20'),_0x67db8b,JSON[_0xcb7d('0x10')](_0x108bd1));_0x3a0ee1(_0x108bd1);})[_0xcb7d('0x16')](function(_0x281428){logger[_0xcb7d('0x11')]('ShowZohoAccount',_0x281428[_0xcb7d('0x13')],_0x67db8b);_0x65ebf8(_0x4dca72['error'](0x1f4,_0x281428[_0xcb7d('0x13')]));});});};