Built motion from commit (unavailable).|2.5.15
[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 _0x0419=['../../mysqldb','../../config/utils','rpc','../../config/environment','client','http','then','info','ZohoAccount,\x20%s,\x20%s','request\x20sent','ZohoAccount,\x20%s,\x20%s,\x20%s','error','message','result','catch','GetZohoAccount','ZohoAccount','findAll','options','attributes','include','map','model','debug','stringify','ShowZohoAccount','find','raw','where','lodash','util','moment','bluebird','randomstring','ioredis'];(function(_0x152449,_0x49f41d){var _0x5b58b2=function(_0x226c30){while(--_0x226c30){_0x152449['push'](_0x152449['shift']());}};_0x5b58b2(++_0x49f41d);}(_0x0419,0xcc));var _0x9041=function(_0x228636,_0x51d570){_0x228636=_0x228636-0x0;var _0x327b9e=_0x0419[_0x228636];return _0x327b9e;};'use strict';var _=require(_0x9041('0x0'));var util=require(_0x9041('0x1'));var moment=require(_0x9041('0x2'));var BPromise=require(_0x9041('0x3'));var rs=require(_0x9041('0x4'));var fs=require('fs');var Redis=require(_0x9041('0x5'));var db=require(_0x9041('0x6'))['db'];var utils=require(_0x9041('0x7'));var logger=require('../../config/logger')(_0x9041('0x8'));var config=require(_0x9041('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x9041('0xa')][_0x9041('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x42ab70,_0x474221,_0x3d51d4){return new BPromise(function(_0xc92fc9,_0x5b4b5e){return client['request'](_0x42ab70,_0x3d51d4)[_0x9041('0xc')](function(_0x253398){logger[_0x9041('0xd')](_0x9041('0xe'),_0x474221,_0x9041('0xf'));logger['debug'](_0x9041('0x10'),_0x474221,_0x9041('0xf'),JSON['stringify'](_0x253398));if(_0x253398[_0x9041('0x11')]){if(_0x253398[_0x9041('0x11')]['code']===0x1f4){logger[_0x9041('0x11')]('ZohoAccount,\x20%s,\x20%s',_0x474221,_0x253398['error']['message']);return _0x5b4b5e(_0x253398[_0x9041('0x11')][_0x9041('0x12')]);}logger[_0x9041('0x11')](_0x9041('0xe'),_0x474221,_0x253398[_0x9041('0x11')]['message']);return _0xc92fc9(_0x253398[_0x9041('0x11')][_0x9041('0x12')]);}else{logger[_0x9041('0xd')](_0x9041('0xe'),_0x474221,_0x9041('0xf'));_0xc92fc9(_0x253398[_0x9041('0x13')][_0x9041('0x12')]);}})[_0x9041('0x14')](function(_0x40c035){logger['error'](_0x9041('0xe'),_0x474221,_0x40c035);_0x5b4b5e(_0x40c035);});});}exports[_0x9041('0x15')]=function(_0x8f4726){var _0x481bf1=this;return new Promise(function(_0x46cbe7,_0x2c3306){return db[_0x9041('0x16')][_0x9041('0x17')]({'raw':_0x8f4726[_0x9041('0x18')]?_0x8f4726[_0x9041('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x8f4726[_0x9041('0x18')]?_0x8f4726[_0x9041('0x18')]['where']||null:null,'attributes':_0x8f4726[_0x9041('0x18')]?_0x8f4726[_0x9041('0x18')][_0x9041('0x19')]||null:null,'limit':_0x8f4726[_0x9041('0x18')]?_0x8f4726['options']['limit']||null:null,'include':_0x8f4726[_0x9041('0x18')]?_0x8f4726[_0x9041('0x18')][_0x9041('0x1a')]?_[_0x9041('0x1b')](_0x8f4726[_0x9041('0x18')][_0x9041('0x1a')],function(_0x392f7a){return{'model':db[_0x392f7a['model']],'as':_0x392f7a['as'],'attributes':_0x392f7a[_0x9041('0x19')],'include':_0x392f7a['include']?_[_0x9041('0x1b')](_0x392f7a[_0x9041('0x1a')],function(_0x2dc551){return{'model':db[_0x2dc551['model']],'as':_0x2dc551['as'],'attributes':_0x2dc551[_0x9041('0x19')],'include':_0x2dc551[_0x9041('0x1a')]?_[_0x9041('0x1b')](_0x2dc551[_0x9041('0x1a')],function(_0x1e9fe1){return{'model':db[_0x1e9fe1[_0x9041('0x1c')]],'as':_0x1e9fe1['as'],'attributes':_0x1e9fe1['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x42ed21){logger['info'](_0x9041('0x15'),_0x8f4726);logger[_0x9041('0x1d')](_0x9041('0x15'),_0x8f4726,JSON[_0x9041('0x1e')](_0x42ed21));_0x46cbe7(_0x42ed21);})[_0x9041('0x14')](function(_0x4d9cdc){logger[_0x9041('0x11')](_0x9041('0x15'),_0x4d9cdc[_0x9041('0x12')],_0x8f4726);_0x2c3306(_0x481bf1[_0x9041('0x11')](0x1f4,_0x4d9cdc['message']));});});};exports[_0x9041('0x1f')]=function(_0x4c7b0e){var _0x4dc639=this;return new Promise(function(_0x3c881c,_0x4d2a78){return db['ZohoAccount'][_0x9041('0x20')]({'raw':_0x4c7b0e[_0x9041('0x18')]?_0x4c7b0e[_0x9041('0x18')][_0x9041('0x21')]===undefined?!![]:![]:!![],'where':_0x4c7b0e[_0x9041('0x18')]?_0x4c7b0e['options'][_0x9041('0x22')]||null:null,'attributes':_0x4c7b0e[_0x9041('0x18')]?_0x4c7b0e[_0x9041('0x18')][_0x9041('0x19')]||null:null,'include':_0x4c7b0e['options']?_0x4c7b0e[_0x9041('0x18')][_0x9041('0x1a')]?_[_0x9041('0x1b')](_0x4c7b0e[_0x9041('0x18')][_0x9041('0x1a')],function(_0x363bd7){return{'model':db[_0x363bd7['model']],'as':_0x363bd7['as'],'attributes':_0x363bd7['attributes'],'include':_0x363bd7['include']?_[_0x9041('0x1b')](_0x363bd7[_0x9041('0x1a')],function(_0x4d09a6){return{'model':db[_0x4d09a6['model']],'as':_0x4d09a6['as'],'attributes':_0x4d09a6[_0x9041('0x19')],'include':_0x4d09a6[_0x9041('0x1a')]?_[_0x9041('0x1b')](_0x4d09a6[_0x9041('0x1a')],function(_0x2918de){return{'model':db[_0x2918de[_0x9041('0x1c')]],'as':_0x2918de['as'],'attributes':_0x2918de['attributes']};}):[]};}):[]};}):[]:[]})[_0x9041('0xc')](function(_0xeca44d){logger[_0x9041('0xd')](_0x9041('0x1f'),_0x4c7b0e);logger[_0x9041('0x1d')]('ShowZohoAccount',_0x4c7b0e,JSON['stringify'](_0xeca44d));_0x3c881c(_0xeca44d);})[_0x9041('0x14')](function(_0x10d4c0){logger[_0x9041('0x11')](_0x9041('0x1f'),_0x10d4c0[_0x9041('0x12')],_0x4c7b0e);_0x4d2a78(_0x4dc639[_0x9041('0x11')](0x1f4,_0x10d4c0[_0x9041('0x12')]));});});};