07d88dd97f4c84ca5f58d3eeb9ca7a1aee671aa0
[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 _0xc0ef=['lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','info','request\x20sent','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','ZohoAccount,\x20%s,\x20%s','result','catch','GetZohoAccount','ZohoAccount','options','raw','attributes','include','map','model','then','debug','ShowZohoAccount','where'];(function(_0x3f5d03,_0x16a8ed){var _0x4c33e3=function(_0x5164fb){while(--_0x5164fb){_0x3f5d03['push'](_0x3f5d03['shift']());}};_0x4c33e3(++_0x16a8ed);}(_0xc0ef,0xee));var _0xfc0e=function(_0x3bd302,_0x386af1){_0x3bd302=_0x3bd302-0x0;var _0x625ff5=_0xc0ef[_0x3bd302];return _0x625ff5;};'use strict';var _=require(_0xfc0e('0x0'));var util=require(_0xfc0e('0x1'));var moment=require(_0xfc0e('0x2'));var BPromise=require(_0xfc0e('0x3'));var rs=require(_0xfc0e('0x4'));var fs=require('fs');var Redis=require(_0xfc0e('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xfc0e('0x6'));var logger=require(_0xfc0e('0x7'))(_0xfc0e('0x8'));var config=require(_0xfc0e('0x9'));var jayson=require(_0xfc0e('0xa'));var client=jayson[_0xfc0e('0xb')]['http']({'port':0x232a});function respondWithRpcPromise(_0x11e8ed,_0x64f45f,_0x51d9bf){return new BPromise(function(_0x2d600d,_0x3339bf){return client[_0xfc0e('0xc')](_0x11e8ed,_0x51d9bf)['then'](function(_0x10b90a){logger[_0xfc0e('0xd')]('ZohoAccount,\x20%s,\x20%s',_0x64f45f,_0xfc0e('0xe'));logger['debug'](_0xfc0e('0xf'),_0x64f45f,_0xfc0e('0xe'),JSON[_0xfc0e('0x10')](_0x10b90a));if(_0x10b90a[_0xfc0e('0x11')]){if(_0x10b90a[_0xfc0e('0x11')]['code']===0x1f4){logger['error']('ZohoAccount,\x20%s,\x20%s',_0x64f45f,_0x10b90a['error'][_0xfc0e('0x12')]);return _0x3339bf(_0x10b90a['error'][_0xfc0e('0x12')]);}logger[_0xfc0e('0x11')]('ZohoAccount,\x20%s,\x20%s',_0x64f45f,_0x10b90a['error']['message']);return _0x2d600d(_0x10b90a[_0xfc0e('0x11')]['message']);}else{logger[_0xfc0e('0xd')](_0xfc0e('0x13'),_0x64f45f,'request\x20sent');_0x2d600d(_0x10b90a[_0xfc0e('0x14')][_0xfc0e('0x12')]);}})[_0xfc0e('0x15')](function(_0x45cb2b){logger[_0xfc0e('0x11')]('ZohoAccount,\x20%s,\x20%s',_0x64f45f,_0x45cb2b);_0x3339bf(_0x45cb2b);});});}exports[_0xfc0e('0x16')]=function(_0x1bc034){var _0x42b6bf=this;return new Promise(function(_0x22f84b,_0x1d820c){return db[_0xfc0e('0x17')]['findAll']({'raw':_0x1bc034[_0xfc0e('0x18')]?_0x1bc034[_0xfc0e('0x18')][_0xfc0e('0x19')]===undefined?!![]:![]:!![],'where':_0x1bc034['options']?_0x1bc034[_0xfc0e('0x18')]['where']||null:null,'attributes':_0x1bc034[_0xfc0e('0x18')]?_0x1bc034[_0xfc0e('0x18')][_0xfc0e('0x1a')]||null:null,'limit':_0x1bc034[_0xfc0e('0x18')]?_0x1bc034['options']['limit']||null:null,'include':_0x1bc034[_0xfc0e('0x18')]?_0x1bc034[_0xfc0e('0x18')][_0xfc0e('0x1b')]?_[_0xfc0e('0x1c')](_0x1bc034[_0xfc0e('0x18')][_0xfc0e('0x1b')],function(_0x40e3ff){return{'model':db[_0x40e3ff['model']],'as':_0x40e3ff['as'],'attributes':_0x40e3ff['attributes'],'include':_0x40e3ff[_0xfc0e('0x1b')]?_[_0xfc0e('0x1c')](_0x40e3ff[_0xfc0e('0x1b')],function(_0xa06ba8){return{'model':db[_0xa06ba8[_0xfc0e('0x1d')]],'as':_0xa06ba8['as'],'attributes':_0xa06ba8['attributes'],'include':_0xa06ba8[_0xfc0e('0x1b')]?_[_0xfc0e('0x1c')](_0xa06ba8['include'],function(_0x21ab62){return{'model':db[_0x21ab62[_0xfc0e('0x1d')]],'as':_0x21ab62['as'],'attributes':_0x21ab62['attributes']};}):[]};}):[]};}):[]:[]})[_0xfc0e('0x1e')](function(_0x2de45a){logger['info'](_0xfc0e('0x16'),_0x1bc034);logger[_0xfc0e('0x1f')](_0xfc0e('0x16'),_0x1bc034,JSON['stringify'](_0x2de45a));_0x22f84b(_0x2de45a);})['catch'](function(_0x176d08){logger[_0xfc0e('0x11')](_0xfc0e('0x16'),_0x176d08[_0xfc0e('0x12')],_0x1bc034);_0x1d820c(_0x42b6bf[_0xfc0e('0x11')](0x1f4,_0x176d08['message']));});});};exports[_0xfc0e('0x20')]=function(_0x4b31b2){var _0x10af8d=this;return new Promise(function(_0x53efda,_0x17cc33){return db[_0xfc0e('0x17')]['find']({'raw':_0x4b31b2['options']?_0x4b31b2[_0xfc0e('0x18')][_0xfc0e('0x19')]===undefined?!![]:![]:!![],'where':_0x4b31b2[_0xfc0e('0x18')]?_0x4b31b2[_0xfc0e('0x18')][_0xfc0e('0x21')]||null:null,'attributes':_0x4b31b2['options']?_0x4b31b2['options']['attributes']||null:null,'include':_0x4b31b2[_0xfc0e('0x18')]?_0x4b31b2[_0xfc0e('0x18')][_0xfc0e('0x1b')]?_['map'](_0x4b31b2[_0xfc0e('0x18')][_0xfc0e('0x1b')],function(_0x2e9d50){return{'model':db[_0x2e9d50[_0xfc0e('0x1d')]],'as':_0x2e9d50['as'],'attributes':_0x2e9d50[_0xfc0e('0x1a')],'include':_0x2e9d50[_0xfc0e('0x1b')]?_[_0xfc0e('0x1c')](_0x2e9d50[_0xfc0e('0x1b')],function(_0x544eb3){return{'model':db[_0x544eb3[_0xfc0e('0x1d')]],'as':_0x544eb3['as'],'attributes':_0x544eb3['attributes'],'include':_0x544eb3[_0xfc0e('0x1b')]?_['map'](_0x544eb3[_0xfc0e('0x1b')],function(_0x433890){return{'model':db[_0x433890[_0xfc0e('0x1d')]],'as':_0x433890['as'],'attributes':_0x433890[_0xfc0e('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xfc0e('0x1e')](function(_0x12ba92){logger[_0xfc0e('0xd')](_0xfc0e('0x20'),_0x4b31b2);logger[_0xfc0e('0x1f')](_0xfc0e('0x20'),_0x4b31b2,JSON[_0xfc0e('0x10')](_0x12ba92));_0x53efda(_0x12ba92);})[_0xfc0e('0x15')](function(_0x3b4c16){logger[_0xfc0e('0x11')](_0xfc0e('0x20'),_0x3b4c16[_0xfc0e('0x12')],_0x4b31b2);_0x17cc33(_0x10af8d[_0xfc0e('0x11')](0x1f4,_0x3b4c16[_0xfc0e('0x12')]));});});};