Built motion from commit (unavailable).|2.5.31
[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 _0xcf86=['bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','ZohoAccount,\x20%s,\x20%s','request\x20sent','debug','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','catch','GetZohoAccount','ZohoAccount','options','where','attributes','limit','include','model','find','map','ShowZohoAccount','lodash','util','moment'];(function(_0x4963cc,_0x5d8ada){var _0x3c9875=function(_0x38f286){while(--_0x38f286){_0x4963cc['push'](_0x4963cc['shift']());}};_0x3c9875(++_0x5d8ada);}(_0xcf86,0x165));var _0x6cf8=function(_0x13ea00,_0x12f610){_0x13ea00=_0x13ea00-0x0;var _0x1f7347=_0xcf86[_0x13ea00];return _0x1f7347;};'use strict';var _=require(_0x6cf8('0x0'));var util=require(_0x6cf8('0x1'));var moment=require(_0x6cf8('0x2'));var BPromise=require(_0x6cf8('0x3'));var rs=require(_0x6cf8('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x6cf8('0x5'))['db'];var utils=require(_0x6cf8('0x6'));var logger=require(_0x6cf8('0x7'))(_0x6cf8('0x8'));var config=require(_0x6cf8('0x9'));var jayson=require(_0x6cf8('0xa'));var client=jayson[_0x6cf8('0xb')][_0x6cf8('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x33c512,_0x1e24d1,_0x2979d8){return new BPromise(function(_0x212601,_0x56ff80){return client[_0x6cf8('0xd')](_0x33c512,_0x2979d8)[_0x6cf8('0xe')](function(_0x1cd98e){logger['info'](_0x6cf8('0xf'),_0x1e24d1,_0x6cf8('0x10'));logger[_0x6cf8('0x11')](_0x6cf8('0x12'),_0x1e24d1,_0x6cf8('0x10'),JSON[_0x6cf8('0x13')](_0x1cd98e));if(_0x1cd98e[_0x6cf8('0x14')]){if(_0x1cd98e[_0x6cf8('0x14')]['code']===0x1f4){logger[_0x6cf8('0x14')]('ZohoAccount,\x20%s,\x20%s',_0x1e24d1,_0x1cd98e[_0x6cf8('0x14')]['message']);return _0x56ff80(_0x1cd98e['error'][_0x6cf8('0x15')]);}logger[_0x6cf8('0x14')](_0x6cf8('0xf'),_0x1e24d1,_0x1cd98e['error'][_0x6cf8('0x15')]);return _0x212601(_0x1cd98e[_0x6cf8('0x14')]['message']);}else{logger[_0x6cf8('0x16')](_0x6cf8('0xf'),_0x1e24d1,_0x6cf8('0x10'));_0x212601(_0x1cd98e[_0x6cf8('0x17')][_0x6cf8('0x15')]);}})[_0x6cf8('0x18')](function(_0x5875ed){logger[_0x6cf8('0x14')](_0x6cf8('0xf'),_0x1e24d1,_0x5875ed);_0x56ff80(_0x5875ed);});});}exports[_0x6cf8('0x19')]=function(_0x3a878d){var _0x30bda7=this;return new Promise(function(_0x5d0002,_0x5dc71b){return db[_0x6cf8('0x1a')]['findAll']({'raw':_0x3a878d['options']?_0x3a878d[_0x6cf8('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x3a878d[_0x6cf8('0x1b')]?_0x3a878d[_0x6cf8('0x1b')][_0x6cf8('0x1c')]||null:null,'attributes':_0x3a878d['options']?_0x3a878d[_0x6cf8('0x1b')][_0x6cf8('0x1d')]||null:null,'limit':_0x3a878d[_0x6cf8('0x1b')]?_0x3a878d[_0x6cf8('0x1b')][_0x6cf8('0x1e')]||null:null,'include':_0x3a878d[_0x6cf8('0x1b')]?_0x3a878d[_0x6cf8('0x1b')][_0x6cf8('0x1f')]?_['map'](_0x3a878d['options'][_0x6cf8('0x1f')],function(_0xba8264){return{'model':db[_0xba8264[_0x6cf8('0x20')]],'as':_0xba8264['as'],'attributes':_0xba8264[_0x6cf8('0x1d')],'include':_0xba8264[_0x6cf8('0x1f')]?_['map'](_0xba8264[_0x6cf8('0x1f')],function(_0xa3e77f){return{'model':db[_0xa3e77f[_0x6cf8('0x20')]],'as':_0xa3e77f['as'],'attributes':_0xa3e77f['attributes'],'include':_0xa3e77f[_0x6cf8('0x1f')]?_['map'](_0xa3e77f[_0x6cf8('0x1f')],function(_0x2d3732){return{'model':db[_0x2d3732[_0x6cf8('0x20')]],'as':_0x2d3732['as'],'attributes':_0x2d3732[_0x6cf8('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2b9cc8){logger[_0x6cf8('0x16')](_0x6cf8('0x19'),_0x3a878d);logger[_0x6cf8('0x11')](_0x6cf8('0x19'),_0x3a878d,JSON[_0x6cf8('0x13')](_0x2b9cc8));_0x5d0002(_0x2b9cc8);})[_0x6cf8('0x18')](function(_0x5cca26){logger[_0x6cf8('0x14')](_0x6cf8('0x19'),_0x5cca26[_0x6cf8('0x15')],_0x3a878d);_0x5dc71b(_0x30bda7[_0x6cf8('0x14')](0x1f4,_0x5cca26[_0x6cf8('0x15')]));});});};exports['ShowZohoAccount']=function(_0x810109){var _0x5d48be=this;return new Promise(function(_0xf8fa9,_0x5144bd){return db[_0x6cf8('0x1a')][_0x6cf8('0x21')]({'raw':_0x810109['options']?_0x810109[_0x6cf8('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x810109[_0x6cf8('0x1b')]?_0x810109[_0x6cf8('0x1b')][_0x6cf8('0x1c')]||null:null,'attributes':_0x810109[_0x6cf8('0x1b')]?_0x810109[_0x6cf8('0x1b')]['attributes']||null:null,'include':_0x810109['options']?_0x810109[_0x6cf8('0x1b')][_0x6cf8('0x1f')]?_[_0x6cf8('0x22')](_0x810109['options'][_0x6cf8('0x1f')],function(_0xfe7466){return{'model':db[_0xfe7466[_0x6cf8('0x20')]],'as':_0xfe7466['as'],'attributes':_0xfe7466[_0x6cf8('0x1d')],'include':_0xfe7466[_0x6cf8('0x1f')]?_[_0x6cf8('0x22')](_0xfe7466[_0x6cf8('0x1f')],function(_0x5a47a2){return{'model':db[_0x5a47a2[_0x6cf8('0x20')]],'as':_0x5a47a2['as'],'attributes':_0x5a47a2[_0x6cf8('0x1d')],'include':_0x5a47a2['include']?_[_0x6cf8('0x22')](_0x5a47a2[_0x6cf8('0x1f')],function(_0x1caa49){return{'model':db[_0x1caa49[_0x6cf8('0x20')]],'as':_0x1caa49['as'],'attributes':_0x1caa49[_0x6cf8('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x6cf8('0xe')](function(_0x1b4c83){logger[_0x6cf8('0x16')](_0x6cf8('0x23'),_0x810109);logger['debug']('ShowZohoAccount',_0x810109,JSON['stringify'](_0x1b4c83));_0xf8fa9(_0x1b4c83);})['catch'](function(_0x56b01e){logger[_0x6cf8('0x14')]('ShowZohoAccount',_0x56b01e[_0x6cf8('0x15')],_0x810109);_0x5144bd(_0x5d48be[_0x6cf8('0x14')](0x1f4,_0x56b01e['message']));});});};