Built motion from commit (unavailable).|2.5.26
[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 _0xcd47=['bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request\x20sent','debug','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','ZohoAccount,\x20%s,\x20%s','message','info','result','catch','GetZohoAccount','ZohoAccount','findAll','raw','options','where','limit','include','map','model','attributes','then','ShowZohoAccount','lodash','moment'];(function(_0xa148b7,_0x2f3eb2){var _0x51efd3=function(_0x34bcec){while(--_0x34bcec){_0xa148b7['push'](_0xa148b7['shift']());}};_0x51efd3(++_0x2f3eb2);}(_0xcd47,0x1c5));var _0x7cd4=function(_0x29d4ed,_0x264f8e){_0x29d4ed=_0x29d4ed-0x0;var _0x21a4a6=_0xcd47[_0x29d4ed];return _0x21a4a6;};'use strict';var _=require(_0x7cd4('0x0'));var util=require('util');var moment=require(_0x7cd4('0x1'));var BPromise=require(_0x7cd4('0x2'));var rs=require(_0x7cd4('0x3'));var fs=require('fs');var Redis=require(_0x7cd4('0x4'));var db=require(_0x7cd4('0x5'))['db'];var utils=require(_0x7cd4('0x6'));var logger=require(_0x7cd4('0x7'))(_0x7cd4('0x8'));var config=require(_0x7cd4('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x7cd4('0xa')][_0x7cd4('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x19d371,_0x4c9fcf,_0x176e15){return new BPromise(function(_0x195667,_0x3cc9a5){return client['request'](_0x19d371,_0x176e15)['then'](function(_0x351c92){logger['info']('ZohoAccount,\x20%s,\x20%s',_0x4c9fcf,_0x7cd4('0xc'));logger[_0x7cd4('0xd')](_0x7cd4('0xe'),_0x4c9fcf,_0x7cd4('0xc'),JSON[_0x7cd4('0xf')](_0x351c92));if(_0x351c92[_0x7cd4('0x10')]){if(_0x351c92[_0x7cd4('0x10')]['code']===0x1f4){logger[_0x7cd4('0x10')](_0x7cd4('0x11'),_0x4c9fcf,_0x351c92[_0x7cd4('0x10')][_0x7cd4('0x12')]);return _0x3cc9a5(_0x351c92[_0x7cd4('0x10')][_0x7cd4('0x12')]);}logger[_0x7cd4('0x10')](_0x7cd4('0x11'),_0x4c9fcf,_0x351c92[_0x7cd4('0x10')][_0x7cd4('0x12')]);return _0x195667(_0x351c92[_0x7cd4('0x10')][_0x7cd4('0x12')]);}else{logger[_0x7cd4('0x13')](_0x7cd4('0x11'),_0x4c9fcf,_0x7cd4('0xc'));_0x195667(_0x351c92[_0x7cd4('0x14')][_0x7cd4('0x12')]);}})[_0x7cd4('0x15')](function(_0x129a85){logger[_0x7cd4('0x10')](_0x7cd4('0x11'),_0x4c9fcf,_0x129a85);_0x3cc9a5(_0x129a85);});});}exports[_0x7cd4('0x16')]=function(_0x2774d5){var _0x255ec6=this;return new Promise(function(_0xa3898e,_0x1586ca){return db[_0x7cd4('0x17')][_0x7cd4('0x18')]({'raw':_0x2774d5['options']?_0x2774d5['options'][_0x7cd4('0x19')]===undefined?!![]:![]:!![],'where':_0x2774d5[_0x7cd4('0x1a')]?_0x2774d5[_0x7cd4('0x1a')][_0x7cd4('0x1b')]||null:null,'attributes':_0x2774d5[_0x7cd4('0x1a')]?_0x2774d5['options']['attributes']||null:null,'limit':_0x2774d5[_0x7cd4('0x1a')]?_0x2774d5['options'][_0x7cd4('0x1c')]||null:null,'include':_0x2774d5[_0x7cd4('0x1a')]?_0x2774d5[_0x7cd4('0x1a')][_0x7cd4('0x1d')]?_[_0x7cd4('0x1e')](_0x2774d5[_0x7cd4('0x1a')]['include'],function(_0x2f517a){return{'model':db[_0x2f517a[_0x7cd4('0x1f')]],'as':_0x2f517a['as'],'attributes':_0x2f517a[_0x7cd4('0x20')],'include':_0x2f517a[_0x7cd4('0x1d')]?_[_0x7cd4('0x1e')](_0x2f517a[_0x7cd4('0x1d')],function(_0x42bb10){return{'model':db[_0x42bb10[_0x7cd4('0x1f')]],'as':_0x42bb10['as'],'attributes':_0x42bb10[_0x7cd4('0x20')],'include':_0x42bb10['include']?_[_0x7cd4('0x1e')](_0x42bb10[_0x7cd4('0x1d')],function(_0x300a47){return{'model':db[_0x300a47[_0x7cd4('0x1f')]],'as':_0x300a47['as'],'attributes':_0x300a47[_0x7cd4('0x20')]};}):[]};}):[]};}):[]:[]})[_0x7cd4('0x21')](function(_0x5e34b0){logger[_0x7cd4('0x13')](_0x7cd4('0x16'),_0x2774d5);logger[_0x7cd4('0xd')](_0x7cd4('0x16'),_0x2774d5,JSON['stringify'](_0x5e34b0));_0xa3898e(_0x5e34b0);})[_0x7cd4('0x15')](function(_0x5ba030){logger[_0x7cd4('0x10')](_0x7cd4('0x16'),_0x5ba030['message'],_0x2774d5);_0x1586ca(_0x255ec6[_0x7cd4('0x10')](0x1f4,_0x5ba030[_0x7cd4('0x12')]));});});};exports[_0x7cd4('0x22')]=function(_0x501f2a){var _0x480400=this;return new Promise(function(_0x51424a,_0x437e4f){return db[_0x7cd4('0x17')]['find']({'raw':_0x501f2a['options']?_0x501f2a[_0x7cd4('0x1a')][_0x7cd4('0x19')]===undefined?!![]:![]:!![],'where':_0x501f2a[_0x7cd4('0x1a')]?_0x501f2a['options'][_0x7cd4('0x1b')]||null:null,'attributes':_0x501f2a['options']?_0x501f2a[_0x7cd4('0x1a')][_0x7cd4('0x20')]||null:null,'include':_0x501f2a[_0x7cd4('0x1a')]?_0x501f2a[_0x7cd4('0x1a')]['include']?_[_0x7cd4('0x1e')](_0x501f2a[_0x7cd4('0x1a')][_0x7cd4('0x1d')],function(_0x24f6ad){return{'model':db[_0x24f6ad['model']],'as':_0x24f6ad['as'],'attributes':_0x24f6ad[_0x7cd4('0x20')],'include':_0x24f6ad[_0x7cd4('0x1d')]?_[_0x7cd4('0x1e')](_0x24f6ad['include'],function(_0x1b6da4){return{'model':db[_0x1b6da4[_0x7cd4('0x1f')]],'as':_0x1b6da4['as'],'attributes':_0x1b6da4[_0x7cd4('0x20')],'include':_0x1b6da4[_0x7cd4('0x1d')]?_[_0x7cd4('0x1e')](_0x1b6da4[_0x7cd4('0x1d')],function(_0x1a04b1){return{'model':db[_0x1a04b1[_0x7cd4('0x1f')]],'as':_0x1a04b1['as'],'attributes':_0x1a04b1[_0x7cd4('0x20')]};}):[]};}):[]};}):[]:[]})[_0x7cd4('0x21')](function(_0x18b987){logger['info'](_0x7cd4('0x22'),_0x501f2a);logger[_0x7cd4('0xd')](_0x7cd4('0x22'),_0x501f2a,JSON[_0x7cd4('0xf')](_0x18b987));_0x51424a(_0x18b987);})[_0x7cd4('0x15')](function(_0x349fcb){logger['error'](_0x7cd4('0x22'),_0x349fcb[_0x7cd4('0x12')],_0x501f2a);_0x437e4f(_0x480400[_0x7cd4('0x10')](0x1f4,_0x349fcb[_0x7cd4('0x12')]));});});};