Built motion from commit e0fa946e.|2.6.5
[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 _0x5454=['model','debug','catch','ShowZohoAccount','find','raw','bluebird','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','then','info','ZohoAccount,\x20%s,\x20%s','request\x20sent','ZohoAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','GetZohoAccount','ZohoAccount','options','where','attributes','map','include'];(function(_0x55cb9f,_0x64654d){var _0x272a75=function(_0x2d4f90){while(--_0x2d4f90){_0x55cb9f['push'](_0x55cb9f['shift']());}};_0x272a75(++_0x64654d);}(_0x5454,0x15b));var _0x4545=function(_0x28a21c,_0x3edcac){_0x28a21c=_0x28a21c-0x0;var _0x578519=_0x5454[_0x28a21c];return _0x578519;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require(_0x4545('0x0'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x4545('0x1'));var logger=require(_0x4545('0x2'))(_0x4545('0x3'));var config=require(_0x4545('0x4'));var jayson=require('jayson/promise');var client=jayson[_0x4545('0x5')][_0x4545('0x6')]({'port':0x232a});function respondWithRpcPromise(_0x6fd3bb,_0xc79c57,_0x3f1134){return new BPromise(function(_0x1fd7e5,_0x1c5649){return client[_0x4545('0x7')](_0x6fd3bb,_0x3f1134)[_0x4545('0x8')](function(_0x3e2526){logger[_0x4545('0x9')](_0x4545('0xa'),_0xc79c57,_0x4545('0xb'));logger['debug'](_0x4545('0xc'),_0xc79c57,_0x4545('0xb'),JSON[_0x4545('0xd')](_0x3e2526));if(_0x3e2526[_0x4545('0xe')]){if(_0x3e2526[_0x4545('0xe')][_0x4545('0xf')]===0x1f4){logger['error'](_0x4545('0xa'),_0xc79c57,_0x3e2526[_0x4545('0xe')][_0x4545('0x10')]);return _0x1c5649(_0x3e2526[_0x4545('0xe')][_0x4545('0x10')]);}logger[_0x4545('0xe')](_0x4545('0xa'),_0xc79c57,_0x3e2526[_0x4545('0xe')][_0x4545('0x10')]);return _0x1fd7e5(_0x3e2526[_0x4545('0xe')][_0x4545('0x10')]);}else{logger['info'](_0x4545('0xa'),_0xc79c57,_0x4545('0xb'));_0x1fd7e5(_0x3e2526[_0x4545('0x11')][_0x4545('0x10')]);}})['catch'](function(_0x4a5bdf){logger[_0x4545('0xe')](_0x4545('0xa'),_0xc79c57,_0x4a5bdf);_0x1c5649(_0x4a5bdf);});});}exports[_0x4545('0x12')]=function(_0x2e13e0){var _0x207e38=this;return new Promise(function(_0x33393b,_0x3161c8){return db[_0x4545('0x13')]['findAll']({'raw':_0x2e13e0['options']?_0x2e13e0[_0x4545('0x14')]['raw']===undefined?!![]:![]:!![],'where':_0x2e13e0[_0x4545('0x14')]?_0x2e13e0[_0x4545('0x14')][_0x4545('0x15')]||null:null,'attributes':_0x2e13e0[_0x4545('0x14')]?_0x2e13e0[_0x4545('0x14')][_0x4545('0x16')]||null:null,'limit':_0x2e13e0[_0x4545('0x14')]?_0x2e13e0[_0x4545('0x14')]['limit']||null:null,'include':_0x2e13e0['options']?_0x2e13e0[_0x4545('0x14')]['include']?_[_0x4545('0x17')](_0x2e13e0['options'][_0x4545('0x18')],function(_0x4c47c0){return{'model':db[_0x4c47c0['model']],'as':_0x4c47c0['as'],'attributes':_0x4c47c0[_0x4545('0x16')],'include':_0x4c47c0[_0x4545('0x18')]?_[_0x4545('0x17')](_0x4c47c0[_0x4545('0x18')],function(_0x344633){return{'model':db[_0x344633[_0x4545('0x19')]],'as':_0x344633['as'],'attributes':_0x344633[_0x4545('0x16')],'include':_0x344633[_0x4545('0x18')]?_[_0x4545('0x17')](_0x344633[_0x4545('0x18')],function(_0x3e5807){return{'model':db[_0x3e5807[_0x4545('0x19')]],'as':_0x3e5807['as'],'attributes':_0x3e5807[_0x4545('0x16')]};}):[]};}):[]};}):[]:[]})[_0x4545('0x8')](function(_0x1d8c39){logger[_0x4545('0x9')]('GetZohoAccount',_0x2e13e0);logger[_0x4545('0x1a')](_0x4545('0x12'),_0x2e13e0,JSON[_0x4545('0xd')](_0x1d8c39));_0x33393b(_0x1d8c39);})[_0x4545('0x1b')](function(_0xb9c5ee){logger['error'](_0x4545('0x12'),_0xb9c5ee[_0x4545('0x10')],_0x2e13e0);_0x3161c8(_0x207e38[_0x4545('0xe')](0x1f4,_0xb9c5ee[_0x4545('0x10')]));});});};exports[_0x4545('0x1c')]=function(_0x27b7d7){var _0x52dd8e=this;return new Promise(function(_0x406920,_0x80b55f){return db[_0x4545('0x13')][_0x4545('0x1d')]({'raw':_0x27b7d7[_0x4545('0x14')]?_0x27b7d7[_0x4545('0x14')][_0x4545('0x1e')]===undefined?!![]:![]:!![],'where':_0x27b7d7[_0x4545('0x14')]?_0x27b7d7[_0x4545('0x14')][_0x4545('0x15')]||null:null,'attributes':_0x27b7d7[_0x4545('0x14')]?_0x27b7d7['options'][_0x4545('0x16')]||null:null,'include':_0x27b7d7['options']?_0x27b7d7[_0x4545('0x14')][_0x4545('0x18')]?_['map'](_0x27b7d7[_0x4545('0x14')][_0x4545('0x18')],function(_0x46e814){return{'model':db[_0x46e814[_0x4545('0x19')]],'as':_0x46e814['as'],'attributes':_0x46e814[_0x4545('0x16')],'include':_0x46e814[_0x4545('0x18')]?_[_0x4545('0x17')](_0x46e814['include'],function(_0x1abc06){return{'model':db[_0x1abc06[_0x4545('0x19')]],'as':_0x1abc06['as'],'attributes':_0x1abc06[_0x4545('0x16')],'include':_0x1abc06[_0x4545('0x18')]?_[_0x4545('0x17')](_0x1abc06[_0x4545('0x18')],function(_0x5bc452){return{'model':db[_0x5bc452[_0x4545('0x19')]],'as':_0x5bc452['as'],'attributes':_0x5bc452[_0x4545('0x16')]};}):[]};}):[]};}):[]:[]})[_0x4545('0x8')](function(_0x3cee1a){logger[_0x4545('0x9')](_0x4545('0x1c'),_0x27b7d7);logger[_0x4545('0x1a')](_0x4545('0x1c'),_0x27b7d7,JSON[_0x4545('0xd')](_0x3cee1a));_0x406920(_0x3cee1a);})['catch'](function(_0x47c85d){logger['error'](_0x4545('0x1c'),_0x47c85d['message'],_0x27b7d7);_0x80b55f(_0x52dd8e[_0x4545('0xe')](0x1f4,_0x47c85d[_0x4545('0x10')]));});});};